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

123 lines
5.1 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: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
2022-12-28 12:06:00 +00:00
await page.click(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
2022-12-28 12:06:00 +00:00
await page.click(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}`);
2022-12-28 12:06:00 +00:00
await page.click(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 return error when insert 'out' of first entry`, async() => {
pending('https://redmine.verdnatura.es/issues/4707');
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
await page.respondToDialog('accept');
2023-01-03 08:14:25 +00:00
const message = await page.waitForSnackbar();
2019-06-04 05:57:01 +00:00
expect(message.text).toBeDefined();
2023-01-03 08:14:25 +00:00
});
2019-06-04 05:57:01 +00:00
2023-01-03 08:14:25 +00:00
it(`should insert 'in' monday`, async() => {
pending('https://redmine.verdnatura.es/issues/4707');
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm);
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in');
await page.respondToDialog('accept');
2023-01-03 08:14:25 +00:00
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
2019-06-04 05:57:01 +00:00
2023-01-03 08:14:25 +00:00
expect(result).toEqual(eightAm);
});
2019-06-04 05:57:01 +00:00
2023-01-03 08:14:25 +00:00
it(`should insert 'out' monday`, async() => {
pending('https://redmine.verdnatura.es/issues/4707');
await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton);
await page.pickTime(selectors.workerTimeControl.dialogTimeInput, fourPm);
await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out');
await page.respondToDialog('accept');
2023-01-03 08:14:25 +00:00
const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText');
2019-06-04 05:57:01 +00:00
2023-01-03 08:14:25 +00:00
expect(result).toEqual(fourPm);
});
it(`should check Hank Pym worked 8:20 hours`, async() => {
pending('https://redmine.verdnatura.es/issues/4707');
await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '08:20 h.');
await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '08:20 h.');
});
2019-06-04 05:57:01 +00:00
2023-01-03 08:14:25 +00:00
it('should remove first entry of monday', async() => {
pending('https://redmine.verdnatura.es/issues/4707');
await page.waitForTextInElement(selectors.workerTimeControl.firstEntryOfMonday, eightAm);
await page.waitForTextInElement(selectors.workerTimeControl.secondEntryOfMonday, fourPm);
await page.waitToClick(selectors.workerTimeControl.firstEntryOfMondayDelete);
await page.respondToDialog('accept');
2023-01-03 08:14:25 +00:00
const message = await page.waitForSnackbar();
2019-06-04 05:57:01 +00:00
expect(message.text).toContain('Entry removed');
2023-01-03 08:14:25 +00:00
});
2023-01-03 08:14:25 +00:00
it(`should be the 'out' the first entry of monday`, async() => {
pending('https://redmine.verdnatura.es/issues/4707');
const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText');
2019-06-04 05:57:01 +00:00
expect(result).toEqual(fourPm);
2023-01-03 08:14:25 +00:00
});
2019-06-04 05:57:01 +00:00
2023-01-03 08:14:25 +00:00
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
});
});