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

66 lines
2.3 KiB
JavaScript
Raw Permalink 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:17:47 +00:00
describe('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
2023-01-03 08:14:25 +00:00
it('should go to the next month, go to current month and go 1 month in the past', async() => {
2023-01-16 14:18:24 +00:00
let date = Date.vnNew();
2023-01-31 09:37:18 +00:00
date.setDate(1);
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
2023-03-22 09:13:37 +00:00
await page.waitToClick(selectors.workerTimeControl.nextMonthButton);
2023-01-03 08:14:25 +00:00
let result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText');
2023-01-03 08:14:25 +00:00
expect(result).toContain(month);
2019-06-04 05:57:01 +00:00
2023-01-16 14:18:24 +00:00
date = Date.vnNew();
2023-01-31 09:37:18 +00:00
date.setDate(1);
2022-12-28 12:06:00 +00:00
month = date.toLocaleString('default', {month: 'long'});
2019-06-04 05:57:01 +00:00
2023-03-22 09:13:37 +00:00
await page.waitToClick(selectors.workerTimeControl.previousMonthButton);
2023-01-03 08:14:25 +00:00
result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText');
2019-06-04 05:57:01 +00:00
2023-01-03 08:14:25 +00:00
expect(result).toContain(month);
2019-06-04 05:57:01 +00:00
2023-01-16 14:18:24 +00:00
date = Date.vnNew();
2023-01-31 09:37:18 +00:00
date.setDate(1);
date.setMonth(date.getMonth() - 1);
const timestamp = Math.round(date.getTime() / 1000);
2023-01-03 08:14:25 +00:00
month = date.toLocaleString('default', {month: 'long'});
await page.loginAndModule('salesBoss', 'worker');
await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`);
2023-03-22 09:13:37 +00:00
await page.waitToClick(selectors.workerTimeControl.secondWeekDay);
2019-06-04 05:57:01 +00:00
2023-01-03 08:14:25 +00:00
result = await page.getProperty(selectors.workerTimeControl.monthName, 'innerText');
2019-06-04 05:57:01 +00:00
2023-01-03 08:14:25 +00:00
expect(result).toContain(month);
});
it('should change week of month', async() => {
2022-12-28 12:06:00 +00:00
await page.click(selectors.workerTimeControl.thrirdWeekDay);
2023-01-03 08:14:25 +00:00
const result = await page.getProperty(selectors.workerTimeControl.mondayWorkedHours, 'innerText');
2022-12-28 12:06:00 +00:00
2023-01-03 08:14:25 +00:00
expect(result).toEqual('00:00 h.');
2019-06-04 05:57:01 +00:00
});
});