2020-08-14 07:23:23 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
|
2020-08-18 11:57:34 +00:00
|
|
|
describe('Worker calendar path', () => {
|
2020-08-14 10:02:27 +00:00
|
|
|
let reasonableTimeBetweenClicks = 400;
|
2020-08-14 07:23:23 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('hr', 'worker');
|
2020-08-14 09:57:16 +00:00
|
|
|
await page.accessToSearchResult('Hank Pym');
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.accessToSection('worker.card.calendar');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('as hr', () => {
|
2020-08-14 09:57:16 +00:00
|
|
|
it('should check 5 total holidays have been used so far before testing anything', async() => {
|
2020-08-14 07:23:23 +00:00
|
|
|
const result = await page.waitToGetProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText');
|
|
|
|
|
2020-08-14 09:57:16 +00:00
|
|
|
expect(result).toContain(' 5 ');
|
2020-08-14 07:23:23 +00:00
|
|
|
});
|
|
|
|
|
2020-10-21 08:13:04 +00:00
|
|
|
it('should set two days as holidays on the calendar and check the total holidays increased by 1.5', async() => {
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.holidays);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.januaryThirtyFirst);
|
|
|
|
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.absence);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.marchTwentyThird);
|
|
|
|
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.halfHoliday);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayFourth);
|
|
|
|
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.furlough);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayTwelfth);
|
2020-11-12 15:52:42 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayThirteenth);
|
2020-11-12 15:52:42 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayFourteenth);
|
|
|
|
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.halfFurlough);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayEighth);
|
2020-10-20 15:36:02 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
|
|
|
|
const result = await page.waitToGetProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText');
|
|
|
|
|
2020-08-14 09:57:16 +00:00
|
|
|
expect(result).toContain(' 6.5 ');
|
2020-08-14 07:23:23 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-08-14 09:57:16 +00:00
|
|
|
describe(`as salesBoss`, () => {
|
|
|
|
it(`should log in and get to Hank's calendar`, async() => {
|
|
|
|
await page.loginAndModule('salesBoss', 'worker');
|
|
|
|
await page.accessToSearchResult('Hank Pym');
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.accessToSection('worker.card.calendar');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should undo what was done here', async() => {
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.holidays);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.januaryThirtyFirst);
|
|
|
|
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.absence);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.marchTwentyThird);
|
|
|
|
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.halfHoliday);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayFourth);
|
|
|
|
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.furlough);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayTwelfth);
|
2020-11-12 15:52:42 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayThirteenth);
|
2020-11-12 15:52:42 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayFourteenth);
|
|
|
|
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.halfFurlough);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.mayEighth);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should check the total holidays used are back to what it was', async() => {
|
|
|
|
const result = await page.waitToGetProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText');
|
|
|
|
|
2020-08-14 09:57:16 +00:00
|
|
|
expect(result).toContain(' 5 ');
|
2020-08-14 07:23:23 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-08-14 09:57:16 +00:00
|
|
|
describe(`as Hank`, () => {
|
2020-08-14 07:23:23 +00:00
|
|
|
it(`should log in and get to his calendar`, async() => {
|
2020-08-14 09:57:16 +00:00
|
|
|
await page.loginAndModule('HankPym', 'worker');
|
|
|
|
await page.accessToSearchResult('Hank Pym');
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.accessToSection('worker.card.calendar');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should make a futile attempt to add holidays', async() => {
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.holidays);
|
2020-08-14 10:02:27 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
2020-08-14 07:23:23 +00:00
|
|
|
await page.waitToClick(selectors.workerCalendar.januaryThirtyFirst);
|
|
|
|
});
|
|
|
|
|
2020-08-14 09:57:16 +00:00
|
|
|
it('should check the total holidays used are now the initial ones', async() => {
|
2020-08-14 07:23:23 +00:00
|
|
|
const result = await page.waitToGetProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText');
|
|
|
|
|
2020-08-14 09:57:16 +00:00
|
|
|
expect(result).toContain(' 5 ');
|
2020-08-14 07:23:23 +00:00
|
|
|
});
|
|
|
|
|
2020-08-18 11:55:38 +00:00
|
|
|
it('should use the year selector to go to the previous year', async() => {
|
|
|
|
const date = new Date();
|
|
|
|
const lastYear = (date.getFullYear() - 1).toString();
|
2020-08-14 07:23:23 +00:00
|
|
|
|
2020-08-18 11:55:38 +00:00
|
|
|
await page.autocompleteSearch(selectors.workerCalendar.year, lastYear);
|
2020-08-14 07:23:23 +00:00
|
|
|
|
2020-08-18 11:55:38 +00:00
|
|
|
await page.waitFor(reasonableTimeBetweenClicks);
|
|
|
|
const result = await page.waitToGetProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText');
|
2020-08-14 09:57:16 +00:00
|
|
|
|
2020-08-18 11:55:38 +00:00
|
|
|
expect(result).toContain(' 0 ');
|
|
|
|
});
|
2020-08-14 07:23:23 +00:00
|
|
|
});
|
|
|
|
});
|