salix/e2e/paths/03-worker/04_time_control.spec.js

91 lines
4.3 KiB
JavaScript
Raw Normal View History

/* eslint max-len: ["error", { "code": 150 }]*/
2019-06-04 05:57:01 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
fdescribe('Worker time control path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('salesBoss', 'worker');
await page.accessToSearchResult('HankPym');
await page.accessToSection('worker.card.timeControl');
});
2019-06-04 05:57:01 +00:00
afterAll(async() => {
await browser.close();
2019-06-04 05:57:01 +00:00
});
const eightAm = '08:00';
const fourPm = '16:00';
const hankPymId = 1107;
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
it(`should go to the next month, go to current month, go 1 month in the past, return error when insert 'out' of first entry, then insert 'in' monday, then insert 'out' monday, then check if Hank Pym worked 8:20 hours, remove first entry of monday, be the 'out' the first entry of monday and change week of month`, async() => {
let date = new Date();
date.setMonth(date.getMonth() + 1);
2022-12-28 12:06:00 +00:00
let month = date.toLocaleString('default', {month: 'long'});
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
await page.click(selectors.workerTimeControl.nextMonthButton);
2022-12-28 12:06:00 +00:00
expect(await page.getProperty(selectors.workerTimeControl.monthName, 'innerText')).toContain(month);
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
date = new Date();
month = date.toLocaleString('default', {month: 'long'});
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
await page.click(selectors.workerTimeControl.previousMonthButton);
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
expect(await page.getProperty(selectors.workerTimeControl.monthName, 'innerText')).toContain(month);
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
date = new Date();
date.setMonth(date.getMonth() - 1);
2022-12-28 12:06:00 +00:00
month = date.toLocaleString('default', {month: 'long'});
const timestamp = Math.round(date.getTime() / 1000);
await page.loginAndModule('salesBoss', 'worker');
await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`);
2022-12-28 12:06:00 +00:00
await page.click(selectors.workerTimeControl.secondWeekDay);
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
expect(await page.getProperty(selectors.workerTimeControl.monthName, 'innerText')).toContain(month);
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
await page.click(selectors.workerTimeControl.mondayAddTimeButton);
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
await page.respondToDialog('accept');
2022-12-28 12:06:00 +00:00
let message = await page.waitForSnackbar();
2019-06-04 05:57:01 +00:00
expect(message.text).toBeDefined();
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
await page.click(selectors.workerTimeControl.mondayAddTimeButton);
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
await page.respondToDialog('accept');
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
expect(await page.getProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText')).toEqual(eightAm);
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
await page.click(selectors.workerTimeControl.mondayAddTimeButton);
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, fourPm);
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
await page.respondToDialog('accept');
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
expect(await page.getProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText')).toEqual(fourPm);
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
expect(await page.getProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText')).toBe('08:20 h.');
expect(await page.getProperty(selectors.workerTimeControl.weekWorkedHours, 'innerText')).toBe('08:20 h.');
expect(await page.getProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText')).toBe(eightAm);
expect(await page.getProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText')).toBe(fourPm);
await page.click(selectors.workerTimeControl.firstEntryOfMondayDelete);
await page.respondToDialog('accept');
2022-12-28 12:06:00 +00:00
message = await page.waitForSnackbar();
2019-06-04 05:57:01 +00:00
expect(message.text).toContain('Entry removed');
2022-12-28 12:06:00 +00:00
const result = await page.getProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
2019-06-04 05:57:01 +00:00
expect(result).toEqual(fourPm);
2019-06-04 05:57:01 +00:00
2022-12-28 12:06:00 +00:00
await page.click(selectors.workerTimeControl.thrirdWeekDay);
expect(await page.getProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText')).toBe('00:00 h.');
2019-06-04 05:57:01 +00:00
});
});