2022-12-28 12:06:00 +00:00
/* eslint-disable max-len */
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' , ( ) => {
2022-12-28 12:06:00 +00:00
const reasonableTimeBetweenClicks = 300 ;
2023-01-16 14:18:24 +00:00
const date = Date . vnNew ( ) ;
2022-12-28 12:06:00 +00:00
const lastYear = ( date . getFullYear ( ) - 1 ) . toString ( ) ;
2020-08-14 07:23:23 +00:00
let browser ;
let page ;
2022-12-28 12:06:00 +00:00
async function accessAs ( user ) {
await page . loginAndModule ( user , 'worker' ) ;
await page . accessToSearchResult ( 'Charles Xavier' ) ;
await page . accessToSection ( 'worker.card.calendar' ) ;
}
2020-08-14 07:23:23 +00:00
beforeAll ( async ( ) => {
browser = await getBrowser ( ) ;
page = browser . page ;
2022-12-28 12:06:00 +00:00
accessAs ( 'hr' ) ;
2020-08-14 07:23:23 +00:00
} ) ;
afterAll ( async ( ) => {
await browser . close ( ) ;
} ) ;
describe ( 'as hr' , ( ) => {
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-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . penultimateMondayOfJanuary ) ;
2020-08-14 07:23:23 +00:00
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . absence ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . lastMondayOfMarch ) ;
2020-08-14 07:23:23 +00:00
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . halfHoliday ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . fistMondayOfMay ) ;
2020-08-14 07:23:23 +00:00
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . furlough ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . secondTuesdayOfMay ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . secondWednesdayOfMay ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . secondThursdayOfMay ) ;
2020-08-14 07:23:23 +00:00
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . halfFurlough ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . secondFridayOfJun ) ;
2020-08-14 07:23:23 +00:00
2022-12-28 12:06:00 +00:00
expect ( await page . getProperty ( selectors . workerCalendar . totalHolidaysUsed , 'innerText' ) ) . toContain ( ' 1.5 ' ) ;
2020-08-14 07:23:23 +00:00
} ) ;
} ) ;
2020-08-14 09:57:16 +00:00
describe ( ` as salesBoss ` , ( ) => {
2022-12-28 12:06:00 +00:00
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' ) ;
2020-08-14 07:23:23 +00:00
await page . waitToClick ( selectors . workerCalendar . holidays ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2021-01-18 18:11:29 +00:00
await page . waitToClick ( selectors . workerCalendar . penultimateMondayOfJanuary ) ;
2020-08-14 07:23:23 +00:00
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2020-08-14 07:23:23 +00:00
await page . waitToClick ( selectors . workerCalendar . absence ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2021-01-18 18:11:29 +00:00
await page . waitToClick ( selectors . workerCalendar . lastMondayOfMarch ) ;
2020-08-14 07:23:23 +00:00
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2020-08-14 07:23:23 +00:00
await page . waitToClick ( selectors . workerCalendar . halfHoliday ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2021-01-18 18:11:29 +00:00
await page . waitToClick ( selectors . workerCalendar . fistMondayOfMay ) ;
2020-08-14 07:23:23 +00:00
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2020-08-14 07:23:23 +00:00
await page . waitToClick ( selectors . workerCalendar . furlough ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2021-01-18 18:11:29 +00:00
await page . waitToClick ( selectors . workerCalendar . secondTuesdayOfMay ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2021-01-18 18:11:29 +00:00
await page . waitToClick ( selectors . workerCalendar . secondWednesdayOfMay ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2021-01-18 18:11:29 +00:00
await page . waitToClick ( selectors . workerCalendar . secondThursdayOfMay ) ;
2020-08-14 07:23:23 +00:00
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2020-08-14 07:23:23 +00:00
await page . waitToClick ( selectors . workerCalendar . halfFurlough ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2021-01-19 09:53:37 +00:00
await page . waitToClick ( selectors . workerCalendar . secondFridayOfJun ) ;
2020-08-14 07:23:23 +00:00
2022-12-28 12:06:00 +00:00
expect ( await page . getProperty ( selectors . workerCalendar . totalHolidaysUsed , 'innerText' ) ) . toContain ( ' 0 ' ) ;
2020-08-14 07:23:23 +00:00
} ) ;
} ) ;
2022-03-15 14:11:58 +00:00
describe ( ` as Charles Xavier ` , ( ) => {
2022-12-28 12:06:00 +00:00
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' ) ;
2020-08-14 07:23:23 +00:00
await page . waitToClick ( selectors . workerCalendar . holidays ) ;
2020-11-23 17:28:39 +00:00
await page . waitForTimeout ( reasonableTimeBetweenClicks ) ;
2020-08-14 07:23:23 +00:00
2022-12-28 12:06:00 +00:00
await page . click ( selectors . workerCalendar . penultimateMondayOfJanuary ) ;
2020-08-14 07:23:23 +00:00
2022-12-28 12:06:00 +00:00
expect ( await page . getProperty ( selectors . workerCalendar . totalHolidaysUsed , 'innerText' ) ) . toContain ( ' 0 ' ) ;
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
2022-12-28 12:06:00 +00:00
expect ( await page . getProperty ( selectors . workerCalendar . totalHolidaysUsed , 'innerText' ) ) . toContain ( ' 0 ' ) ;
2020-08-18 11:55:38 +00:00
} ) ;
2020-08-14 07:23:23 +00:00
} ) ;
} ) ;