2022-06-23 12:07:53 +00:00
|
|
|
/* eslint max-len: ["error", { "code": 150 }]*/
|
2019-06-04 05:57:01 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2020-01-14 08:24:09 +00:00
|
|
|
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', () => {
|
2020-01-14 08:24:09 +00:00
|
|
|
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
|
|
|
|
2020-01-14 08:24:09 +00:00
|
|
|
afterAll(async() => {
|
2020-01-14 08:41:49 +00:00
|
|
|
await browser.close();
|
2019-06-04 05:57:01 +00:00
|
|
|
});
|
|
|
|
|
2022-06-28 10:10:37 +00:00
|
|
|
const eightAm = '08:00';
|
2022-06-23 12:07:53 +00: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);
|
2022-06-23 12:07:53 +00:00
|
|
|
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');
|
2020-01-14 08:24:09 +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);
|
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);
|
2022-06-23 12:07:53 +00:00
|
|
|
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'});
|
|
|
|
|
2022-06-23 12:07:53 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|