import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; // #2390-calendar_date_filter e2e xdescribe('Worker calendar path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('hr', 'worker'); await page.accessToSearchResult('coolerNick'); await page.accessToSection('worker.card.calendar'); }); afterAll(async() => { await browser.close(); }); describe('as hr', () => { it('should check 0 total holidays have been used so far', async() => { const result = await page.waitToGetProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText'); expect(result).toContain(' 0 '); }); it('should set two days as holidays on the calendar', async() => { await page.waitToClick(selectors.workerCalendar.holidays); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.januaryThirtyFirst); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.absence); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.marchTwentyThird); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.halfHoliday); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.mayFourth); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.furlough); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.mayTwelfth); await page.waitToClick(selectors.workerCalendar.mayThirteenth); await page.waitToClick(selectors.workerCalendar.mayFourteenth); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.halfFurlough); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.mayEighth); }); it('should check the total holidays used now has 1.5 more days', async() => { const result = await page.waitToGetProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText'); expect(result).toContain(' 1.5 '); }); }); describe(`as cool boss`, () => { it(`should log in and get to cool's calendar`, async() => { await page.loginAndModule('coolerBoss', 'worker'); await page.accessToSearchResult('coolerNick'); await page.accessToSection('worker.card.calendar'); }); it('should undo what was done here', async() => { await page.waitFor(4000); await page.waitToClick(selectors.workerCalendar.holidays); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.januaryThirtyFirst); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.absence); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.marchTwentyThird); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.halfHoliday); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.mayFourth); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.furlough); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.mayTwelfth); await page.waitToClick(selectors.workerCalendar.mayThirteenth); await page.waitToClick(selectors.workerCalendar.mayFourteenth); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.halfFurlough); await page.waitFor(400); 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'); expect(result).toContain(' 0 '); }); }); describe(`as cooler`, () => { it(`should log in and get to his calendar`, async() => { await page.loginAndModule('cooler', 'worker'); await page.accessToSearchResult('coolerNick'); await page.accessToSection('worker.card.calendar'); }); it('should make a futile attempt to add holidays', async() => { await page.waitFor(4000); await page.waitToClick(selectors.workerCalendar.holidays); await page.waitFor(400); await page.waitToClick(selectors.workerCalendar.januaryThirtyFirst); }); it('should check the total holidays used remain the same', async() => { const result = await page.waitToGetProperty(selectors.workerCalendar.totalHolidaysUsed, 'innerText'); expect(result).toContain(' 0 '); }); it('should use the year selector yo go to the previous year', async() => { const date = new Date(); const lastYear = (date.getFullYear() - 1).toString(); await page.autocompleteSearch(selectors.workerCalendar.year, lastYear); expect(result).toContain(' 0 '); }); }); });