#1976 Implementar Puppeteer ticket module + others
gitea/salix/puppeteer There was a failure building this commit Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-01-23 16:01:29 +01:00
parent 584212a659
commit 0c5ce6586f
39 changed files with 1155 additions and 1125 deletions

View File

@ -51,6 +51,11 @@ let actions = {
await this.waitForURL('#!/login');
} catch (e) {
await this.goto(`${defaultURL}/#!/login`);
let dialog = await this.evaluate(() => {
return document.querySelector('button[response="accept"]');
});
if (dialog)
await this.waitToClick('button[response="accept"]');
}
await this.doLogin(userName);
@ -139,20 +144,24 @@ let actions = {
},
waitPropertyValue: async function(selector, property, status) {
await this.wait(selector);
return await this.wait((selector, property, status) => {
await this.waitForSelector(selector);
return await this.waitForFunction((selector, property, status) => {
const element = document.querySelector(selector);
return element[property] === status;
}, {}, selector, property, status);
},
waitToGetProperty: async function(selector, property) {
await this.wait((selector, property) => {
const element = document.querySelector(selector);
try {
await this.waitForFunction((selector, property) => {
const element = document.querySelector(selector);
return element && element[property] != null && element[property] !== '';
}, {}, selector, property);
return await this.getProperty(selector, property);
return element && element[property] != null && element[property] !== '';
}, {}, selector, property);
return await this.getProperty(selector, property);
} catch (error) {
throw new Error(`couldn't get property: ${property} of ${selector}`);
}
},
write: async function(selector, text) {
@ -162,8 +171,8 @@ let actions = {
},
waitToClick: async function(selector) {
await this.wait(selector);
await this.click(selector);
await this.waitForSelector(selector, {});
await this.click(selector, {waitUntil: 'domcontentloaded'});
},
focusElement: async function(selector) {
@ -279,11 +288,11 @@ let actions = {
},
waitForInnerText: async function(selector) {
await this.wait(selector);
await this.wait(selector => {
await this.waitForSelector(selector, {});
await this.waitForFunction(selector => {
const innerText = document.querySelector(selector).innerText;
return innerText != null && innerText != '';
}, selector);
}, {}, selector);
return await this.evaluate(selector => {
return document.querySelector(selector).innerText;
}, selector);
@ -337,7 +346,6 @@ let actions = {
return document.querySelector(`vn-left-menu li li > a[ui-sref="${sectionRoute}"]`) != null;
}, sectionRoute);
if (nested) {
await this.waitToClick('vn-left-menu vn-item-section > vn-icon[icon=keyboard_arrow_down]');
await this.wait('vn-left-menu .expanded');
@ -353,19 +361,21 @@ let actions = {
autocompleteSearch: async function(selector, searchValue) {
try {
await this.waitToClick(`${selector} input`),
await this.waitToClick(`${selector} input`);
await this.waitForSelector(selector => {
document
.querySelector(`${selector} vn-drop-down`).$ctrl.content
.querySelectorAll('li');
}, selector);
await this.write(`.vn-drop-down.shown`, searchValue),
await this.waitForFunction(selector => {
return document
await this.write(`.vn-drop-down.shown`, searchValue);
await this.waitForFunction((selector, searchValue) => {
let element = document
.querySelector(`${selector} vn-drop-down`).$ctrl.content
.querySelector('li.active');
}, {}, selector);
if (element)
return element.innerText.toLowerCase().includes(searchValue.toLowerCase());
}, {}, selector, searchValue);
await this.keyboard.press('Enter');
await this.waitForFunction((selector, searchValue) => {
@ -379,13 +389,16 @@ let actions = {
},
reloadSection: async function(sectionRoute) {
await this.evaluate(() => {
let summayButton = document.querySelector('vn-icon[icon="desktop_windows"]');
summayButton.scrollIntoViewIfNeeded();
return summayButton.click();
});
await this.wait('vn-card.summary');
await this.waitToClick(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`);
await this.waitFor(1000);
await Promise.all([
this.waitForNavigation({waitUntil: 'networkidle0'}),
this.click('vn-icon[icon="desktop_windows"]', {}),
]);
await Promise.all([
this.waitForNavigation({waitUntil: 'networkidle0'}),
this.click(`vn-left-menu li > a[ui-sref="${sectionRoute}"]`, {}),
]);
},
forceReloadSection: async function(sectionRoute) {
@ -476,12 +489,16 @@ let actions = {
},
waitForContentLoaded: async function() {
await this.evaluate(() => {
return new Promise(resolve => {
const $rootScope = angular.element(document.body).injector().get('$rootScope');
$rootScope.$on('$viewContentLoaded', resolve());
});
});
await this.waitFor(1000);
// to be implemented in base of a directive loaded once al modules are done loading, further investigation required.
// await this.waitForFunction(() => {
// return new Promise(resolve => {
// angular.element(document).ready(() => resolve());
// const $rootScope = angular.element(document).find('ui-view').injector().get('$rootScope');
// $rootScope.$$postDigest(resolve());
// $rootScope.$on('$viewContentLoaded', resolve());
// });
// });
}
};

View File

@ -6,7 +6,7 @@ import {url as defaultURL} from './config';
export async function getBrowser() {
const browser = await Puppeteer.launch({
args: [
`--window-size=${ 1920 },${ 1080 }`,
`--window-size=${ 1920 },${ 1080 }`
],
defaultViewport: null,
headless: false,
@ -14,7 +14,7 @@ export async function getBrowser() {
});
let page = (await browser.pages())[0];
page = extendPage(page);
await page.setDefaultTimeout(5000);
page.setDefaultTimeout(5000);
await page.goto(defaultURL, {waitUntil: 'networkidle0'});
return {page, close: browser.close.bind(browser)};
}

View File

@ -340,7 +340,7 @@ export default {
searchWeeklyButton: 'vn-searchbar vn-icon[icon="search"]',
moreMenu: 'vn-ticket-index vn-icon-menu[icon=more_vert]',
menuWeeklyTickets: 'vn-left-menu [ui-sref="ticket.weekly.index"]',
sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6) [name="weekDay"]',
sixthWeeklyTicket: 'vn-ticket-weekly-index vn-table vn-tr:nth-child(6)',
weeklyTicket: 'vn-ticket-weekly-index vn-table > div > vn-tbody > vn-tr',
firstWeeklyTicketDeleteIcon: 'vn-ticket-weekly-index vn-tr:nth-child(1) vn-icon-button[icon="delete"]',
acceptDeleteTurn: '.vn-confirm.shown button[response="accept"]'
@ -381,7 +381,7 @@ export default {
addNoteButton: 'vn-icon[icon="add_circle"]',
firstNoteTypeAutocomplete: 'vn-autocomplete[ng-model="observation.observationTypeFk"]',
firstDescriptionInput: 'vn-ticket-observation [ng-model="observation.description"]',
submitNotesButton: `button[type=submit]`
submitNotesButton: 'button[type=submit]'
},
ticketExpedition: {
expeditionButton: 'vn-left-menu a[ui-sref="ticket.card.expedition"]',

View File

@ -53,6 +53,7 @@ describe('Client create path', async() => {
await page.write(selectors.createClientView.name, 'Carol Danvers');
await page.write(selectors.createClientView.socialName, 'AVG tax');
await page.write(selectors.createClientView.street, 'Many places');
await page.waitForContentLoaded();
await page.autocompleteSearch(selectors.createClientView.country, 'España');
await page.autocompleteSearch(selectors.createClientView.province, 'Province one');
await page.write(selectors.createClientView.city, 'Valencia');
@ -101,6 +102,7 @@ describe('Client create path', async() => {
});
it('should click on the Clients button of the top bar menu', async() => {
await page.waitFor(500);
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.clientsButton);

View File

@ -25,6 +25,7 @@ describe('Client Add credit path', () => {
});
it(`should edit the credit`, async() => {
await page.waitForContentLoaded();
await page.clearInput(selectors.clientCredit.creditInput);
await page.write(selectors.clientCredit.creditInput, '999');
await page.waitToClick(selectors.clientCredit.saveButton);
@ -34,6 +35,7 @@ describe('Client Add credit path', () => {
});
it('should confirm the credit was updated', async() => {
await page.waitForContentLoaded();
const result = await page.waitToGetProperty(selectors.clientCredit.firstCreditText, 'innerText');
expect(result).toContain(999);

View File

@ -132,6 +132,7 @@ describe('Client balance path', () => {
it(`should click on the search result to access to the client's balance`, async() => {
await page.waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker');
await page.waitToClick(selectors.clientsIndex.searchResult);
await page.waitForContentLoaded();
await page.waitToClick(selectors.clientBalance.balanceButton);
await page.waitForURL('/balance');
let url = await page.parsedUrl();

View File

@ -37,10 +37,11 @@ describe('Item Edit basic data path', () => {
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
}, 15000);
}, 20000);
it(`should confirm the item name was edited`, async() => {
await page.reloadSection('item.card.basicData');
await page.waitForContentLoaded();
const result = await page.waitToGetProperty(`${selectors.itemBasicData.nameInput} input`, 'value');
expect(result).toEqual('Rose of Purity');

View File

@ -42,6 +42,7 @@ describe('Item Create/Clone path', () => {
});
it('should now access to the create item view by clicking the create floating button', async() => {
await page.waitForContentLoaded();
await page.waitToClick(selectors.itemsIndex.createItemButton);
await page.wait(selectors.itemCreateView.createButton);
const url = await page.parsedUrl();

View File

@ -1,94 +1,98 @@
import selectors from '../../../helpers/selectors.js';
import createNightmare from '../../../helpers/nightmare';
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket List sale path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
return nightmare
.loginAndModule('employee', 'ticket')
.accessToSearchResult(13)
.accessToSection('ticket.card.sale');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
await page.accessToSearchResult('13');
await page.accessToSection('ticket.card.sale');
});
afterAll(async() => {
await browser.close();
});
it('should confirm the first ticket sale contains the colour', async() => {
const value = await nightmare
const value = await page
.waitToGetProperty(selectors.ticketSales.firstSaleColour, 'innerText');
expect(value).toContain('Black');
});
it('should confirm the first sale contains the price', async() => {
const value = await nightmare
const value = await page
.waitToGetProperty(selectors.ticketSales.firstSalePrice, 'innerText');
expect(value).toContain('1.72');
});
it('should confirm the first sale contains the discount', async() => {
const value = await nightmare
const value = await page
.waitToGetProperty(selectors.ticketSales.firstSaleDiscount, 'innerText');
expect(value).toContain('0 %');
});
it('should confirm the first sale contains the total import', async() => {
const value = await nightmare
const value = await page
.waitToGetProperty(selectors.ticketSales.firstSaleImport, 'innerText');
expect(value).toContain('34.40');
});
it('should add an empty item to the sale list', async() => {
const sales = await nightmare
.waitToClick(selectors.ticketSales.newItemButton)
await page.waitToClick(selectors.ticketSales.newItemButton);
const sales = await page
.countElement(selectors.ticketSales.saleLine);
expect(sales).toEqual(2);
});
it('should select a valid item to be added as the second item in the sales list', async() => {
const result = await nightmare
.waitToClick(selectors.ticketSales.secondSaleIdInput)
.write(selectors.ticketSales.secondSaleIdAutocomplete, 'Melee weapon heavy shield 1x0.5m')
.waitToClick(selectors.ticketSales.idAutocompleteFirstResult)
.write(selectors.ticketSales.secondSaleQuantity, '1\u000d')
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketSales.secondSaleIdInput);
await page.write(selectors.ticketSales.secondSaleIdAutocomplete, 'Melee weapon heavy shield 1x0.5m');
await page.waitToClick(selectors.ticketSales.idAutocompleteFirstResult);
await page.write(selectors.ticketSales.secondSaleQuantity, '1');
await page.keyboard.press('Enter');
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
// #1865
xit('should update the description of the new sale', async() => {
const result = await nightmare
.focusElement(selectors.ticketSales.secondSaleConceptCell)
.write(selectors.ticketSales.secondSaleConceptInput, 'Aegis of Valor\u000d')
.waitForLastSnackbar();
await page.focusElement(selectors.ticketSales.secondSaleConceptCell);
await page.write(selectors.ticketSales.secondSaleConceptInput, 'Aegis of Valor');
await page.keyboard.press('Enter');
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should add a third empty item to the sale list', async() => {
const sales = await nightmare
.waitToClick(selectors.ticketSales.newItemButton)
.countElement(selectors.ticketSales.saleLine);
await page.waitToClick(selectors.ticketSales.newItemButton);
const sales = await page.countElement(selectors.ticketSales.saleLine);
expect(sales).toEqual(3);
});
it('should select the 2nd and 3th item and delete both', async() => {
const result = await nightmare
.waitToClick(selectors.ticketSales.secondSaleCheckbox)
.waitToClick(selectors.ticketSales.thirdSaleCheckbox)
.waitToClick(selectors.ticketSales.deleteSaleButton)
.waitToClick(selectors.ticketSales.acceptDeleteLineButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketSales.secondSaleCheckbox);
await page.waitToClick(selectors.ticketSales.thirdSaleCheckbox);
await page.waitToClick(selectors.ticketSales.deleteSaleButton);
await page.waitToClick(selectors.ticketSales.acceptDeleteLineButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should verify there's only 1 single line remaining`, async() => {
const sales = await nightmare
.countElement(selectors.ticketSales.saleLine);
const sales = await page.countElement(selectors.ticketSales.saleLine);
expect(sales).toEqual(1);
});

View File

@ -3,15 +3,21 @@ import createNightmare from '../../../helpers/nightmare';
// #1632 [e2e] ticket.sale - Transferir líneas
xdescribe('Ticket Edit sale path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
.loginAndModule('salesPerson', 'ticket')
.accessToSearchResult(16)
.accessToSection('ticket.card.sale');
});
afterAll(async() => {
await browser.close();
});
it(`should click on the first sale claim icon to navigate over there`, async() => {
const url = await nightmare
.waitToClick(selectors.ticketSales.firstSaleClaimIcon)

View File

@ -1,45 +1,50 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket Create notes path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
return nightmare
.loginAndModule('employee', 'ticket')
.accessToSearchResult(1)
.accessToSection('ticket.card.observation');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
await page.accessToSearchResult('1');
await page.accessToSection('ticket.card.observation');
});
afterAll(async() => {
await browser.close();
});
it('should create a new note', async() => {
let result = await nightmare
.waitToClick(selectors.ticketNotes.addNoteButton)
.autocompleteSearch(selectors.ticketNotes.firstNoteTypeAutocomplete, 'observation one')
.write(selectors.ticketNotes.firstDescriptionInput, 'description')
.waitToClick(selectors.ticketNotes.submitNotesButton)
.waitForLastSnackbar();
await page.waitForContentLoaded();
await page.waitToClick(selectors.ticketNotes.addNoteButton);
await page.autocompleteSearch(selectors.ticketNotes.firstNoteTypeAutocomplete, 'observation one');
await page.write(selectors.ticketNotes.firstDescriptionInput, 'description');
await page.waitToClick(selectors.ticketNotes.submitNotesButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
}, 15000);
it('should confirm the note is the expected one', async() => {
let result = await nightmare
.reloadSection('ticket.card.observation')
await page.reloadSection('ticket.card.observation');
const result = await page
.waitToGetProperty(`${selectors.ticketNotes.firstNoteTypeAutocomplete} input`, 'value');
expect(result).toEqual('observation one');
let firstDescription = await nightmare
.waitToGetProperty(selectors.ticketNotes.firstDescriptionInput, 'value');
const firstDescription = await page
.waitToGetProperty(`${selectors.ticketNotes.firstDescriptionInput} input`, 'value');
expect(firstDescription).toEqual('description');
});
it('should delete the note', async() => {
let result = await nightmare
.waitToClick(selectors.ticketNotes.firstNoteRemoveButton)
.waitToClick(selectors.ticketNotes.submitNotesButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketNotes.firstNoteRemoveButton);
await page.waitToClick(selectors.ticketNotes.submitNotesButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});

View File

@ -1,36 +1,42 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket expeditions and log path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
return nightmare
.loginAndModule('production', 'ticket')
.accessToSearchResult('1')
.accessToSection('ticket.card.expedition');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('production', 'ticket');
await page.accessToSearchResult('1');
await page.accessToSection('ticket.card.expedition');
});
afterAll(async() => {
await browser.close();
});
it(`should delete a former expedition and confirm the remaining expedition are the expected ones`, async() => {
const result = await nightmare
.waitToClick(selectors.ticketExpedition.secondExpeditionRemoveButton)
.waitToClick(selectors.ticketExpedition.acceptDeleteRowButton)
.waitToClick(selectors.ticketPackages.packagesButton)
.wait(selectors.ticketPackages.firstPackageAutocomplete)
.waitToClick(selectors.ticketExpedition.expeditionButton)
.wait(selectors.ticketExpedition.expeditionRow)
await page.waitToClick(selectors.ticketExpedition.secondExpeditionRemoveButton);
await page.waitToClick(selectors.ticketExpedition.acceptDeleteRowButton),
await page.reloadSection('ticket.card.expedition');
await page.waitForSelector(selectors.ticketExpedition.expeditionRow, {});
const result = await page
.countElement(selectors.ticketExpedition.expeditionRow);
expect(result).toEqual(3);
});
it(`should confirm the expedition deleted is shown now in the ticket log`, async() => {
const changedBy = await nightmare
.waitToClick(selectors.ticketLog.logButton)
await page.waitToClick(selectors.ticketLog.logButton);
const changedBy = await page
.waitToGetProperty(selectors.ticketLog.changedBy, 'innerText');
const actionTaken = await nightmare
const actionTaken = await page
.waitToGetProperty(selectors.ticketLog.actionTaken, 'innerText');
const id = await nightmare
const id = await page
.waitToGetProperty(selectors.ticketLog.id, 'innerText');
expect(changedBy).toEqual('production');

View File

@ -1,69 +1,70 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket Create packages path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
return nightmare
.loginAndModule('employee', 'ticket')
.accessToSearchResult('1')
.accessToSection('ticket.card.package');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
await page.accessToSearchResult('1');
await page.accessToSection('ticket.card.package');
});
afterAll(async() => {
await browser.close();
});
it(`should attempt create a new package but receive an error if package is blank`, async() => {
const result = await nightmare
.waitToClick(selectors.ticketPackages.firstRemovePackageButton)
.waitToClick(selectors.ticketPackages.addPackageButton)
.write(selectors.ticketPackages.firstQuantityInput, 99)
.waitToClick(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketPackages.firstRemovePackageButton);
await page.waitToClick(selectors.ticketPackages.addPackageButton);
await page.write(selectors.ticketPackages.firstQuantityInput, '99');
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Package cannot be blank');
});
it(`should delete the first package and receive and error to save a new one with blank quantity`, async() => {
const result = await nightmare
.clearInput(selectors.ticketPackages.firstQuantityInput)
.autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m')
.waitToClick(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
await page.clearInput(selectors.ticketPackages.firstQuantityInput);
await page.autocompleteSearch(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m');
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
});
it(`should confirm the quantity input isn't invalid yet`, async() => {
const result = await nightmare
const result = await page
.evaluate(selector => {
return document.querySelector(selector).checkValidity();
return document.querySelector(`${selector} input`).checkValidity();
}, selectors.ticketPackages.firstQuantityInput);
expect(result).toBeTruthy();
});
it(`should create a new package with correct data`, async() => {
const result = await nightmare
.clearInput(selectors.ticketPackages.firstQuantityInput)
.write(selectors.ticketPackages.firstQuantityInput, -99)
.waitToClick(selectors.ticketPackages.savePackagesButton)
.waitForLastSnackbar();
await page.clearInput(selectors.ticketPackages.firstQuantityInput);
await page.write(selectors.ticketPackages.firstQuantityInput, '-99');
await page.waitToClick(selectors.ticketPackages.savePackagesButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the first select is the expected one`, async() => {
const result = await nightmare
.reloadSection('ticket.card.package')
.waitForTextInInput(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m')
.waitToGetProperty(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'value');
await page.reloadSection('ticket.card.package');
await page.waitForTextInInput(selectors.ticketPackages.firstPackageAutocomplete, 'Container medical box 1m');
const result = await page.waitToGetProperty(`${selectors.ticketPackages.firstPackageAutocomplete} input`, 'value');
expect(result).toEqual('7 : Container medical box 1m');
});
it(`should confirm the first quantity is just a number and the string part was ignored by the imput number`, async() => {
const result = await nightmare
.waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '-99')
.waitToGetProperty(selectors.ticketPackages.firstQuantityInput, 'value');
await page.waitForTextInInput(selectors.ticketPackages.firstQuantityInput, '-99');
const result = await page.waitToGetProperty(`${selectors.ticketPackages.firstQuantityInput} input`, 'value');
expect(result).toEqual('-99');
});

View File

@ -1,83 +1,82 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket Create new tracking state path', () => {
const nightmare = createNightmare();
let browser;
let page;
afterAll(async() => {
await browser.close();
});
describe('as production', () => {
beforeAll(() => {
return nightmare
.loginAndModule('production', 'ticket')
.accessToSearchResult('1')
.accessToSection('ticket.card.tracking.index');
it('should log into the ticket 1 tracking', async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('production', 'ticket');
await page.accessToSearchResult('1');
await page.accessToSection('ticket.card.tracking.index');
});
it('should access to the create state view by clicking the create floating button', async() => {
let url = await nightmare
.clickIfVisible(selectors.ticketTracking.createStateButton)
.wait(selectors.createStateView.stateAutocomplete)
.parsedUrl();
await page.clickIfVisible(selectors.ticketTracking.createStateButton);
await page.wait(selectors.createStateView.stateAutocomplete);
let url = await page.parsedUrl();
expect(url.hash).toContain('tracking/edit');
});
it(`should attempt create a new state but receive an error if state is empty`, async() => {
let result = await nightmare
.waitToClick(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
expect(result).toEqual('State cannot be blank');
});
it(`should create a new state`, async() => {
let result = await nightmare
.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?')
.waitToClick(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
await page.autocompleteSearch(selectors.createStateView.stateAutocomplete, '¿Fecha?');
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
});
describe('as salesPerson', () => {
beforeAll(() => {
return nightmare
.loginAndModule('salesPerson', 'ticket')
.accessToSearchResult('1')
.accessToSection('ticket.card.tracking.index');
it('should now log into the ticket 1 tracking', async() => {
await page.loginAndModule('salesPerson', 'ticket');
await page.accessToSearchResult('1');
await page.accessToSection('ticket.card.tracking.index');
});
it('should now access to the create state view by clicking the create floating button', async() => {
let url = await nightmare
.waitToClick(selectors.ticketTracking.createStateButton)
.wait(selectors.createStateView.stateAutocomplete)
.parsedUrl();
await page.waitToClick(selectors.ticketTracking.createStateButton);
await page.waitForURL('tracking/edit');
let url = await page.parsedUrl();
expect(url.hash).toContain('tracking/edit');
});
it(`should attemp to create an state for which salesPerson doesn't have permissions`, async() => {
let result = await nightmare
.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'Encajado')
.waitToClick(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
await page.waitFor(1500);
await page.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'Encajado');
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
expect(result).toEqual(`You don't have enough privileges`);
});
it(`should make sure the worker gets autocomplete uppon selecting the assigned state`, async() => {
let result = await nightmare
.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'asignado')
await page.autocompleteSearch(selectors.createStateView.stateAutocomplete, 'asignado');
let result = await page
.waitToGetProperty(`${selectors.createStateView.workerAutocomplete} input`, 'value');
expect(result).toEqual('salesPersonNick');
});
it(`should succesfully create a valid state`, async() => {
let result = await nightmare
.waitToClick(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.createStateView.saveStateButton);
let result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});

View File

@ -1,98 +1,98 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket Edit basic data path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
return nightmare
.loginAndModule('employee', 'ticket')
.accessToSearchResult(11)
.accessToSection('ticket.card.basicData.stepOne');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
await page.accessToSearchResult('11');
await page.accessToSection('ticket.card.basicData.stepOne');
});
afterAll(async() => {
await browser.close();
});
it(`should confirm the zone autocomplete is disabled unless your role is productionBoss`, async() => {
const disabled = await nightmare
.wait(selectors.ticketBasicData.zoneAutocomplete)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, `${selectors.ticketBasicData.zoneAutocomplete} input`);
await page.waitForSelector(selectors.ticketBasicData.zoneAutocomplete, {});
const disabled = await page.evaluate(selector => {
return document.querySelector(selector).disabled;
}, `${selectors.ticketBasicData.zoneAutocomplete} input`);
expect(disabled).toBeTruthy();
});
it(`should now log as productionBoss to perform the rest of the tests`, async() => {
await nightmare
.loginAndModule('productionBoss', 'ticket')
.accessToSearchResult(11)
.accessToSection('ticket.card.basicData.stepOne');
await page.loginAndModule('productionBoss', 'ticket');
await page.accessToSearchResult('11');
await page.accessToSection('ticket.card.basicData.stepOne');
});
it(`should confirm the zone autocomplete is enabled for the role productionBoss`, async() => {
const disabled = await nightmare
.waitForSpinnerLoad()
.wait(selectors.ticketBasicData.zoneAutocomplete)
.evaluate(selector => {
return document.querySelector(selector).disabled;
}, `${selectors.ticketBasicData.zoneAutocomplete} input`);
await page.waitForSpinnerLoad();
await page.wait(selectors.ticketBasicData.zoneAutocomplete);
const disabled = await page.evaluate(selector => {
return document.querySelector(selector).disabled;
}, `${selectors.ticketBasicData.zoneAutocomplete} input`);
expect(disabled).toBeFalsy();
});
it(`should check the zone is for Silla247`, async() => {
let zone = await nightmare
let zone = await page
.waitToGetProperty(`${selectors.ticketBasicData.zoneAutocomplete} input`, 'value');
expect(zone).toContain('Zone 247 A');
});
it(`should edit the ticket agency then check there are no zones for it`, async() => {
let zone = await nightmare
.autocompleteSearch(selectors.ticketBasicData.agencyAutocomplete, 'Entanglement')
await page.autocompleteSearch(selectors.ticketBasicData.agencyAutocomplete, 'Entanglement');
let zone = await page
.getProperty(`${selectors.ticketBasicData.zoneAutocomplete} input`, 'value');
expect(zone.length).toEqual(0);
});
it(`should edit the ticket zone then check the agency is for the new zone`, async() => {
let zone = await nightmare
.autocompleteSearch(selectors.ticketBasicData.zoneAutocomplete, 'Zone expensive A')
await page.autocompleteSearch(selectors.ticketBasicData.zoneAutocomplete, 'Zone expensive A');
let zone = await page
.waitToGetProperty(`${selectors.ticketBasicData.agencyAutocomplete} input`, 'value');
expect(zone).toContain('Silla247Expensive');
});
it(`should click next`, async() => {
let url = await nightmare
.waitToClick(selectors.ticketBasicData.nextStepButton)
.waitForURL('data/step-two')
.parsedUrl();
await page.waitToClick(selectors.ticketBasicData.nextStepButton);
await page.waitForURL('data/step-two');
let url = await page.parsedUrl();
expect(url.hash).toContain('data/step-two');
});
it(`should have a price diference`, async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.ticketBasicData.stepTwoTotalPriceDif, 'innerText');
expect(result).toContain('-€248.00');
});
it(`should then click next to move on to step three`, async() => {
let url = await nightmare
.waitToClick(selectors.ticketBasicData.nextStepButton)
.waitForURL('data/step-three')
.parsedUrl();
await page.waitToClick(selectors.ticketBasicData.nextStepButton);
await page.waitForURL('data/step-three');
let url = await page.parsedUrl();
expect(url.hash).toContain('data/step-three');
});
it(`should select a new reason for the changes made then click on finalize`, async() => {
let url = await nightmare
.autocompleteSearch(selectors.ticketBasicData.chargesReasonAutocomplete, 'Cambiar los precios en el ticket')
.waitToClick(selectors.ticketBasicData.finalizeButton)
.waitForURL('summary')
.parsedUrl();
await page.autocompleteSearch(selectors.ticketBasicData.chargesReasonAutocomplete, 'Cambiar los precios en el ticket');
await page.waitToClick(selectors.ticketBasicData.finalizeButton);
await page.waitForURL('summary');
let url = await page.parsedUrl();
expect(url.hash).toContain('summary');
});

View File

@ -1,23 +1,28 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket List components path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
return nightmare
.loginAndModule('employee', 'ticket')
.accessToSearchResult('1')
.accessToSection('ticket.card.components');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
await page.accessToSearchResult('1');
await page.accessToSection('ticket.card.components');
});
afterAll(async() => {
await browser.close();
});
it('should confirm the total base is correct', async() => {
const name = 'Base €';
const minLength = name.length;
const base = await nightmare
.waitPropertyLength(selectors.ticketComponents.base, 'innerText', minLength)
.waitToGetProperty(selectors.ticketComponents.base, 'innerText');
await page.waitPropertyLength(selectors.ticketComponents.base, 'innerText', minLength);
const base = await page.waitToGetProperty(selectors.ticketComponents.base, 'innerText');
expect(base).toContain('Base');

View File

@ -1,166 +1,140 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket descriptor path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
await page.accessToSection('ticket.weekly.index');
});
afterAll(async() => {
await browser.close();
});
it('should count the amount of tickets in the turns section', async() => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.menuWeeklyTickets)
.wait(selectors.ticketsIndex.weeklyTicket)
.countElement(selectors.ticketsIndex.weeklyTicket);
await page.waitForNumberOfElements(selectors.ticketsIndex.weeklyTicket, 5);
const result = await page.countElement(selectors.ticketsIndex.weeklyTicket);
expect(result).toEqual(5);
});
it('should now click on the Tickets button of the top bar menu', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should search for the ticket 11', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 11)
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should click on the search result to access to the ticket`, async() => {
const url = await nightmare
.waitToClick(selectors.ticketsIndex.searchResult)
.waitForURL('/summary')
.parsedUrl();
expect(url.hash).toContain('/summary');
it('should go back to the ticket index then search and access a ticket summary', async() => {
await page.accessToSection('ticket.index');
await page.accessToSearchResult('11');
await page.waitForContentLoaded();
});
it('should add the ticket to thursday turn using the descriptor more menu', async() => {
const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn)
.waitToClick(selectors.ticketDescriptor.thursdayButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn);
await page.waitToClick(selectors.ticketDescriptor.thursdayButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should again click on the Tickets button of the top bar menu', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
.parsedUrl();
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.ticketsButton);
await page.waitForContentLoaded();
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should confirm the ticket 11 was added on thursday', async() => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.menuWeeklyTickets)
.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value');
it('should confirm the ticket 11 was added to thursday', async() => {
await page.accessToSection('ticket.weekly.index');
const result = await page.waitToGetProperty(`${selectors.ticketsIndex.sixthWeeklyTicket} input`, 'value');
expect(result).toEqual('Thursday');
});
it('should click on the Tickets button of the top bar menu once more', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
.parsedUrl();
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.ticketsButton);
await page.waitForURL('#!/ticket/index');
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should now search for the ticket 11', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 11)
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
await page.waitForContentLoaded();
await page.write(selectors.ticketsIndex.searchTicketInput, '11');
await page.waitToClick(selectors.ticketsIndex.searchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should click on the search result to access to the ticket`, async() => {
const url = await nightmare
.waitToClick(selectors.ticketsIndex.searchResult)
.waitForURL('/summary')
.parsedUrl();
await page.waitToClick(selectors.ticketsIndex.searchResult);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it('should add the ticket to saturday turn using the descriptor more menu', async() => {
const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn)
.waitToClick(selectors.ticketDescriptor.saturdayButton)
.waitForLastSnackbar();
await page.waitForContentLoaded();
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuAddToTurn);
await page.waitToClick(selectors.ticketDescriptor.saturdayButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should click on the Tickets button of the top bar menu once again', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
.parsedUrl();
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.ticketsButton);
await page.wait(selectors.ticketsIndex.searchTicketInput);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should confirm the ticket 11 was added on saturday', async() => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.menuWeeklyTickets)
.waitToGetProperty(selectors.ticketsIndex.sixthWeeklyTicket, 'value');
await page.accessToSection('ticket.weekly.index');
const result = await page.waitToGetProperty(`${selectors.ticketsIndex.sixthWeeklyTicket} input`, 'value');
expect(result).toEqual('Saturday');
});
it('should now search for the weekly ticket 11', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchWeeklyTicketInput, 11)
.waitToClick(selectors.ticketsIndex.searchWeeklyButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 1)
.countElement(selectors.ticketsIndex.searchWeeklyResult);
await page.write(selectors.ticketsIndex.searchTicketInput, '11');
await page.waitToClick(selectors.ticketsIndex.searchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
expect(result).toEqual(1);
});
it('should delete the weekly ticket 11', async() => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.firstWeeklyTicketDeleteIcon)
.waitToClick(selectors.ticketsIndex.acceptDeleteTurn)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketsIndex.firstWeeklyTicketDeleteIcon);
await page.waitToClick(selectors.ticketsIndex.acceptDeleteTurn);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the sixth weekly ticket was deleted', async() => {
const result = await nightmare
.waitToClick('vn-searchbar vn-icon[icon=clear]')
.waitToClick(selectors.ticketsIndex.searchWeeklyButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 5)
.countElement(selectors.ticketsIndex.searchWeeklyResult);
await page.waitForContentLoaded();
await page.clearInput('vn-searchbar');
await page.waitToClick(selectors.ticketsIndex.searchWeeklyButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchWeeklyResult, 5);
const result = await page.countElement(selectors.ticketsIndex.searchWeeklyResult);
expect(result).toEqual(5);
});

View File

@ -1,59 +1,58 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket purchase request path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('salesPerson', 'ticket')
.accessToSearchResult('16')
.accessToSection('ticket.card.request.index');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('salesPerson', 'ticket');
await page.accessToSearchResult('16');
await page.accessToSection('ticket.card.request.index');
});
afterAll(async() => {
await browser.close();
});
it(`should add a new request`, async() => {
const result = await nightmare
.waitToClick(selectors.ticketRequests.addRequestButton)
.write(selectors.ticketRequests.descriptionInput, 'New stuff')
.write(selectors.ticketRequests.quantityInput, 99)
.autocompleteSearch(selectors.ticketRequests.atenderAutocomplete, 'buyerNick')
.write(selectors.ticketRequests.priceInput, 999)
.waitToClick(selectors.ticketRequests.saveButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketRequests.addRequestButton);
await page.write(selectors.ticketRequests.descriptionInput, 'New stuff');
await page.write(selectors.ticketRequests.quantityInput, '99');
await page.autocompleteSearch(selectors.ticketRequests.atenderAutocomplete, 'buyerNick');
await page.write(selectors.ticketRequests.priceInput, '999');
await page.waitToClick(selectors.ticketRequests.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should have been redirected to the request index`, async() => {
const url = await nightmare
.waitForURL('/request')
.parsedUrl();
await page.waitForURL('/request');
const url = await page.parsedUrl();
expect(url.hash).toContain('/request');
});
it(`should confirm the new request was added`, async() => {
const result = await nightmare
.reloadSection('ticket.card.request.index')
.waitToGetProperty(selectors.ticketRequests.firstDescription, 'innerText');
await page.reloadSection('ticket.card.request.index');
const result = await page.waitToGetProperty(selectors.ticketRequests.firstDescription, 'innerText');
expect(result).toEqual('New stuff');
});
it(`should delete the added request`, async() => {
const result = await nightmare
.waitToClick(selectors.ticketRequests.firstRemoveRequestButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketRequests.firstRemoveRequestButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the request was deleted`, async() => {
const result = await nightmare
.reloadSection('ticket.card.request.index')
.wait(selectors.ticketRequests.addRequestButton)
.exists(selectors.ticketRequests.request);
expect(result).toBeFalsy();
await page.reloadSection('ticket.card.request.index');
await page.wait(selectors.ticketRequests.addRequestButton);
await page.waitForSelector(selectors.ticketRequests.request, {hidden: true});
});
});

View File

@ -1,61 +1,66 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket diary path', () => {
const nightmare = createNightmare();
// #2026 Fallo en relocate de descriptor popover
xdescribe('Ticket diary path', () => {
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
});
afterAll(async() => {
await browser.close();
});
it('should search for a specific ticket', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 1)
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
await page.write(selectors.ticketsIndex.searchTicketInput, '1');
await page.waitToClick(selectors.ticketsIndex.searchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should click on the search result to access to the ticket summary`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Bat cave')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitForURL('/summary')
.parsedUrl();
await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Bat cave');
await page.waitToClick(selectors.ticketsIndex.searchResult);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should navigate to the item diary from the 1st sale item id descriptor popover`, async() => {
const url = await nightmare
.waitToClick(selectors.ticketSummary.firstSaleItemId)
.waitToClick(selectors.ticketSummary.popoverDiaryButton)
.waitForURL('/diary')
.parsedUrl();
await page.waitToClick(selectors.ticketSummary.firstSaleItemId);
await page.waitForTransitionEnd('.vn-popover');
await page.waitToClick(selectors.ticketSummary.popoverDiaryButton);
await page.waitForURL('/diary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/diary');
});
it(`should check the second line id is marked as message`, async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.itemDiary.secondTicketId, 'className');
expect(result).toContain('message');
});
it(`should check the third line balance is marked as message`, async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(`${selectors.itemDiary.fourthBalance} > span`, 'className');
expect(result).toContain('message');
});
it(`should change to the warehouse two and check there are sales marked as negative balance`, async() => {
const result = await nightmare
.autocompleteSearch(selectors.itemDiary.warehouseAutocomplete, 'Warehouse Two')
await page.autocompleteSearch(selectors.itemDiary.warehouseAutocomplete, 'Warehouse Two');
const result = await page
.waitToGetProperty(selectors.itemDiary.firstBalance, 'className');
expect(result).toContain('balance');

View File

@ -1,77 +1,78 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket descriptor path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('salesperson', 'ticket');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('salesperson', 'ticket');
});
afterAll(async() => {
await browser.close();
});
describe('Delete ticket', () => {
it('should search for an specific ticket', async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 18)
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
await page.write(selectors.ticketsIndex.searchTicketInput, '18');
await page.waitToClick(selectors.ticketsIndex.searchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should click on the search result to access to the ticket summary`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Cerebro')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitForURL('/summary')
.parsedUrl();
await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Cerebro');
await page.waitToClick(selectors.ticketsIndex.searchResult);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should update the shipped hour using the descriptor menu`, async() => {
const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuChangeShippedHour)
.pickTime(selectors.ticketDescriptor.changeShippedHourInput, '08:15')
.waitToClick(selectors.ticketDescriptor.acceptChangeHourButton)
.waitForLastSnackbar();
await page.waitForContentLoaded();
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuChangeShippedHour);
await page.pickTime(selectors.ticketDescriptor.changeShippedHourInput, '08:15');
await page.waitToClick(selectors.ticketDescriptor.acceptChangeHourButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Shipped hour updated');
});
it(`should confirm the ticket descriptor shows the correct shipping hour`, async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.ticketDescriptor.descriptorDeliveryDate, 'innerText');
expect(result).toContain('08:15');
});
it('should delete the ticket using the descriptor more menu', async() => {
const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket)
.waitToClick(selectors.ticketDescriptor.acceptDeleteButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteTicket);
await page.waitToClick(selectors.ticketDescriptor.acceptDeleteButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Ticket deleted');
});
it('should have been relocated to the ticket index', async() => {
const url = await nightmare
.parsedUrl();
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it(`should search for the deleted ticket and check it's date`, async() => {
const result = await nightmare
.write(selectors.ticketsIndex.searchTicketInput, 18)
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.wait(selectors.ticketsIndex.searchResultDate)
.waitToGetProperty(selectors.ticketsIndex.searchResultDate, 'innerText');
await page.write(selectors.ticketsIndex.searchTicketInput, '18');
await page.waitToClick(selectors.ticketsIndex.searchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
await page.wait(selectors.ticketsIndex.searchResultDate);
const result = await page.waitToGetProperty(selectors.ticketsIndex.searchResultDate, 'innerText');
expect(result).toContain(2000);
});
@ -79,116 +80,105 @@ describe('Ticket descriptor path', () => {
describe('add stowaway', () => {
it('should search for a ticket', async() => {
const result = await nightmare
.clearInput(selectors.ticketsIndex.searchTicketInput)
.write(selectors.ticketsIndex.searchTicketInput, 16)
.waitToClick(selectors.ticketsIndex.searchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
await page.clearInput(selectors.ticketsIndex.searchTicketInput);
await page.write(selectors.ticketsIndex.searchTicketInput, '16');
await page.waitToClick(selectors.ticketsIndex.searchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
it(`should now click on the search result to access to the ticket summary`, async() => {
const url = await nightmare
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Many Places')
.waitToClick(selectors.ticketsIndex.searchResult)
.waitForURL('/summary')
.parsedUrl();
await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Many Places');
await page.waitToClick(selectors.ticketsIndex.searchResult);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it('should open the add stowaway dialog', async() => {
const isVisible = await nightmare
.wait(() => {
let element = document.querySelector('vn-ticket-descriptor');
return element.$ctrl.canShowStowaway === true;
})
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway)
.wait(selectors.ticketDescriptor.addStowawayDialogFirstTicket)
.visible(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
await page.waitForFunction(() => {
let element = document.querySelector('vn-ticket-descriptor');
return element.$ctrl.canShowStowaway === true;
});
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuAddStowaway);
await page.wait(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
const isVisible = await page.isVisible(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
expect(isVisible).toBeTruthy();
});
it('should add a ticket as stowaway', async() => {
const result = await nightmare
.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketDescriptor.addStowawayDialogFirstTicket);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should check the state of the stowaway ticket is embarked`, async() => {
const state = await nightmare
.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText');
const state = await page.waitToGetProperty(selectors.ticketDescriptor.stateLabelValue, 'innerText');
expect(state).toEqual('State Embarcando');
});
it(`should navigate back to the added ticket using the descriptors ship button`, async() => {
const url = await nightmare
.waitToClick(selectors.ticketDescriptor.shipButton)
.waitForURL('#!/ticket/17/summary')
.parsedUrl();
await page.waitToClick(selectors.ticketDescriptor.shipButton);
await page.waitForURL('#!/ticket/17/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('#!/ticket/17/summary');
});
it('should delete the stowaway', async() => {
const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuDeleteStowawayButton)
.waitToClick(selectors.ticketDescriptor.acceptDeleteStowawayButton)
.waitForLastSnackbar();
await page.waitForContentLoaded();
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuDeleteStowawayButton);
await page.waitToClick(selectors.ticketDescriptor.acceptDeleteStowawayButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the ship buton doesn't exisist any more`, async() => {
const exists = await nightmare
.exists(selectors.ticketDescriptor.shipButton);
expect(exists).toBeFalsy();
await page.waitForSelector(selectors.ticketDescriptor.shipButton, {hidden: true});
});
});
describe('Make invoice', () => {
it('should login as adminBoss role then search for a ticket', async() => {
const invoiceableTicketId = 14;
const invoiceableTicketId = '14';
const url = await nightmare
.loginAndModule('adminBoss', 'ticket')
.accessToSearchResult(invoiceableTicketId)
.waitForURL('/summary')
.parsedUrl();
await page.loginAndModule('adminBoss', 'ticket');
await page.accessToSearchResult(invoiceableTicketId);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain(`ticket/${invoiceableTicketId}/summary`);
});
it(`should make sure the ticket doesn't have an invoiceOutFk yet`, async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.ticketSummary.invoiceOutRef, 'innerText');
expect(result).toEqual('-');
});
it('should invoice the ticket using the descriptor more menu', async() => {
const result = await nightmare
.waitToClick(selectors.ticketDescriptor.moreMenu)
.waitToClick(selectors.ticketDescriptor.moreMenuMakeInvoice)
.waitToClick(selectors.ticketDescriptor.acceptInvoiceOutButton)
.waitForLastSnackbar();
await page.waitForContentLoaded();
await page.waitToClick(selectors.ticketDescriptor.moreMenu);
await page.waitToClick(selectors.ticketDescriptor.moreMenuMakeInvoice);
await page.waitToClick(selectors.ticketDescriptor.acceptInvoiceOutButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Ticket invoiced');
});
it(`should make sure the ticket summary have an invoiceOutFk`, async() => {
const result = await nightmare
.waitForTextInElement(selectors.ticketSummary.invoiceOutRef, 'T4444445')
.waitToGetProperty(selectors.ticketSummary.invoiceOutRef, 'innerText');
await page.waitForTextInElement(selectors.ticketSummary.invoiceOutRef, 'T4444445');
const result = await page.waitToGetProperty(selectors.ticketSummary.invoiceOutRef, 'innerText');
expect(result).toEqual('T4444445');
});

View File

@ -1,141 +1,138 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket services path', () => {
const nightmare = createNightmare();
const invoicedTicketId = 1;
let browser;
let page;
const invoicedTicketId = '1';
afterAll(async() => {
await browser.close();
});
describe('as employee', () => {
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket')
.accessToSearchResult(invoicedTicketId)
.accessToSection('ticket.card.service');
it('should log in as employee, search for an invoice and get to services', async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
await page.accessToSearchResult(invoicedTicketId);
await page.accessToSection('ticket.card.service');
});
it('should find the add descripton button disabled for this user role', async() => {
const result = await nightmare
.waitForClassPresent(selectors.ticketService.firstAddServiceTypeButton, 'disabled')
.waitToClick(selectors.ticketService.addServiceButton)
.wait(selectors.ticketService.firstAddServiceTypeButton)
.isDisabled(selectors.ticketService.firstAddServiceTypeButton);
await page.waitForClassPresent(selectors.ticketService.firstAddServiceTypeButton, 'disabled');
await page.waitToClick(selectors.ticketService.addServiceButton);
await page.wait(selectors.ticketService.firstAddServiceTypeButton);
const result = await page.isDisabled(selectors.ticketService.firstAddServiceTypeButton);
expect(result).toBeTruthy();
}, 100000);
}, 15000);
it('should receive an error if you attempt to save a service without access rights', async() => {
const result = await nightmare
.clearInput(selectors.ticketService.firstPriceInput)
.write(selectors.ticketService.firstPriceInput, 999)
.waitToClick(selectors.ticketService.saveServiceButton)
.waitForLastSnackbar();
await page.clearInput(selectors.ticketService.firstPriceInput);
await page.write(selectors.ticketService.firstPriceInput, '999');
await page.waitToClick(selectors.ticketService.saveServiceButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual(`The current ticket can't be modified`);
});
});
describe('as administrative', () => {
let editableTicketId = 16;
let editableTicketId = '16';
it('should navigate to the services of a target ticket', async() => {
const url = await nightmare
.loginAndModule('administrative', 'ticket')
.accessToSearchResult(editableTicketId)
.accessToSection('ticket.card.service')
.waitForURL('/service')
.parsedUrl();
await page.loginAndModule('administrative', 'ticket');
await page.accessToSearchResult(editableTicketId);
await page.accessToSection('ticket.card.service');
await page.waitForURL('/service');
const url = await page.parsedUrl();
expect(url.hash).toContain('/service');
});
it('should click on the add button to prepare the form to create a new service', async() => {
const result = await nightmare
.waitToClick(selectors.ticketService.addServiceButton)
await page.waitToClick(selectors.ticketService.addServiceButton);
const result = await page
.isVisible(selectors.ticketService.firstServiceTypeAutocomplete);
expect(result).toBeTruthy();
});
it('should receive an error if you attempt to save it with empty fields', async() => {
const result = await nightmare
.waitToClick(selectors.ticketService.saveServiceButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketService.saveServiceButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual(`can't be blank`);
});
it('should click on the add new service type to open the dialog', async() => {
const result = await nightmare
.waitToClick(selectors.ticketService.firstAddServiceTypeButton)
.wait('.vn-dialog.shown')
.isVisible(selectors.ticketService.newServiceTypeNameInput);
await page.waitToClick(selectors.ticketService.firstAddServiceTypeButton);
await page.wait('.vn-dialog.shown');
const result = await page.isVisible(selectors.ticketService.newServiceTypeNameInput);
expect(result).toBeTruthy();
});
it('should receive an error if service type is empty on submit', async() => {
const result = await nightmare
.waitToClick(selectors.ticketService.saveServiceTypeButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketService.saveServiceTypeButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual(`Name can't be empty`);
});
it('should create a new service type then add price then create the service', async() => {
const result = await nightmare
.write(selectors.ticketService.newServiceTypeNameInput, 'Documentos')
.autocompleteSearch(selectors.ticketService.newServiceTypeExpenseAutocomplete, 'Retencion')
.waitToClick(selectors.ticketService.saveServiceTypeButton)
.write(selectors.ticketService.firstPriceInput, 999)
.waitToClick(selectors.ticketService.saveServiceButton)
.waitForLastSnackbar();
await page.write(selectors.ticketService.newServiceTypeNameInput, 'Documentos');
await page.autocompleteSearch(selectors.ticketService.newServiceTypeExpenseAutocomplete, 'Retencion');
await page.waitToClick(selectors.ticketService.saveServiceTypeButton);
await page.write(selectors.ticketService.firstPriceInput, '999');
await page.waitToClick(selectors.ticketService.saveServiceButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the service description was created correctly', async() => {
const result = await nightmare
.reloadSection('ticket.card.service')
await page.reloadSection('ticket.card.service');
const result = await page
.waitToGetProperty(`${selectors.ticketService.firstServiceTypeAutocomplete} input`, 'value');
expect(result).toEqual('Documentos');
});
it('should confirm the service quantity was created correctly', async() => {
const result = await nightmare
.waitToGetProperty(selectors.ticketService.firstQuantityInput, 'value');
const result = await page
.waitToGetProperty(`${selectors.ticketService.firstQuantityInput} input`, 'value');
expect(result).toEqual('1');
});
it('should confirm the service price was created correctly', async() => {
const result = await nightmare
.waitToGetProperty(selectors.ticketService.firstPriceInput, 'value');
const result = await page
.waitToGetProperty(`${selectors.ticketService.firstPriceInput} input`, 'value');
expect(result).toEqual('999');
});
it('should confirm the service VAT was created correctly', async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(`${selectors.ticketService.firstVatTypeAutocomplete} input`, 'value');
expect(result).toEqual('General VAT');
});
it('should delete the service', async() => {
const result = await nightmare
.waitToClick(selectors.ticketService.fistDeleteServiceButton)
.waitForNumberOfElements(selectors.ticketService.serviceLine, 0)
.waitToClick(selectors.ticketService.saveServiceButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketService.fistDeleteServiceButton);
await page.waitForNumberOfElements(selectors.ticketService.serviceLine, 0);
await page.waitToClick(selectors.ticketService.saveServiceButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the service was removed`, async() => {
const result = await nightmare
.reloadSection('ticket.card.service')
.waitForNumberOfElements(selectors.ticketService.serviceLine, 0)
.countElement(selectors.ticketService.serviceLine);
await page.reloadSection('ticket.card.service');
await page.waitForNumberOfElements(selectors.ticketService.serviceLine, 0);
const result = await page.countElement(selectors.ticketService.serviceLine);
expect(result).toEqual(0);
});

View File

@ -1,40 +1,43 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket create path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('employee', 'ticket');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'ticket');
});
afterAll(async() => {
await browser.close();
});
it('should open the new ticket form', async() => {
const url = await nightmare
.waitToClick(selectors.ticketsIndex.newTicketButton)
.wait(selectors.createTicketView.clientAutocomplete)
.parsedUrl();
await page.waitToClick(selectors.ticketsIndex.newTicketButton);
await page.wait(selectors.createTicketView.clientAutocomplete);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/ticket/create');
});
it('should succeed to create a ticket', async() => {
const result = await nightmare
.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark')
.datePicker(selectors.createTicketView.deliveryDateInput, 1, null)
.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One')
.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'Silla247')
.waitToClick(selectors.createTicketView.createButton)
.waitForLastSnackbar();
await page.autocompleteSearch(selectors.createTicketView.clientAutocomplete, 'Tony Stark');
await page.autocompleteSearch(selectors.createTicketView.addressAutocomplete, 'Tony Stark');
await page.datePicker(selectors.createTicketView.deliveryDateInput, 1, null);
await page.autocompleteSearch(selectors.createTicketView.warehouseAutocomplete, 'Warehouse One');
await page.autocompleteSearch(selectors.createTicketView.agencyAutocomplete, 'Silla247');
await page.waitToClick(selectors.createTicketView.createButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should check the url is now the summary of the ticket', async() => {
const url = await nightmare
.waitForURL('/summary')
.parsedUrl();
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});

View File

@ -1,30 +1,35 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket create from client path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('employee', 'client')
.accessToSearchResult('Petter Parker');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('Petter Parker');
});
afterAll(async() => {
await browser.close();
});
it('should click the create simple ticket on the descriptor menu', async() => {
const url = await nightmare
.waitToClick(selectors.clientDescriptor.moreMenu)
.waitToClick(selectors.clientDescriptor.simpleTicketButton)
.waitForURL('#!/ticket/create?clientFk=102')
.parsedUrl();
await page.waitToClick(selectors.clientDescriptor.moreMenu);
await page.waitToClick(selectors.clientDescriptor.simpleTicketButton);
await page.waitForURL('#!/ticket/create?clientFk=102');
const url = await page.parsedUrl();
expect(url.hash).toContain('clientFk=102');
});
it('should check if the client details are the expected ones', async() => {
const client = await nightmare
const client = await page
.waitToGetProperty(`${selectors.createTicketView.clientAutocomplete} input`, 'value');
const address = await nightmare
const address = await page
.waitToGetProperty(`${selectors.createTicketView.addressAutocomplete} input`, 'value');

View File

@ -1,24 +1,32 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Ticket Summary path', () => {
const nightmare = createNightmare();
const ticketId = 20;
let browser;
let page;
const ticketId = '20';
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
});
afterAll(async() => {
await browser.close();
});
it('should navigate to the target ticket summary section', async() => {
let url = await nightmare
.loginAndModule('employee', 'ticket')
.accessToSearchResult(ticketId)
.waitForURL('/summary')
.parsedUrl();
await page.loginAndModule('employee', 'ticket');
await page.accessToSearchResult(ticketId);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should display details from the ticket and it's client on the top of the header`, async() => {
let result = await nightmare
.waitForTextInElement(selectors.ticketSummary.header, 'Bruce Banner')
.waitToGetProperty(selectors.ticketSummary.header, 'innerText');
await page.waitForTextInElement(selectors.ticketSummary.header, 'Bruce Banner');
const result = await page.waitToGetProperty(selectors.ticketSummary.header, 'innerText');
expect(result).toContain(`Ticket #${ticketId}`);
expect(result).toContain('Bruce Banner (109)');
@ -26,71 +34,64 @@ describe('Ticket Summary path', () => {
});
it('should display ticket details', async() => {
let result = await nightmare
let result = await page
.waitToGetProperty(selectors.ticketSummary.state, 'innerText');
expect(result).toContain('Arreglar');
});
it('should display delivery details', async() => {
let result = await nightmare
let result = await page
.waitToGetProperty(selectors.ticketSummary.route, 'innerText');
expect(result).toContain('3');
});
it('should display the ticket total', async() => {
let result = await nightmare
let result = await page
.waitToGetProperty(selectors.ticketSummary.total, 'innerText');
expect(result).toContain('€155.54');
});
it('should display the ticket line(s)', async() => {
let result = await nightmare
let result = await page
.waitToGetProperty(selectors.ticketSummary.firstSaleItemId, 'innerText');
expect(result).toContain('000002');
});
it(`should click on the first sale ID making the item descriptor visible`, async() => {
const visible = await nightmare
.waitToClick(selectors.ticketSummary.firstSaleItemId)
.waitImgLoad(selectors.ticketSummary.firstSaleDescriptorImage)
.isVisible(selectors.ticketSummary.itemDescriptorPopover);
await page.waitToClick(selectors.ticketSummary.firstSaleItemId);
await page.waitImgLoad(selectors.ticketSummary.firstSaleDescriptorImage);
const visible = await page.isVisible(selectors.ticketSummary.itemDescriptorPopover);
expect(visible).toBeTruthy();
});
it(`should check the url for the item diary link of the descriptor is for the right item id`, async() => {
const exists = await nightmare
.exists(selectors.ticketSummary.itemDescriptorPopoverItemDiaryButton);
expect(exists).toBeTruthy();
await page.waitForSelector(selectors.ticketSummary.itemDescriptorPopoverItemDiaryButton, {visible: true});
});
it('should log in as production then navigate to the summary of the same ticket', async() => {
let url = await nightmare
.loginAndModule('production', 'ticket')
.accessToSearchResult(ticketId)
.waitForURL('/summary')
.parsedUrl();
await page.loginAndModule('production', 'ticket');
await page.accessToSearchResult(ticketId);
await page.waitForURL('/summary');
let url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it('should click on the SET OK button', async() => {
let result = await nightmare
.waitToClick(selectors.ticketSummary.setOk)
.waitForLastSnackbar();
await page.waitToClick(selectors.ticketSummary.setOk);
let result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the ticket state was updated', async() => {
let result = await nightmare
.waitForSpinnerLoad()
.waitToGetProperty(selectors.ticketSummary.state, 'innerText');
await page.waitForSpinnerLoad();
let result = await page.waitToGetProperty(selectors.ticketSummary.state, 'innerText');
expect(result).toContain('OK');
});

View File

@ -1,58 +1,60 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Claim edit basic data path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('salesAssistant', 'claim')
.accessToSearchResult('1')
.accessToSection('claim.card.basicData');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('salesAssistant', 'claim');
await page.accessToSearchResult('1');
await page.accessToSection('claim.card.basicData');
});
afterAll(async() => {
await browser.close();
});
it(`should edit claim state and observation fields`, async() => {
const result = await nightmare
.autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Gestionado')
.clearTextarea(selectors.claimBasicData.observationInput)
.write(selectors.claimBasicData.observationInput, 'edited observation')
.waitToClick(selectors.claimBasicData.saveButton)
.waitForLastSnackbar();
await page.autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Gestionado');
await page.clearTextarea(selectors.claimBasicData.observationInput);
await page.write(selectors.claimBasicData.observationInput, 'edited observation');
await page.waitToClick(selectors.claimBasicData.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
it(`should have been redirected to the next section of claims as the role is salesAssistant`, async() => {
const url = await nightmare
.waitForURL('/detail')
.parsedUrl();
await page.waitForURL('/detail');
const url = await page.parsedUrl();
expect(url.hash).toContain('/detail');
});
it('should confirm the claim state was edited', async() => {
const result = await nightmare
.reloadSection('claim.card.basicData')
.wait(selectors.claimBasicData.claimStateAutocomplete)
.waitToGetProperty(`${selectors.claimBasicData.claimStateAutocomplete} input`, 'value');
await page.reloadSection('claim.card.basicData');
await page.wait(selectors.claimBasicData.claimStateAutocomplete);
const result = await page.waitToGetProperty(`${selectors.claimBasicData.claimStateAutocomplete} input`, 'value');
expect(result).toEqual('Gestionado');
});
it('should confirm the claim observation was edited', async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.claimBasicData.observationInput, 'value');
expect(result).toEqual('edited observation');
});
it(`should edit the claim to leave it untainted`, async() => {
const result = await nightmare
.autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Pendiente')
.clearTextarea(selectors.claimBasicData.observationInput)
.write(selectors.claimBasicData.observationInput, 'Observation one')
.waitToClick(selectors.claimBasicData.saveButton)
.waitForLastSnackbar();
await page.autocompleteSearch(selectors.claimBasicData.claimStateAutocomplete, 'Pendiente');
await page.clearTextarea(selectors.claimBasicData.observationInput);
await page.write(selectors.claimBasicData.observationInput, 'Observation one');
await page.waitToClick(selectors.claimBasicData.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});

View File

@ -1,68 +1,71 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Claim development', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('salesAssistant', 'claim')
.accessToSearchResult('1')
.accessToSection('claim.card.development');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('salesAssistant', 'claim');
await page.accessToSearchResult('1');
await page.accessToSection('claim.card.development');
});
afterAll(async() => {
await browser.close();
});
it('should delete a development and create a new one', async() => {
const result = await nightmare
.waitToClick(selectors.claimDevelopment.firstDeleteDevelopmentButton)
.waitToClick(selectors.claimDevelopment.addDevelopmentButton)
.autocompleteSearch(selectors.claimDevelopment.secondClaimReasonAutocomplete, 'Baja calidad')
.autocompleteSearch(selectors.claimDevelopment.secondClaimResultAutocomplete, 'Deshidratacion')
.autocompleteSearch(selectors.claimDevelopment.secondClaimResponsibleAutocomplete, 'Calidad general')
.autocompleteSearch(selectors.claimDevelopment.secondClaimWorkerAutocomplete, 'deliveryNick')
.autocompleteSearch(selectors.claimDevelopment.secondClaimRedeliveryAutocomplete, 'Reparto')
.waitToClick(selectors.claimDevelopment.saveDevelopmentButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimDevelopment.firstDeleteDevelopmentButton);
await page.waitToClick(selectors.claimDevelopment.addDevelopmentButton);
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimReasonAutocomplete, 'Baja calidad');
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimResultAutocomplete, 'Deshidratacion');
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimResponsibleAutocomplete, 'Calidad general');
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimWorkerAutocomplete, 'deliveryNick');
await page.autocompleteSearch(selectors.claimDevelopment.secondClaimRedeliveryAutocomplete, 'Reparto');
await page.waitToClick(selectors.claimDevelopment.saveDevelopmentButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
}, 15000);
it(`should redirect to the next section of claims as the role is salesAssistant`, async() => {
const url = await nightmare
.waitForURL('/action')
.parsedUrl();
await page.waitForURL('/action');
const url = await page.parsedUrl();
expect(url.hash).toContain('/action');
});
it('should edit a development', async() => {
const result = await nightmare
.reloadSection('claim.card.development')
.autocompleteSearch(selectors.claimDevelopment.firstClaimReasonAutocomplete, 'Calor')
.autocompleteSearch(selectors.claimDevelopment.firstClaimResultAutocomplete, 'Cocido')
.autocompleteSearch(selectors.claimDevelopment.firstClaimResponsibleAutocomplete, 'Calidad general')
.autocompleteSearch(selectors.claimDevelopment.firstClaimWorkerAutocomplete, 'adminAssistantNick')
.autocompleteSearch(selectors.claimDevelopment.firstClaimRedeliveryAutocomplete, 'Cliente')
.waitToClick(selectors.claimDevelopment.saveDevelopmentButton)
.waitForLastSnackbar();
await page.reloadSection('claim.card.development');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimReasonAutocomplete, 'Calor');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimResultAutocomplete, 'Cocido');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimResponsibleAutocomplete, 'Calidad general');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimWorkerAutocomplete, 'adminAssistantNick');
await page.autocompleteSearch(selectors.claimDevelopment.firstClaimRedeliveryAutocomplete, 'Cliente');
await page.waitToClick(selectors.claimDevelopment.saveDevelopmentButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the first development is the expected one', async() => {
const reason = await nightmare
.reloadSection('claim.card.development')
await page.reloadSection('claim.card.development');
const reason = await page
.waitToGetProperty(`${selectors.claimDevelopment.firstClaimReasonAutocomplete} input`, 'value');
const result = await nightmare
const result = await page
.waitToGetProperty(`${selectors.claimDevelopment.firstClaimResultAutocomplete} input`, 'value');
const responsible = await nightmare
const responsible = await page
.waitToGetProperty(`${selectors.claimDevelopment.firstClaimResponsibleAutocomplete} input`, 'value');
const worker = await nightmare
const worker = await page
.waitToGetProperty(`${selectors.claimDevelopment.firstClaimWorkerAutocomplete} input`, 'value');
const redelivery = await nightmare
const redelivery = await page
.waitToGetProperty(`${selectors.claimDevelopment.firstClaimRedeliveryAutocomplete} input`, 'value');
expect(reason).toEqual('Calor');
@ -73,19 +76,19 @@ describe('Claim development', () => {
});
it('should confirm the second development is the expected one', async() => {
const reason = await nightmare
const reason = await page
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimReasonAutocomplete} input`, 'value');
const result = await nightmare
const result = await page
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimResultAutocomplete} input`, 'value');
const responsible = await nightmare
const responsible = await page
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimResponsibleAutocomplete} input`, 'value');
const worker = await nightmare
const worker = await page
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimWorkerAutocomplete} input`, 'value');
const redelivery = await nightmare
const redelivery = await page
.waitToGetProperty(`${selectors.claimDevelopment.secondClaimRedeliveryAutocomplete} input`, 'value');
expect(reason).toEqual('Baja calidad');

View File

@ -1,48 +1,51 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
// #1528 e2e claim/detail
xdescribe('Claim detail', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('salesPerson', 'claim')
.accessToSearchResult(1)
.accessToSection('claim.card.detail');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('salesPerson', 'claim');
await page.accessToSearchResult('1');
await page.accessToSection('claim.card.detail');
});
afterAll(async() => {
await browser.close();
});
it('should add the first claimable item from ticket to the claim', async() => {
const result = await nightmare
.waitToClick(selectors.claimDetail.addItemButton)
.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimDetail.addItemButton);
await page.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the claim contains now two items', async() => {
const result = await nightmare
.countElement(selectors.claimDetail.claimDetailLine);
const result = await page.countElement(selectors.claimDetail.claimDetailLine);
expect(result).toEqual(2);
});
it('should edit de first item claimed quantity', async() => {
const result = await nightmare
.clearInput(selectors.claimDetail.firstItemQuantityInput) // selector deleted, find new upon fixes
.write(selectors.claimDetail.firstItemQuantityInput, 4) // selector deleted, find new upon fixes
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
await page.clearInput(selectors.claimDetail.firstItemQuantityInput); // selector deleted, find new upon fixes
await page.write(selectors.claimDetail.firstItemQuantityInput, '4'); // selector deleted, find new upon fixes
await page.keyboard.press('Enter');
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the first item quantity, and the claimed total were correctly edited', async() => {
const claimedQuantity = await nightmare
const claimedQuantity = page
.waitToGetProperty(selectors.claimDetail.firstItemQuantityInput, 'value'); // selector deleted, find new upon fixes
const totalClaimed = await nightmare
const totalClaimed = page
.waitToGetProperty(selectors.claimDetail.totalClaimed, 'innerText');
expect(claimedQuantity).toEqual('4');
@ -50,71 +53,63 @@ xdescribe('Claim detail', () => {
});
it('should login as salesAssistant and navigate to the claim.detail section', async() => {
const url = await nightmare
.loginAndModule('salesAssistant', 'claim')
.accessToSearchResult(1)
.accessToSection('claim.card.detail')
.waitForURL('/detail')
.parsedUrl();
await page.loginAndModule('salesAssistant', 'claim');
await page.accessToSearchResult('1');
await page.accessToSection('claim.card.detail');
await page.waitForURL('/detail');
const url = await page.parsedUrl();
expect(url.hash).toContain('/detail');
});
it('should edit de second item claimed discount', async() => {
const result = await nightmare
.waitToClick(selectors.claimDetail.secondItemDiscount)
.write(selectors.claimDetail.discountInput, 100)
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
await page.waitToClick(selectors.claimDetail.secondItemDiscount);
await page.write(selectors.claimDetail.discountInput, '100');
await page.keyboard.press('Enter');
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should check the mana is the expected one', async() => {
const result = await nightmare
.waitToClick(selectors.claimDetail.secondItemDiscount)
.waitToGetProperty(selectors.claimDetail.discoutPopoverMana, 'innerText');
await page.waitToClick(selectors.claimDetail.secondItemDiscount);
const result = await page.waitToGetProperty(selectors.claimDetail.discoutPopoverMana, 'innerText');
expect(result).toContain('MANÁ: €106');
});
it('should delete the second item from the claim', async() => {
const result = await nightmare
.waitToClick(selectors.claimDetail.secondItemDeleteButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimDetail.secondItemDeleteButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the claim contains now one item', async() => {
const result = await nightmare
.countElement(selectors.claimDetail.claimDetailLine);
const result = await page.countElement(selectors.claimDetail.claimDetailLine);
expect(result).toEqual(1);
});
it('should add the deleted ticket from to the claim', async() => {
const result = await nightmare
.waitToClick(selectors.claimDetail.addItemButton)
.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimDetail.addItemButton);
await page.waitToClick(selectors.claimDetail.firstClaimableSaleFromTicket);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should have been redirected to the next section in claims`, async() => {
const url = await nightmare
.waitForURL('/development')
.parsedUrl();
await page.waitForURL('/development');
const url = await page.parsedUrl();
expect(url.hash).toContain('development');
});
it('should navigate back to claim.detail to confirm the claim contains now two items', async() => {
const result = await nightmare
.accessToSection('claim.card.detail')
.wait(selectors.claimDetail.claimDetailLine)
.countElement(selectors.claimDetail.claimDetailLine);
await page.accessToSection('claim.card.detail');
await page.wait(selectors.claimDetail.claimDetailLine);
const result = await page.countElement(selectors.claimDetail.claimDetailLine);
expect(result).toEqual(2);
});

View File

@ -1,77 +1,75 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Claim action path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('administrative', 'claim')
.accessToSearchResult(2)
.accessToSection('claim.card.action');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'claim');
await page.accessToSearchResult('2');
await page.accessToSection('claim.card.action');
});
afterAll(async() => {
await browser.close();
});
it('should import the claim', async() => {
const result = await nightmare
.waitToClick(selectors.claimAction.importClaimButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimAction.importClaimButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should import the second importable ticket', async() => {
const result = await nightmare
.waitToClick(selectors.claimAction.importTicketButton)
.waitToClick(selectors.claimAction.secondImportableTicket)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimAction.importTicketButton);
await page.waitToClick(selectors.claimAction.secondImportableTicket);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should edit the second line destination field', async() => {
const result = await nightmare
.autocompleteSearch(selectors.claimAction.secondLineDestination, 'Bueno')
.waitForLastSnackbar();
await page.autocompleteSearch(selectors.claimAction.secondLineDestination, 'Bueno');
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should delete the first line', async() => {
const result = await nightmare
.waitToClick(selectors.claimAction.firstDeleteLine)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimAction.firstDeleteLine);
await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should refresh the view to check the remaining line is the expected one', async() => {
const result = await nightmare
.reloadSection('claim.card.action')
.waitToGetProperty(`${selectors.claimAction.firstLineDestination} input`, 'value');
await page.reloadSection('claim.card.action');
const result = await page.waitToGetProperty(`${selectors.claimAction.firstLineDestination} input`, 'value');
expect(result).toEqual('Bueno');
});
it('should delete the current first line', async() => {
const result = await nightmare
.waitToClick(selectors.claimAction.firstDeleteLine)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimAction.firstDeleteLine);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should check the "is paid with mana" checkbox', async() => {
const result = await nightmare
.waitToClick(selectors.claimAction.isPaidWithManaCheckbox)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimAction.isPaidWithManaCheckbox);
const result = await page.waitForLastSnackbar();
expect(result).toEqual(jasmine.arrayContaining(['Data saved!']));
});
it('should confirm the "is paid with mana" checkbox is checked', async() => {
const result = await nightmare
.reloadSection('claim.card.action')
.checkboxState(selectors.claimAction.isPaidWithManaCheckbox);
await page.reloadSection('claim.card.action');
const result = await page.checkboxState(selectors.claimAction.isPaidWithManaCheckbox);
expect(result).toBe('checked');
});

View File

@ -1,96 +1,95 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('claim Summary path', () => {
const nightmare = createNightmare();
let browser;
let page;
const claimId = 4;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
});
afterAll(async() => {
await browser.close();
});
it('should navigate to the target claim summary section', async() => {
let url = await nightmare
.loginAndModule('employee', 'claim')
.accessToSearchResult(claimId)
.waitForURL('/summary')
.parsedUrl();
await page.loginAndModule('employee', 'claim');
await page.accessToSearchResult(claimId);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should display details from the claim and it's client on the top of the header`, async() => {
let result = await nightmare
.waitForTextInElement(selectors.claimSummary.header, 'Tony Stark')
.waitToGetProperty(selectors.claimSummary.header, 'innerText');
await page.waitForTextInElement(selectors.claimSummary.header, 'Tony Stark');
const result = await page.waitToGetProperty(selectors.claimSummary.header, 'innerText');
expect(result).toContain('4 -');
expect(result).toContain('Tony Stark');
});
it('should display the claim state', async() => {
let result = await nightmare
.waitToGetProperty(selectors.claimSummary.state, 'innerText');
const result = await page.waitToGetProperty(selectors.claimSummary.state, 'innerText');
expect(result).toContain('Resuelto');
});
it('should display the observation', async() => {
let result = await nightmare
.waitToGetProperty(selectors.claimSummary.observation, 'value');
const result = await page.waitToGetProperty(selectors.claimSummary.observation, 'value');
expect(result).toContain('observation four');
});
it('should display the claimed line(s)', async() => {
let result = await nightmare
.waitToGetProperty(selectors.claimSummary.firstSaleItemId, 'innerText');
const result = await page.waitToGetProperty(selectors.claimSummary.firstSaleItemId, 'innerText');
expect(result).toContain('000002');
});
it(`should click on the first sale ID making the item descriptor visible`, async() => {
const visible = await nightmare
.waitToClick(selectors.claimSummary.firstSaleItemId)
.waitImgLoad(selectors.claimSummary.firstSaleDescriptorImage)
.isVisible(selectors.claimSummary.itemDescriptorPopover);
await page.waitToClick(selectors.claimSummary.firstSaleItemId);
await page.waitImgLoad(selectors.claimSummary.firstSaleDescriptorImage);
const visible = await page.isVisible(selectors.claimSummary.itemDescriptorPopover);
expect(visible).toBeTruthy();
});
it(`should check the url for the item diary link of the descriptor is for the right item id`, async() => {
const exists = await nightmare
.exists(selectors.claimSummary.itemDescriptorPopoverItemDiaryButton);
const exists = await page.exists(selectors.claimSummary.itemDescriptorPopoverItemDiaryButton);
expect(exists).toBeTruthy();
await nightmare.mousedown('.vn-popover.shown');
});
it('should display the claim development details', async() => {
let result = await nightmare
.waitToGetProperty(selectors.claimSummary.firstDevelopmentWorker, 'innerText');
const result = await page.waitToGetProperty(selectors.claimSummary.firstDevelopmentWorker, 'innerText');
expect(result).toContain('salesAssistantNick');
});
it(`should click on the first development worker making the worker descriptor visible`, async() => {
const visible = await nightmare
.waitToClick(selectors.claimSummary.firstDevelopmentWorker)
.wait(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton)
.isVisible(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton);
await page.waitToClick(selectors.claimSummary.firstDevelopmentWorker);
await page.wait(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton);
const visible = await page.isVisible(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton);
expect(visible).toBeTruthy();
});
it(`should check the url for the go to clientlink of the descriptor is for the right client id`, async() => {
const exists = await nightmare
.exists(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton);
const exists = await page.exists(selectors.claimSummary.firstDevelopmentWorkerGoToClientButton);
expect(exists).toBeTruthy();
await nightmare.mousedown('.vn-popover.shown');
});
it(`should click on the first action ticket ID making the ticket descriptor visible`, async() => {
const visible = await nightmare
.waitToClick(selectors.claimSummary.firstActionTicketId)
.wait(selectors.claimSummary.firstActionTicketDescriptor)
.isVisible(selectors.claimSummary.firstActionTicketDescriptor);
await page.waitToClick(selectors.claimSummary.firstActionTicketId);
await page.wait(selectors.claimSummary.firstActionTicketDescriptor);
const visible = await page.isVisible(selectors.claimSummary.firstActionTicketDescriptor);
expect(visible).toBeTruthy();
});

View File

@ -1,70 +1,73 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('claim Descriptor path', () => {
const nightmare = createNightmare();
const claimId = 1;
let browser;
let page;
const claimId = '1';
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
});
afterAll(async() => {
await browser.close();
});
it('should navigate to the target claim summary section', async() => {
let url = await nightmare
.loginAndModule('employee', 'claim')
.accessToSearchResult(claimId)
.waitForURL('/summary')
.parsedUrl();
await page.loginAndModule('employee', 'claim');
await page.accessToSearchResult(claimId);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should not be able to see the delete claim button of the descriptor more menu`, async() => {
let exists = await nightmare
.waitToClick(selectors.claimDescriptor.moreMenu)
.exists(selectors.claimDescriptor.moreMenuDeleteClaim);
await page.waitToClick(selectors.claimDescriptor.moreMenu);
const exists = await page.exists(selectors.claimDescriptor.moreMenuDeleteClaim);
expect(exists).toBeFalsy();
});
it(`should log in as salesAssistant and navigate to the target claim`, async() => {
let url = await nightmare
.loginAndModule('salesAssistant', 'claim')
.accessToSearchResult(claimId)
.waitForURL('/summary')
.parsedUrl();
await page.loginAndModule('salesAssistant', 'claim');
await page.accessToSearchResult(claimId);
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should be able to see the delete claim button of the descriptor more menu`, async() => {
let exists = await nightmare
.waitToClick(selectors.claimDescriptor.moreMenu)
.wait(selectors.claimDescriptor.moreMenuDeleteClaim)
.exists(selectors.claimDescriptor.moreMenuDeleteClaim);
await page.waitToClick(selectors.claimDescriptor.moreMenu);
await page.wait(selectors.claimDescriptor.moreMenuDeleteClaim);
const exists = await page.exists(selectors.claimDescriptor.moreMenuDeleteClaim);
expect(exists).toBeTruthy();
});
it(`should delete the claim`, async() => {
let result = await nightmare
.waitToClick(selectors.claimDescriptor.moreMenuDeleteClaim)
.waitToClick(selectors.claimDescriptor.acceptDeleteClaim)
.waitForLastSnackbar();
await page.waitToClick(selectors.claimDescriptor.moreMenuDeleteClaim);
await page.waitToClick(selectors.claimDescriptor.acceptDeleteClaim);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Claim deleted!');
});
it(`should have been relocated to the claim index`, async() => {
let url = await nightmare
.waitForURL('/claim/index')
.parsedUrl();
await page.waitForURL('/claim/index');
const url = await page.parsedUrl();
expect(url.hash).toContain('/claim/index');
});
it(`should search for the deleted claim to find no results`, async() => {
const result = await nightmare
.write(selectors.claimsIndex.searchClaimInput, claimId)
.waitToClick(selectors.claimsIndex.searchButton)
.waitForNumberOfElements(selectors.claimsIndex.searchResult, 0)
.countElement(selectors.claimsIndex.searchResult);
await page.write(selectors.claimsIndex.searchClaimInput, claimId);
await page.waitToClick(selectors.claimsIndex.searchButton);
await page.waitForNumberOfElements(selectors.claimsIndex.searchResult, 0);
const result = await page.countElement(selectors.claimsIndex.searchResult);
expect(result).toEqual(0);
});

View File

@ -1,24 +1,30 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Order edit basic data path', () => {
const nightmare = createNightmare();
let browser;
let page;
const today = new Date().getDate();
describe('when confirmed order', () => {
beforeAll(() => {
nightmare
.loginAndModule('employee', 'order')
.accessToSearchResult(1)
.accessToSection('order.card.basicData');
});
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'order');
await page.accessToSearchResult('1');
await page.accessToSection('order.card.basicData');
});
afterAll(async() => {
await browser.close();
});
describe('when confirmed order', () => {
it('should not be able to change the client', async() => {
const result = await nightmare
.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark')
.waitToClick(selectors.orderBasicData.saveButton)
.waitForLastSnackbar();
await page.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark');
await page.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark');
await page.waitToClick(selectors.orderBasicData.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual(`You can't make changes on the basic data of an confirmed order or with rows`);
}, 15000);
@ -27,23 +33,22 @@ describe('Order edit basic data path', () => {
describe('when order with rows', () => {
it('should now navigate to order index', async() => {
const orderId = 16;
const url = await nightmare
.waitToClick(selectors.orderDescriptor.returnToModuleIndexButton)
.waitToClick(selectors.orderDescriptor.acceptNavigationButton)
.wait(selectors.ordersIndex.createOrderButton)
.accessToSearchResult(orderId)
.accessToSection('order.card.basicData')
.wait(selectors.orderBasicData.observationInput)
.parsedUrl();
await page.waitToClick(selectors.orderDescriptor.returnToModuleIndexButton);
await page.waitToClick(selectors.orderDescriptor.acceptNavigationButton);
await page.wait(selectors.ordersIndex.createOrderButton);
await page.accessToSearchResult(orderId);
await page.accessToSection('order.card.basicData');
await page.wait(selectors.orderBasicData.observationInput);
const url = await page.parsedUrl();
expect(url.hash).toEqual(`#!/order/${orderId}/basic-data`);
});
it('should not be able to change anything', async() => {
const result = await nightmare
.write(selectors.orderBasicData.observationInput, 'observation')
.waitToClick(selectors.orderBasicData.saveButton)
.waitForLastSnackbar();
await page.write(selectors.orderBasicData.observationInput, 'observation');
await page.waitToClick(selectors.orderBasicData.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual(`You can't make changes on the basic data of an confirmed order or with rows`);
});
@ -51,66 +56,62 @@ describe('Order edit basic data path', () => {
describe('when new order', () => {
it('should navigate to the order index and click the new order button', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.returnToModuleIndexButton)
.waitToClick(selectors.orderBasicData.acceptButton)
.waitToClick(selectors.ordersIndex.createOrderButton)
.waitForURL('#!/order/create')
.parsedUrl();
await page.waitToClick(selectors.globalItems.returnToModuleIndexButton);
await page.waitToClick(selectors.orderBasicData.acceptButton);
await page.waitToClick(selectors.ordersIndex.createOrderButton);
await page.waitForURL('#!/order/create');
const url = await page.parsedUrl();
expect(url.hash).toContain('#!/order/create');
});
it('should now create a new one', async() => {
const url = await nightmare
.autocompleteSearch(selectors.createOrderView.clientAutocomplete, 'Jessica Jones')
.datePicker(selectors.createOrderView.landedDatePicker, 0, today)
.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'inhouse pickup')
.waitToClick(selectors.createOrderView.createButton)
.waitForURL('/catalog')
.parsedUrl();
await page.autocompleteSearch(selectors.createOrderView.clientAutocomplete, 'Jessica Jones');
await page.datePicker(selectors.createOrderView.landedDatePicker, 0, today);
await page.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'inhouse pickup');
await page.waitToClick(selectors.createOrderView.createButton);
await page.waitForURL('/catalog');
const url = await page.parsedUrl();
expect(url.hash).toContain('/catalog');
});
it('should navigate to the basic data section of the new order', async() => {
const url = await nightmare
.accessToSection('order.card.basicData')
.wait(selectors.orderBasicData.observationInput)
.parsedUrl();
await page.accessToSection('order.card.basicData');
await page.wait(selectors.orderBasicData.observationInput);
const url = await page.parsedUrl();
expect(url.hash).toContain('/basic-data');
});
it('should be able to modify all the properties', async() => {
const result = await nightmare
.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark')
.autocompleteSearch(selectors.orderBasicData.agencyAutocomplete, 'Silla247')
.write(selectors.orderBasicData.observationInput, 'my observation')
.waitToClick(selectors.orderBasicData.saveButton)
.waitForLastSnackbar();
await page.autocompleteSearch(selectors.orderBasicData.clientAutocomplete, 'Tony Stark');
await page.autocompleteSearch(selectors.orderBasicData.addressAutocomplete, 'Tony Stark');
await page.autocompleteSearch(selectors.orderBasicData.agencyAutocomplete, 'Silla247');
await page.write(selectors.orderBasicData.observationInput, 'my observation');
await page.waitToClick(selectors.orderBasicData.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should now confirm the client have been edited', async() => {
const result = await nightmare
.reloadSection('order.card.basicData')
await page.reloadSection('order.card.basicData');
const result = await page
.waitToGetProperty(`${selectors.orderBasicData.clientAutocomplete} input`, 'value');
expect(result).toEqual('104: Tony Stark');
});
it('should now confirm the agency have been edited', async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(`${selectors.orderBasicData.agencyAutocomplete} input`, 'value');
expect(result).toEqual('7: Silla247');
});
it('should now confirm the observations have been edited', async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.orderBasicData.observationInput, 'value');
expect(result).toEqual('my observation');

View File

@ -1,82 +1,85 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Order catalog', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('employee', 'order');
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'order');
});
afterAll(async() => {
await browser.close();
});
it('should open the create new order form', async() => {
const url = await nightmare
.waitToClick(selectors.ordersIndex.createOrderButton)
.waitForURL('order/create')
.parsedUrl();
await page.waitToClick(selectors.ordersIndex.createOrderButton);
await page.waitForURL('order/create');
const url = await page.parsedUrl();
expect(url.hash).toContain('order/create');
});
it('should create a new order', async() => {
let today = new Date().getDate();
const url = await nightmare
.autocompleteSearch(selectors.createOrderView.clientAutocomplete, 'Tony Stark')
.datePicker(selectors.createOrderView.landedDatePicker, 0, today)
.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'inhouse pickup')
.waitToClick(selectors.createOrderView.createButton)
.waitForURL('/catalog')
.parsedUrl();
await page.autocompleteSearch(selectors.createOrderView.clientAutocomplete, 'Tony Stark');
await page.datePicker(selectors.createOrderView.landedDatePicker, 0, today);
await page.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'inhouse pickup');
await page.waitToClick(selectors.createOrderView.createButton);
await page.waitForURL('/catalog');
const url = await page.parsedUrl();
expect(url.hash).toContain('/catalog');
});
it('should add the realm and type filters and obtain results', async() => {
const result = await nightmare
.waitToClick(selectors.orderCatalog.plantRealmButton)
.autocompleteSearch(selectors.orderCatalog.typeAutocomplete, 'Anthurium')
.waitForNumberOfElements('section.product', 4)
.countElement('section.product');
await page.waitToClick(selectors.orderCatalog.plantRealmButton);
await page.autocompleteSearch(selectors.orderCatalog.typeAutocomplete, 'Anthurium');
await page.waitForNumberOfElements('section.product', 4);
const result = await page.countElement('section.product');
expect(result).toEqual(4);
});
it('should search for the item tag value +1 and find two results', async() => {
const result = await nightmare
.write(selectors.orderCatalog.itemTagValueInput, '+1\u000d')
.waitForNumberOfElements('section.product', 2)
.countElement('section.product');
await page.write(selectors.orderCatalog.itemTagValueInput, '+1');
await page.keyboard.press('Enter');
await page.waitForNumberOfElements('section.product', 2);
const result = await page.countElement('section.product');
expect(result).toEqual(2);
});
it('should search for the item tag categoria +1 and find two results', async() => {
const result = await nightmare
.waitToClick(selectors.orderCatalog.openTagSearch)
.autocompleteSearch(selectors.orderCatalog.tagAutocomplete, 'categoria')
.write(selectors.orderCatalog.tagValueInput, '+1')
.waitToClick(selectors.orderCatalog.searchTagButton)
.waitForNumberOfElements('section.product', 1)
.countElement('section.product');
await page.waitToClick(selectors.orderCatalog.openTagSearch);
await page.autocompleteSearch(selectors.orderCatalog.tagAutocomplete, 'categoria');
await page.write(selectors.orderCatalog.tagValueInput, '+1');
await page.waitToClick(selectors.orderCatalog.searchTagButton);
await page.waitForNumberOfElements('section.product', 1);
const result = await page.countElement('section.product');
expect(result).toEqual(1);
});
it('should remove the tag filters and have 4 results', async() => {
const result = await nightmare
.waitToClick(selectors.orderCatalog.fourthFilterRemoveButton)
.waitToClick(selectors.orderCatalog.thirdFilterRemoveButton)
.waitForNumberOfElements('.product', 4)
.countElement('section.product');
await page.waitToClick(selectors.orderCatalog.fourthFilterRemoveButton);
await page.waitToClick(selectors.orderCatalog.thirdFilterRemoveButton);
await page.waitForNumberOfElements('.product', 4);
const result = await page.countElement('section.product');
expect(result).toEqual(4);
});
it('should search for the item id 1 and have only 1 result', async() => {
const result = await nightmare
.write(selectors.orderCatalog.itemIdInput, '2\u000d')
.waitForNumberOfElements('section.product', 1)
.countElement('section.product');
it('should search for an item by id', async() => {
await page.write(selectors.orderCatalog.itemIdInput, '2');
await page.keyboard.press('Enter');
await page.waitForNumberOfElements('section.product', 1);
const result = await page.countElement('section.product');
expect(result).toEqual(1);
});

View File

@ -1,43 +1,47 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Order lines', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('employee', 'order')
.accessToSearchResult(16)
.accessToSection('order.card.line');
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'order');
await page.accessToSearchResult('16');
await page.accessToSection('order.card.line');
});
afterAll(async() => {
await browser.close();
});
it('should check the order subtotal', async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.orderLine.orderSubtotal, 'innerText');
expect(result).toContain('135.60');
});
it('should delete the first line in the order', async() => {
const result = await nightmare
.waitToClick(selectors.orderLine.firstLineDeleteButton)
.waitToClick(selectors.orderLine.confirmButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.orderLine.firstLineDeleteButton);
await page.waitToClick(selectors.orderLine.confirmButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the order subtotal has changed', async() => {
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.orderLine.orderSubtotal, 'innerText');
expect(result).toContain('90.10');
});
it('should confirm the whole order and redirect to ticket index filtered by clientFk', async() => {
const url = await nightmare
.waitToClick(selectors.orderLine.confirmOrder)
.waitForURL('ticket/index')
.parsedUrl();
await page.waitToClick(selectors.orderLine.confirmOrder);
await page.waitForURL('ticket/index');
const url = await page.parsedUrl();
expect(url.hash).toContain('ticket/index');
expect(url.hash).toContain('clientFk');

View File

@ -1,67 +1,68 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Route create path', () => {
const nightmare = createNightmare();
describe('as employee', () => {
beforeAll(() => {
nightmare
.loginAndModule('employee', 'route');
});
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'route');
});
afterAll(async() => {
await browser.close();
});
describe('as employee', () => {
it('should click on the add new route button and open the creation form', async() => {
const url = await nightmare
.waitToClick(selectors.routeIndex.addNewRouteButton)
.wait(selectors.createRouteView.workerAutocomplete)
.parsedUrl();
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
await page.wait(selectors.createRouteView.workerAutocomplete);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/route/create');
});
it(`should attempt to create a new route but fail since employee has no access rights`, async() => {
const result = await nightmare
.write(selectors.createRouteView.descriptionInput, 'faster faster!!')
.waitToClick(selectors.createRouteView.submitButton)
.waitForLastSnackbar();
await page.write(selectors.createRouteView.descriptionInput, 'faster faster!!');
await page.waitToClick(selectors.createRouteView.submitButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Access denied');
});
});
describe('as delivery', () => {
beforeAll(() => {
nightmare
.login('delivery')
.selectModule('route')
.changeLanguageToEnglish();
beforeAll(async() => {
await page.login('delivery');
await page.selectModule('route');
await page.changeLanguageToEnglish();
});
it('should again click on the add new route button and open the creation form', async() => {
const url = await nightmare
.waitToClick(selectors.routeIndex.addNewRouteButton)
.wait(selectors.createRouteView.workerAutocomplete)
.parsedUrl();
await page.waitToClick(selectors.routeIndex.addNewRouteButton);
await page.wait(selectors.createRouteView.workerAutocomplete);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/route/create');
});
it(`should create a new route`, async() => {
const result = await nightmare
.autocompleteSearch(selectors.createRouteView.workerAutocomplete, 'teamManagerNick')
.datePicker(selectors.createRouteView.createdDatePicker, 0, null)
.autocompleteSearch(selectors.createRouteView.vehicleAutoComplete, '4444-IMK')
.autocompleteSearch(selectors.createRouteView.agencyAutoComplete, 'Teleportation device')
.write(selectors.createRouteView.descriptionInput, 'faster faster!!')
.waitToClick(selectors.createRouteView.submitButton)
.waitForLastSnackbar();
await page.autocompleteSearch(selectors.createRouteView.workerAutocomplete, 'teamManagerNick');
await page.datePicker(selectors.createRouteView.createdDatePicker, 0, null);
await page.autocompleteSearch(selectors.createRouteView.vehicleAutoComplete, '4444-IMK');
await page.autocompleteSearch(selectors.createRouteView.agencyAutoComplete, 'Teleportation device');
await page.write(selectors.createRouteView.descriptionInput, 'faster faster!!');
await page.waitToClick(selectors.createRouteView.submitButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the redirection to the created route summary`, async() => {
const url = await nightmare
.wait(selectors.routeSummary.routeId)
.parsedUrl();
await page.wait(selectors.routeSummary.routeId);
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});

View File

@ -1,62 +1,60 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('Route basic Data path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('delivery', 'route')
.accessToSearchResult(1)
.accessToSection('route.card.basicData');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('delivery', 'route');
await page.accessToSearchResult('1');
await page.accessToSection('route.card.basicData');
});
afterAll(async() => {
await browser.close();
});
it('should edit the route basic data', async() => {
const result = await nightmare
.autocompleteSearch(selectors.routeBasicData.workerAutoComplete, 'adminBossNick')
.autocompleteSearch(selectors.routeBasicData.vehicleAutoComplete, '1111-IMK')
.datePicker(selectors.routeBasicData.createdDateInput, 1, null)
.clearInput(selectors.routeBasicData.kmStartInput)
.write(selectors.routeBasicData.kmStartInput, 1)
.clearInput(selectors.routeBasicData.kmEndInput)
.write(selectors.routeBasicData.kmEndInput, 2)
.write(selectors.routeBasicData.startedHourInput, '0800')
.write(selectors.routeBasicData.finishedHourInput, '1230')
.waitToClick(selectors.routeBasicData.saveButton)
.waitForLastSnackbar();
await page.autocompleteSearch(selectors.routeBasicData.workerAutoComplete, 'adminBossNick');
await page.autocompleteSearch(selectors.routeBasicData.vehicleAutoComplete, '1111-IMK');
await page.datePicker(selectors.routeBasicData.createdDateInput, 1, null);
await page.clearInput(selectors.routeBasicData.kmStartInput);
await page.write(selectors.routeBasicData.kmStartInput, '1');
await page.clearInput(selectors.routeBasicData.kmEndInput);
await page.write(selectors.routeBasicData.kmEndInput, '2');
await page.write(selectors.routeBasicData.startedHourInput, '0800');
await page.write(selectors.routeBasicData.finishedHourInput, '1230');
await page.waitToClick(selectors.routeBasicData.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
}, 15000);
it('should confirm the worker was edited', async() => {
const worker = await nightmare
.reloadSection('route.card.basicData')
.waitToGetProperty(`${selectors.routeBasicData.workerAutoComplete} input`, 'value');
await page.reloadSection('route.card.basicData');
const worker = await page.waitToGetProperty(`${selectors.routeBasicData.workerAutoComplete} input`, 'value');
expect(worker).toEqual('adminBoss - adminBossNick');
});
it('should confirm the vehicle was edited', async() => {
const vehicle = await nightmare
.waitToGetProperty(`${selectors.routeBasicData.vehicleAutoComplete} input`, 'value');
const vehicle = await page.waitToGetProperty(`${selectors.routeBasicData.vehicleAutoComplete} input`, 'value');
expect(vehicle).toEqual('1111-IMK');
});
it('should confirm the km start was edited', async() => {
const kmStart = await nightmare
.waitToGetProperty(selectors.routeBasicData.kmStartInput, 'value');
const kmStart = await page.waitToGetProperty(selectors.routeBasicData.kmStartInput, 'value');
expect(kmStart).toEqual('1');
});
it('should confirm the km end was edited', async() => {
const kmEnd = await nightmare
.waitToGetProperty(selectors.routeBasicData.kmEndInput, 'value');
const kmEnd = await page.waitToGetProperty(selectors.routeBasicData.kmEndInput, 'value');
expect(kmEnd).toEqual('2');
});

View File

@ -1,87 +1,93 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
// #1528 e2e claim/detail
xdescribe('Route basic Data path', () => {
const nightmare = createNightmare();
let browser;
let page;
beforeAll(() => {
nightmare
.loginAndModule('delivery', 'route')
.accessToSearchResult(3)
.accessToSection('route.card.tickets');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('delivery', 'route');
await page.accessToSearchResult('3');
await page.accessToSection('route.card.tickets');
});
afterAll(async() => {
await browser.close();
});
it('should modify the first ticket priority', async() => {
const result = await nightmare
.write(selectors.routeTickets.firstTicketPriority, 2)
.write('body', '\u000d') // simulates enter
.waitForLastSnackbar();
const result = await nightmare;
await page.write(selectors.routeTickets.firstTicketPriority, '2');
await page.keyboard.press('Enter');
await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should confirm the buscamanButton is disabled', async() => {
const result = await nightmare
.evaluate(selector => {
return document.querySelector(selector);
}, `${selectors.routeTickets.buscamanButton} :disabled`);
const result = await nightmare;
await page.evaluate(selector => {
return document.querySelector(selector);
}, `${selectors.routeTickets.buscamanButton} :disabled`);
expect(result).toBeTruthy();
});
it('should check the first ticket checkbox and confirm the buscamanButton button is no longer disabled', async() => {
const result = await nightmare
.waitToClick(selectors.routeTickets.firstTicketCheckbox)
.evaluate(selector => {
return document.querySelector(selector);
}, `${selectors.routeTickets.buscamanButton} :disabled`);
const result = await nightmare;
await page.waitToClick(selectors.routeTickets.firstTicketCheckbox);
await page.evaluate(selector => {
return document.querySelector(selector);
}, `${selectors.routeTickets.buscamanButton} :disabled`);
expect(result).toBeFalsy();
});
it('should check the route volume on the descriptor', async() => {
const result = await nightmare
.waitToGetProperty(selectors.routeDescriptor.volume, 'innerText');
const result = await nightmare;
await page.waitToGetProperty(selectors.routeDescriptor.volume, 'innerText');
expect(result).toEqual('1.1 / 18 m³');
});
it('should count how many tickets are in route', async() => {
const result = await nightmare
.countElement('vn-route-tickets vn-textfield[ng-model="ticket.priority"]');
const result = await nightmare;
await page.countElement('vn-route-tickets vn-textfield[ng-model="ticket.priority"]');
expect(result).toEqual(11);
});
it('should delete the first ticket in route', async() => {
const result = await nightmare
.waitToClick(selectors.routeTickets.firstTicketDeleteButton)
.waitToClick(selectors.routeTickets.confirmButton)
.waitForLastSnackbar();
const result = await nightmare;
await page.waitToClick(selectors.routeTickets.firstTicketDeleteButton);
await page.waitToClick(selectors.routeTickets.confirmButton);
await page.waitForLastSnackbar();
expect(result).toEqual('Ticket removed from route');
});
it('should again delete the first ticket in route', async() => {
const result = await nightmare
.waitToClick(selectors.routeTickets.firstTicketDeleteButton)
.waitToClick(selectors.routeTickets.confirmButton)
.waitForLastSnackbar();
const result = await nightmare;
await page.waitToClick(selectors.routeTickets.firstTicketDeleteButton);
await page.waitToClick(selectors.routeTickets.confirmButton);
await page.waitForLastSnackbar();
expect(result).toEqual('Ticket removed from route');
});
it('should now count how many tickets are in route to find one less', async() => {
const result = await nightmare
.countElement('vn-route-tickets vn-textfield[ng-model="ticket.priority"]');
const result = await nightmare;
await page.countElement('vn-route-tickets vn-textfield[ng-model="ticket.priority"]');
expect(result).toEqual(9);
});
it('should confirm the route volume on the descriptor has been updated by the changes made', async() => {
const result = await nightmare
.waitToGetProperty(selectors.routeDescriptor.volume, 'innerText');
const result = await nightmare;
await page.waitToGetProperty(selectors.routeDescriptor.volume, 'innerText');
expect(result).toEqual('0.9 / 18 m³');
});

View File

@ -1,139 +1,132 @@
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
import getBrowser from '../../helpers/puppeteer';
describe('InvoiceOut descriptor path', () => {
const nightmare = createNightmare();
let browser;
let page;
describe('as Administrative', () => {
beforeAll(() => {
nightmare
.loginAndModule('administrative', 'ticket');
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('administrative', 'ticket');
});
afterAll(async() => {
await browser.close();
});
it('should search for tickets with an specific invoiceOut', async() => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton)
.write(selectors.ticketsIndex.advancedSearchInvoiceOut, 'T2222222')
.waitToClick(selectors.ticketsIndex.advancedSearchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton);
await page.write(selectors.ticketsIndex.advancedSearchInvoiceOut, 'T2222222');
await page.waitToClick(selectors.ticketsIndex.advancedSearchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
it('should navigate to the invoiceOut index', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.invoiceOutButton)
.wait(selectors.invoiceOutIndex.searchInvoiceOutInput)
.parsedUrl();
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.invoiceOutButton);
await page.wait(selectors.invoiceOutIndex.searchInvoiceOutInput);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/invoice-out/index');
});
it('should search for the target invoiceOut', async() => {
const result = await nightmare
.write(selectors.invoiceOutIndex.searchInvoiceOutInput, 'T2222222')
.waitToClick(selectors.invoiceOutIndex.searchButton)
.waitForNumberOfElements(selectors.invoiceOutIndex.searchResult, 1)
.countElement(selectors.invoiceOutIndex.searchResult);
await page.write(selectors.invoiceOutIndex.searchInvoiceOutInput, 'T2222222');
await page.waitToClick(selectors.invoiceOutIndex.searchButton);
await page.waitForNumberOfElements(selectors.invoiceOutIndex.searchResult, 1);
const result = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(result).toEqual(1);
});
it(`should click on the search result to access to the invoiceOut summary`, async() => {
const url = await nightmare
.accessToSearchResult('T2222222')
.waitForURL('/summary')
.parsedUrl();
await page.accessToSearchResult('T2222222');
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it('should delete the invoiceOut using the descriptor more menu', async() => {
const result = await nightmare
.waitToClick(selectors.invoiceOutDescriptor.moreMenu)
.waitToClick(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut)
.waitToClick(selectors.invoiceOutDescriptor.acceptDeleteButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu);
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut);
await page.waitToClick(selectors.invoiceOutDescriptor.acceptDeleteButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('InvoiceOut deleted');
});
it('should have been relocated to the invoiceOut index', async() => {
const url = await nightmare
.parsedUrl();
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/invoice-out/index');
});
it(`should search for the deleted invouceOut to find no results`, async() => {
const result = await nightmare
.write(selectors.invoiceOutIndex.searchInvoiceOutInput, 'T2222222')
.waitToClick(selectors.invoiceOutIndex.searchButton)
.waitForNumberOfElements(selectors.invoiceOutIndex.searchResult, 0)
.countElement(selectors.invoiceOutIndex.searchResult);
await page.write(selectors.invoiceOutIndex.searchInvoiceOutInput, 'T2222222');
await page.waitToClick(selectors.invoiceOutIndex.searchButton);
await page.waitForNumberOfElements(selectors.invoiceOutIndex.searchResult, 0);
const result = await page.countElement(selectors.invoiceOutIndex.searchResult);
expect(result).toEqual(0);
});
it('should navigate to the ticket index', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
.parsedUrl();
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.ticketsButton);
await page.wait(selectors.ticketsIndex.searchTicketInput);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
it('should search for tickets with an specific invoiceOut to find no results', async() => {
const result = await nightmare
.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton)
.write(selectors.ticketsIndex.advancedSearchInvoiceOut, 'T2222222')
.waitToClick(selectors.ticketsIndex.advancedSearchButton)
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 0)
.countElement(selectors.ticketsIndex.searchResult);
await page.waitToClick(selectors.ticketsIndex.openAdvancedSearchButton);
await page.write(selectors.ticketsIndex.advancedSearchInvoiceOut, 'T2222222');
await page.waitToClick(selectors.ticketsIndex.advancedSearchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 0);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(0);
});
it('should now navigate to the invoiceOut index', async() => {
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.invoiceOutButton)
.wait(selectors.invoiceOutIndex.searchInvoiceOutInput)
.parsedUrl();
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.invoiceOutButton);
await page.wait(selectors.invoiceOutIndex.searchInvoiceOutInput);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/invoice-out/index');
});
it(`should search and access to the invoiceOut summary`, async() => {
const url = await nightmare
.accessToSearchResult('T1111111')
.waitForURL('/summary')
.parsedUrl();
await page.accessToSearchResult('T1111111');
await page.waitForURL('/summary');
const url = await page.parsedUrl();
expect(url.hash).toContain('/summary');
});
it(`should check the invoiceOut is booked in the summary data`, async() => {
const result = await nightmare
.waitForTextInElement(selectors.invoiceOutSummary.bookedLabel, '/')
.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText');
await page.waitForTextInElement(selectors.invoiceOutSummary.bookedLabel, '/');
const result = await page.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText');
expect(result.length).toBeGreaterThan(1);
});
it('should re-book the invoiceOut using the descriptor more menu', async() => {
const result = await nightmare
.waitToClick(selectors.invoiceOutDescriptor.moreMenu)
.waitToClick(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut)
.waitToClick(selectors.invoiceOutDescriptor.acceptBookingButton)
.waitForLastSnackbar();
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu);
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut);
await page.waitToClick(selectors.invoiceOutDescriptor.acceptBookingButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('InvoiceOut booked');
});
@ -149,7 +142,7 @@ describe('InvoiceOut descriptor path', () => {
let expectedDate = `${day}/${month}/${today.getFullYear()}`;
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.invoiceOutSummary.bookedLabel, 'innerText');
expect(result).toEqual(expectedDate);
@ -157,24 +150,21 @@ describe('InvoiceOut descriptor path', () => {
});
describe('as salesPerson', () => {
beforeAll(() => {
nightmare
.loginAndModule('salesPerson', 'invoiceOut')
.accessToSearchResult('A1111111');
beforeAll(async() => {
await page.loginAndModule('salesPerson', 'invoiceOut');
await page.accessToSearchResult('A1111111');
});
it(`should check the salesPerson role doens't see the book option in the more menu`, async() => {
const result = await nightmare
.waitToClick(selectors.invoiceOutDescriptor.moreMenu)
.wait(selectors.invoiceOutDescriptor.moreMenuShowInvoiceOutPdf)
.exists(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut);
await page.waitToClick(selectors.invoiceOutDescriptor.moreMenu);
await page.wait(selectors.invoiceOutDescriptor.moreMenuShowInvoiceOutPdf);
const result = await page.exists(selectors.invoiceOutDescriptor.moreMenuBookInvoiceOut);
expect(result).toBeFalsy();
});
it(`should check the salesPerson role doens't see the delete option in the more menu`, async() => {
const result = await nightmare
.exists(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut);
const result = await page.exists(selectors.invoiceOutDescriptor.moreMenuDeleteInvoiceOut);
expect(result).toBeFalsy();
});

View File

@ -1,29 +1,32 @@
import selectors from '../helpers/selectors';
import createNightmare from '../helpers/nightmare';
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('create client path', () => {
let nightmare = createNightmare();
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'client');
});
beforeAll(() => {
return nightmare
.loginAndModule('employee', 'client');
afterAll(async() => {
await browser.close();
});
it('should access to the create client view by clicking the create-client floating button', async() => {
let url = await nightmare
.waitToClick(selectors.clientsIndex.createClientButton)
.wait(selectors.createClientView.createButton)
.parsedUrl();
await page.waitToClick(selectors.clientsIndex.createClientButton);
await page.wait(selectors.createClientView.createButton);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/client/create');
});
it('should cancel the client creation to go back to clients index', async() => {
let url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.waitToClick(selectors.globalItems.clientsButton)
.wait(selectors.clientsIndex.createClientButton)
.parsedUrl();
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitToClick(selectors.globalItems.clientsButton);
await page.wait(selectors.clientsIndex.createClientButton);
const url = await page.parsedUrl();
expect(url.hash).toEqual('#!/client/index');
});

View File

@ -216,7 +216,7 @@ function e2eSingleRun() {
`${__dirname}/e2e/paths/02*/*[sS]pec.js`,
`${__dirname}/e2e/paths/03*/*[sS]pec.js`,
`${__dirname}/e2e/paths/04*/*[sS]pec.js`,
// `${__dirname}/e2e/paths/05*/*[sS]pec.js`,
`${__dirname}/e2e/paths/05*/*[sS]pec.js`,
// `${__dirname}/e2e/paths/06*/*[sS]pec.js`,
// `${__dirname}/e2e/paths/07*/*[sS]pec.js`,
// `${__dirname}/e2e/paths/08*/*[sS]pec.js`,