115 lines
5.5 KiB
JavaScript
115 lines
5.5 KiB
JavaScript
/* eslint-disable max-len */
|
|
import selectors from '../../helpers/selectors.js';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Worker calendar path', () => {
|
|
const reasonableTimeBetweenClicks = 300;
|
|
const date = Date.vnNew();
|
|
const lastYear = (date.getFullYear() - 1).toString();
|
|
|
|
let browser;
|
|
let page;
|
|
|
|
async function accessAs(user) {
|
|
await page.loginAndModule(user, 'worker');
|
|
await page.accessToSearchResult('Charles Xavier');
|
|
await page.accessToSection('worker.card.calendar');
|
|
}
|
|
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
accessAs('hr');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
describe('as hr', () => {
|
|
it('should set two days as holidays on the calendar and check the total holidays increased by 1.5', async() => {
|
|
await page.waitToClick(selectors.workerCalendar.holidays);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.penultimateMondayOfJanuary);
|
|
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.absence);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.lastMondayOfMarch);
|
|
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.halfHoliday);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.fistMondayOfMay);
|
|
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.furlough);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.secondTuesdayOfMay);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.secondWednesdayOfMay);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.secondThursdayOfMay);
|
|
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.halfFurlough);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.click(selectors.workerCalendar.secondFridayOfJun);
|
|
|
|
expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 1.5 ');
|
|
});
|
|
});
|
|
|
|
describe(`as salesBoss`, () => {
|
|
it(`should log in, get to Charles Xavier's calendar, undo what was done here, and check the total holidays used are back to what it was`, async() => {
|
|
accessAs('salesBoss');
|
|
|
|
await page.waitToClick(selectors.workerCalendar.holidays);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.penultimateMondayOfJanuary);
|
|
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.absence);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.lastMondayOfMarch);
|
|
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.halfHoliday);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.fistMondayOfMay);
|
|
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.furlough);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.secondTuesdayOfMay);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.secondWednesdayOfMay);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.secondThursdayOfMay);
|
|
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.halfFurlough);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
await page.waitToClick(selectors.workerCalendar.secondFridayOfJun);
|
|
|
|
expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 0 ');
|
|
});
|
|
});
|
|
|
|
describe(`as Charles Xavier`, () => {
|
|
it('should log in and get to his calendar, make a futile attempt to add holidays, check the total holidays used are now the initial ones and use the year selector to go to the previous year', async() => {
|
|
accessAs('CharlesXavier');
|
|
await page.waitToClick(selectors.workerCalendar.holidays);
|
|
await page.waitForTimeout(reasonableTimeBetweenClicks);
|
|
|
|
await page.click(selectors.workerCalendar.penultimateMondayOfJanuary);
|
|
|
|
expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 0 ');
|
|
|
|
await page.autocompleteSearch(selectors.workerCalendar.year, lastYear);
|
|
|
|
expect(await page.getProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText')).toContain(' 0 ');
|
|
});
|
|
});
|
|
});
|