#1976 Implementar Puppeteer worker + item + gulp changes
gitea/salix/puppeteer There was a failure building this commit Details

This commit is contained in:
Carlos Jimenez Ruiz 2020-01-14 09:24:09 +01:00
parent 3bcaaddb14
commit 54f7d21e24
15 changed files with 245 additions and 230 deletions

View File

@ -1,17 +1,19 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Worker pbx path', () => { describe('Worker pbx path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('hr', 'worker'); await page.loginAndModule('hr', 'worker');
await page.accessToSearchResult('employee'); await page.accessToSearchResult('employee');
await page.accessToSection('worker.card.pbx'); await page.accessToSection('worker.card.pbx');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it('should receive an error when the extension exceeds 4 characters', async() => { it('should receive an error when the extension exceeds 4 characters', async() => {

View File

@ -1,95 +1,101 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare'; import getBrowser from '../../helpers/puppeteer';
describe('Worker time control path', () => { describe('Worker time control path', () => {
const nightmare = createNightmare(); let browser;
let page;
beforeAll(() => { beforeAll(async() => {
nightmare browser = await getBrowser();
.loginAndModule('hr', 'worker') page = browser.page;
.accessToSearchResult('HankPym') await page.loginAndModule('salesBoss', 'worker');
.accessToSection('worker.card.timeControl'); await page.accessToSearchResult('HankPym');
await page.accessToSection('worker.card.timeControl');
}); });
describe('as HHRR', () => { afterAll(async() => {
browser.close();
});
describe('as salesBoss', () => {
describe('on Monday', () => { describe('on Monday', () => {
it('should scan in Hank Pym', async() => { it('should scan in Hank Pym', async() => {
const scanTime = '07:00'; const scanTime = '07:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.mondayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should scan out Hank Pym for break`, async() => { it(`should scan out Hank Pym for break`, async() => {
const scanTime = '10:00'; const scanTime = '10:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.mondayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should scan in Hank Pym for a wrong hour and forget to scan in from the break`, async() => { it(`should scan in Hank Pym for a wrong hour and forget to scan in from the break`, async() => {
const scanTime = '18:00'; const scanTime = '18:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.mondayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should delete the wrong entry for Hank Pym`, async() => { it(`should delete the wrong entry for Hank Pym`, async() => {
const wrongScanTime = '18:00'; const wrongScanTime = '18:00';
const result = await nightmare
.waitForTextInElement(selectors.workerTimeControl.thirdEntryOfMonday, wrongScanTime) await page.waitForTextInElement(selectors.workerTimeControl.thirdEntryOfMonday, wrongScanTime);
.waitToClick(selectors.workerTimeControl.thirdEntryOfMondayDelete) await page.waitToClick(selectors.workerTimeControl.thirdEntryOfMondayDelete);
.waitToClick(selectors.workerTimeControl.acceptDeleteDialog) await page.waitToClick(selectors.workerTimeControl.acceptDeleteDialog);
.waitForLastSnackbar(); let result = await page.waitForLastSnackbar();
expect(result).toEqual('Entry removed'); expect(result).toEqual('Entry removed');
}); });
it(`should scan out Hank Pym to leave early`, async() => { it(`should scan out Hank Pym to leave early`, async() => {
const scanTime = '14:00'; const scanTime = '14:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.mondayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should add the break's scan in for Hank Pym and be in the right order`, async() => { it(`should add the break's scan in for Hank Pym and be in the right order`, async() => {
const scanTime = '10:20'; const scanTime = '10:20';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.mondayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfMonday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfMonday, 'innerText');
expect(result).toEqual('14:00'); expect(result).toEqual('14:00');
}); });
it(`should the third entry be the scan in from break`, async() => { it(`should the third entry be the scan in from break`, async() => {
const scanTime = '10:20'; const scanTime = '10:20';
const result = await nightmare
const result = await page
.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText'); .waitToGetProperty(selectors.workerTimeControl.thirdEntryOfMonday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should check Hank Pym worked 8 hours`, async() => { it(`should check Hank Pym worked 8 hours`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '07:00 h.');
.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '07:00 h.') const result = await page
.waitToGetProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText'); .waitToGetProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText');
expect(result).toEqual('07:00 h.'); expect(result).toEqual('07:00 h.');
@ -99,52 +105,51 @@ describe('Worker time control path', () => {
describe('on Tuesday', () => { describe('on Tuesday', () => {
it('should happily scan in Hank Pym', async() => { it('should happily scan in Hank Pym', async() => {
const scanTime = '08:00'; const scanTime = '08:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.firstEntryOfTuesday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfTuesday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should happily scan out Hank Pym for break`, async() => { it(`should happily scan out Hank Pym for break`, async() => {
const scanTime = '10:00'; const scanTime = '10:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.secondEntryOfTuesday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfTuesday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should happily scan in Hank Pym from the break`, async() => { it(`should happily scan in Hank Pym from the break`, async() => {
const scanTime = '10:20'; const scanTime = '10:20';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfTuesday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfTuesday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should happily scan out Hank Pym for the day`, async() => { it(`should happily scan out Hank Pym for the day`, async() => {
const scanTime = '16:00'; const scanTime = '16:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.tuesdayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfTuesday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfTuesday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should check Hank Pym worked 8 happy hours`, async() => { it(`should check Hank Pym worked 8 happy hours`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.workerTimeControl.tuesdayWorkedHours, '08:00 h.');
.waitForTextInElement(selectors.workerTimeControl.tuesdayWorkedHours, '08:00 h.') const result = await page.waitToGetProperty(selectors.workerTimeControl.tuesdayWorkedHours, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.tuesdayWorkedHours, 'innerText');
expect(result).toEqual('08:00 h.'); expect(result).toEqual('08:00 h.');
}); });
@ -153,52 +158,51 @@ describe('Worker time control path', () => {
describe('on Wednesday', () => { describe('on Wednesday', () => {
it('should cheerfully scan in Hank Pym', async() => { it('should cheerfully scan in Hank Pym', async() => {
const scanTime = '09:00'; const scanTime = '09:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.firstEntryOfWednesday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfWednesday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should cheerfully scan out Hank Pym for break`, async() => { it(`should cheerfully scan out Hank Pym for break`, async() => {
const scanTime = '10:00'; const scanTime = '10:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.secondEntryOfWednesday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfWednesday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should cheerfully scan in Hank Pym from the break`, async() => { it(`should cheerfully scan in Hank Pym from the break`, async() => {
const scanTime = '10:20'; const scanTime = '10:20';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfWednesday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfWednesday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should cheerfully scan out Hank Pym for the day`, async() => { it(`should cheerfully scan out Hank Pym for the day`, async() => {
const scanTime = '17:00'; const scanTime = '17:00';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.wednesdayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfWednesday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfWednesday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should check Hank Pym worked 8 cheerfull hours`, async() => { it(`should check Hank Pym worked 8 cheerfull hours`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.workerTimeControl.wednesdayWorkedHours, '08:00 h.');
.waitForTextInElement(selectors.workerTimeControl.wednesdayWorkedHours, '08:00 h.') const result = await page.waitToGetProperty(selectors.workerTimeControl.wednesdayWorkedHours, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.wednesdayWorkedHours, 'innerText');
expect(result).toEqual('08:00 h.'); expect(result).toEqual('08:00 h.');
}); });
@ -207,52 +211,48 @@ describe('Worker time control path', () => {
describe('on Thursday', () => { describe('on Thursday', () => {
it('should joyfully scan in Hank Pym', async() => { it('should joyfully scan in Hank Pym', async() => {
const scanTime = '09:59'; const scanTime = '09:59';
const result = await nightmare
.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton) await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.waitToClick(selectors.workerTimeControl.confirmButton) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToGetProperty(selectors.workerTimeControl.firstEntryOfThursday, 'innerText'); const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfThursday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should joyfully scan out Hank Pym for break`, async() => { it(`should joyfully scan out Hank Pym for break`, async() => {
const scanTime = '10:00'; const scanTime = '10:00';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfThursday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.secondEntryOfThursday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should joyfully scan in Hank Pym from the break`, async() => { it(`should joyfully scan in Hank Pym from the break`, async() => {
const scanTime = '10:20'; const scanTime = '10:20';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfThursday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfThursday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should joyfully scan out Hank Pym for the day`, async() => { it(`should joyfully scan out Hank Pym for the day`, async() => {
const scanTime = '17:59'; const scanTime = '17:59';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton);
.waitToClick(selectors.workerTimeControl.thursdayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfThursday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfThursday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should check Hank Pym worked 8 joyfull hours`, async() => { it(`should check Hank Pym worked 8 joyfull hours`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.workerTimeControl.thursdayWorkedHours, '08:00 h.');
.waitForTextInElement(selectors.workerTimeControl.thursdayWorkedHours, '08:00 h.') const result = await page.waitToGetProperty(selectors.workerTimeControl.thursdayWorkedHours, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.thursdayWorkedHours, 'innerText');
expect(result).toEqual('08:00 h.'); expect(result).toEqual('08:00 h.');
}); });
@ -261,93 +261,88 @@ describe('Worker time control path', () => {
describe('on Friday', () => { describe('on Friday', () => {
it('should smilingly scan in Hank Pym', async() => { it('should smilingly scan in Hank Pym', async() => {
const scanTime = '07:30'; const scanTime = '07:30';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
.waitToClick(selectors.workerTimeControl.fridayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfFriday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.firstEntryOfFriday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should smilingly scan out Hank Pym for break`, async() => { it(`should smilingly scan out Hank Pym for break`, async() => {
const scanTime = '10:00'; const scanTime = '10:00';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
.waitToClick(selectors.workerTimeControl.fridayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfFriday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.secondEntryOfFriday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should smilingly scan in Hank Pym from the break`, async() => { it(`should smilingly scan in Hank Pym from the break`, async() => {
const scanTime = '10:20'; const scanTime = '10:20';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
.waitToClick(selectors.workerTimeControl.fridayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfFriday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.thirdEntryOfFriday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should smilingly scan out Hank Pym for the day`, async() => { it(`should smilingly scan out Hank Pym for the day`, async() => {
const scanTime = '15:30'; const scanTime = '15:30';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.fridayAddTimeButton);
.waitToClick(selectors.workerTimeControl.fridayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfFriday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.fourthEntryOfFriday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should check Hank Pym worked 8 hours with a smile on his face`, async() => { it(`should check Hank Pym worked 8 hours with a smile on his face`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.workerTimeControl.fridayWorkedHours, '08:00 h.');
.waitForTextInElement(selectors.workerTimeControl.fridayWorkedHours, '08:00 h.') const result = await page.waitToGetProperty(selectors.workerTimeControl.fridayWorkedHours, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.fridayWorkedHours, 'innerText');
expect(result).toEqual('08:00 h.'); expect(result).toEqual('08:00 h.');
}); });
}); });
}); });
describe('as hr', () => { describe('as HHRR', () => {
describe('on Saturday', () => { describe('on Saturday', () => {
beforeAll(() => { it('should log in and navigate to timeControl', async() => {
nightmare await page.loginAndModule('hr', 'worker');
.loginAndModule('hr', 'worker') await page.accessToSearchResult('HankPym');
.accessToSearchResult('HankPym') await Promise.all([
.accessToSection('worker.card.timeControl'); page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
page.waitForContentLoaded(),
page.accessToSection('worker.card.timeControl')
]);
}); });
it('should lovingly scan in Hank Pym', async() => { it('should lovingly scan in Hank Pym', async() => {
const scanTime = '06:00'; const scanTime = '06:00';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton);
.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSaturday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSaturday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should lovingly scan out Hank Pym for the day with no break to leave a bit early`, async() => { it(`should lovingly scan out Hank Pym for the day with no break to leave a bit early`, async() => {
const scanTime = '13:40'; const scanTime = '13:40';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton);
.waitToClick(selectors.workerTimeControl.saturdayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSaturday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSaturday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should check Hank Pym worked 8 hours with all his will`, async() => { it(`should check Hank Pym worked 8 hours with all his will`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.workerTimeControl.saturdayWorkedHours, '08:00 h.');
.waitForTextInElement(selectors.workerTimeControl.saturdayWorkedHours, '08:00 h.') const result = await page.waitToGetProperty(selectors.workerTimeControl.saturdayWorkedHours, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.saturdayWorkedHours, 'innerText');
expect(result).toEqual('08:00 h.'); expect(result).toEqual('08:00 h.');
}); });
@ -356,49 +351,51 @@ describe('Worker time control path', () => {
describe('on Sunday', () => { describe('on Sunday', () => {
it('should gladly scan in Hank Pym', async() => { it('should gladly scan in Hank Pym', async() => {
const scanTime = '05:00'; const scanTime = '05:00';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.sundayAddTimeButton);
.waitToClick(selectors.workerTimeControl.sundayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSunday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.firstEntryOfSunday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should gladly scan out Hank Pym for the day with no break to leave a bit early`, async() => { it(`should gladly scan out Hank Pym for the day with no break to leave a bit early`, async() => {
const scanTime = '12:40'; const scanTime = '12:40';
const result = await nightmare await page.waitToClick(selectors.workerTimeControl.sundayAddTimeButton);
.waitToClick(selectors.workerTimeControl.sundayAddTimeButton) await page.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime);
.pickTime(selectors.workerTimeControl.timeDialogInput, scanTime) await page.waitToClick(selectors.workerTimeControl.confirmButton);
.waitToClick(selectors.workerTimeControl.confirmButton) const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSunday, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.secondEntryOfSunday, 'innerText');
expect(result).toEqual(scanTime); expect(result).toEqual(scanTime);
}); });
it(`should check Hank Pym worked 8 glad hours`, async() => { it(`should check Hank Pym worked 8 glad hours`, async() => {
const result = await nightmare await page.waitForTextInElement(selectors.workerTimeControl.sundayWorkedHours, '08:00 h.');
.waitForTextInElement(selectors.workerTimeControl.sundayWorkedHours, '08:00 h.') const result = await page.waitToGetProperty(selectors.workerTimeControl.sundayWorkedHours, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.sundayWorkedHours, 'innerText');
expect(result).toEqual('08:00 h.'); expect(result).toEqual('08:00 h.');
}); });
it(`should check Hank Pym doesn't have hours set on the next months first week`, async() => { it(`should check Hank Pym doesn't have hours set on the next months first week`, async() => {
const wholeWeekHours = await nightmare await page.waitToClick(selectors.workerTimeControl.nextMonthButton);
.waitToClick(selectors.workerTimeControl.nextMonthButton) await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
.waitToClick(selectors.workerTimeControl.secondWeekDay) await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '00:00 h.');
.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '00:00 h.') const wholeWeekHours = await page
.waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText'); .waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText');
expect(wholeWeekHours).toEqual('00:00 h.'); expect(wholeWeekHours).toEqual('00:00 h.');
}); });
it(`should check he didn't scan in this week yet`, async() => { it(`should check he didn't scan in this week yet`, async() => {
const wholeWeekHours = await nightmare await page.waitToClick(selectors.workerTimeControl.navigateBackToIndex);
.waitToClick(selectors.workerTimeControl.navigateBackToIndex) await page.accessToSearchResult('salesBoss');
.accessToSearchResult('salesBoss') await Promise.all([
.accessToSection('worker.card.timeControl') page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
page.waitForContentLoaded(),
page.accessToSection('worker.card.timeControl')
]);
await page.waitFor(1000);
const wholeWeekHours = await page
.waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText'); .waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText');
expect(wholeWeekHours).toEqual('00:00 h.'); expect(wholeWeekHours).toEqual('00:00 h.');
@ -407,17 +404,15 @@ describe('Worker time control path', () => {
}); });
describe('after all this amazing week', () => { describe('after all this amazing week', () => {
beforeAll(() => { it('should log in Hank', async() => {
nightmare await page.loginAndModule('HankPym', 'worker');
.loginAndModule('HankPym', 'worker') await page.accessToSearchResult('HankPym');
.accessToSearchResult('HankPym') await page.accessToSection('worker.card.timeControl');
.accessToSection('worker.card.timeControl');
}); });
it('should Hank Pym check his hours are alright', async() => { it('should check his hours are alright', async() => {
const wholeWeekHours = await nightmare await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '55:00 h.');
.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '55:00 h.') const wholeWeekHours = await page.waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText');
.waitToGetProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText');
expect(wholeWeekHours).toEqual('55:00 h.'); expect(wholeWeekHours).toEqual('55:00 h.');
}); });

View File

@ -1,15 +1,17 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item summary path', () => { describe('Item summary path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'item'); await page.loginAndModule('employee', 'item');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it('should search for an item', async() => { it('should search for an item', async() => {

View File

@ -1,17 +1,19 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item Edit basic data path', () => { describe('Item Edit basic data path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item'); await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Melee weapon combat fist 15cm'); await page.accessToSearchResult('Melee weapon combat fist 15cm');
await page.accessToSection('item.card.basicData'); await page.accessToSection('item.card.basicData');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it(`should check the descritor edit button is visible for buyer`, async() => { it(`should check the descritor edit button is visible for buyer`, async() => {

View File

@ -1,17 +1,19 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item edit tax path', () => { describe('Item edit tax path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item'); await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 2m'); await page.accessToSearchResult('Ranged weapon longbow 2m');
await page.accessToSection('item.card.tax'); await page.accessToSection('item.card.tax');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it(`should add the item tax to all countries`, async() => { it(`should add the item tax to all countries`, async() => {

View File

@ -1,17 +1,19 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item create tags path', () => { describe('Item create tags path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item'); await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 2m'); await page.accessToSearchResult('Ranged weapon longbow 2m');
await page.accessToSection('item.card.tags'); await page.accessToSection('item.card.tags');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it(`should create a new tag and delete a former one`, async() => { it(`should create a new tag and delete a former one`, async() => {

View File

@ -1,17 +1,19 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item create niche path', () => { describe('Item create niche path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item'); await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 2m'); await page.accessToSearchResult('Ranged weapon longbow 2m');
await page.accessToSection('item.card.niche'); await page.accessToSection('item.card.niche');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it(`should click create a new niche and delete a former one`, async() => { it(`should click create a new niche and delete a former one`, async() => {

View File

@ -1,17 +1,19 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item Create botanical path', () => { describe('Item Create botanical path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item'); await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon pistol 9mm'); await page.accessToSearchResult('Ranged weapon pistol 9mm');
await page.accessToSection('item.card.botanical'); await page.accessToSection('item.card.botanical');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it(`should create a new botanical for the item`, async() => { it(`should create a new botanical for the item`, async() => {

View File

@ -1,17 +1,19 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item Create barcodes path', () => { describe('Item Create barcodes path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item'); await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon longbow 2m'); await page.accessToSearchResult('Ranged weapon longbow 2m');
await page.accessToSection('item.card.itemBarcode'); await page.accessToSection('item.card.itemBarcode');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it(`should click create a new code and delete a former one`, async() => { it(`should click create a new code and delete a former one`, async() => {

View File

@ -1,15 +1,17 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item Create/Clone path', () => { describe('Item Create/Clone path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item'); await page.loginAndModule('buyer', 'item');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
describe('create', () => { describe('create', () => {

View File

@ -1,15 +1,17 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item regularize path', () => { describe('Item regularize path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'item'); await page.loginAndModule('employee', 'item');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it('should edit the user local warehouse', async() => { it('should edit the user local warehouse', async() => {

View File

@ -1,16 +1,18 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item index path', () => { describe('Item index path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('salesPerson', 'item'); await page.loginAndModule('salesPerson', 'item');
await page.waitToClick(selectors.itemsIndex.searchIcon); await page.waitToClick(selectors.itemsIndex.searchIcon);
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it('should click on the fields to show button to open the list of columns to show', async() => { it('should click on the fields to show button to open the list of columns to show', async() => {

View File

@ -1,15 +1,17 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item log path', () => { describe('Item log path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('developer', 'item'); await page.loginAndModule('developer', 'item');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it(`should search for the Knowledge artifact to confirm it isn't created yet`, async() => { it(`should search for the Knowledge artifact to confirm it isn't created yet`, async() => {

View File

@ -1,17 +1,19 @@
import selectors from '../../helpers/selectors.js'; import selectors from '../../helpers/selectors.js';
import openPage from '../../helpers/puppeteer'; import getBrowser from '../../helpers/puppeteer';
describe('Item descriptor path', () => { describe('Item descriptor path', () => {
let browser;
let page; let page;
beforeAll(async() => { beforeAll(async() => {
page = await openPage(); browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item'); await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('1'); await page.accessToSearchResult('1');
await page.accessToSection('item.card.basicData'); await page.accessToSection('item.card.basicData');
}); });
afterAll(async() => { afterAll(async() => {
page.close(); browser.close();
}); });
it('should check the descriptor inactive icon is dark as the item is active', async() => { it('should check the descriptor inactive icon is dark as the item is active', async() => {

View File

@ -207,7 +207,6 @@ e2eOnly.description = `Runs the e2e tests only`;
function e2eSingleRun() { function e2eSingleRun() {
require('@babel/register')({presets: ['@babel/preset-env']}); require('@babel/register')({presets: ['@babel/preset-env']});
require('@babel/polyfill'); require('@babel/polyfill');
let getBrowser = require('./e2e/helpers/puppeteer').getBrowser;
const jasmine = require('gulp-jasmine'); const jasmine = require('gulp-jasmine');
const SpecReporter = require('jasmine-spec-reporter').SpecReporter; const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
@ -222,8 +221,7 @@ function e2eSingleRun() {
// `${__dirname}/e2e/paths/07*/*[sS]pec.js`, // `${__dirname}/e2e/paths/07*/*[sS]pec.js`,
// `${__dirname}/e2e/paths/08*/*[sS]pec.js`, // `${__dirname}/e2e/paths/08*/*[sS]pec.js`,
// `${__dirname}/e2e/paths/09*/*[sS]pec.js`, // `${__dirname}/e2e/paths/09*/*[sS]pec.js`,
// `${__dirname}/e2e/paths/**/*[sS]pec.js`, // `${__dirname}/e2e/paths/**/*[sS]pec.js`
`${__dirname}/e2e/helpers/extensions.js`
]; ];
return gulp.src(specFiles).pipe(jasmine({ return gulp.src(specFiles).pipe(jasmine({
@ -239,11 +237,7 @@ function e2eSingleRun() {
} }
}) })
] ]
}) }));
.on('jasmineDone', async function() {
await getBrowser().close();
})
);
} }
e2eSingleRun.description = `Runs the e2e tests just once`; e2eSingleRun.description = `Runs the e2e tests just once`;