/* eslint max-len: ["error", { "code": 150 }]*/ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; 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'); }); afterAll(async() => { await browser.close(); }); const eightAm = '08:00'; const fourPm = '16:00'; const hankPymId = 1107; it('should go to the next month', async() => { const date = new Date(); date.setMonth(date.getMonth() + 1); const month = date.toLocaleString('default', {month: 'long'}); await page.waitToClick(selectors.workerTimeControl.nextMonthButton); const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText'); expect(result).toContain(month); }); it('should go to current month', async() => { const date = new Date(); const month = date.toLocaleString('default', {month: 'long'}); await page.waitToClick(selectors.workerTimeControl.previousMonthButton); const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText'); expect(result).toContain(month); }); it('should go 1 month in the past', async() => { const date = new Date(); date.setMonth(date.getMonth() - 1); const timestamp = Math.round(date.getTime() / 1000); const month = date.toLocaleString('default', {month: 'long'}); await page.loginAndModule('salesBoss', 'worker'); await page.goto(`http://localhost:5000/#!/worker/${hankPymId}/time-control?timestamp=${timestamp}`); await page.waitToClick(selectors.workerTimeControl.secondWeekDay); const result = await page.waitToGetProperty(selectors.workerTimeControl.monthName, 'innerText'); expect(result).toContain(month); }); xit(`should return error when insert 'out' of first entry`, async() => { await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm); await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); await page.respondToDialog('accept'); const message = await page.waitForSnackbar(); expect(message.text).toBeDefined(); }); xit(`should insert 'in' monday`, async() => { await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); await page.pickTime(selectors.workerTimeControl.dialogTimeInput, eightAm); await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'in'); await page.respondToDialog('accept'); const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText'); expect(result).toEqual(eightAm); }); xit(`should insert 'out' monday`, async() => { await page.waitToClick(selectors.workerTimeControl.mondayAddTimeButton); await page.pickTime(selectors.workerTimeControl.dialogTimeInput, fourPm); await page.autocompleteSearch(selectors.workerTimeControl.dialogTimeDirection, 'out'); await page.respondToDialog('accept'); const result = await page.waitToGetProperty(selectors.workerTimeControl.secondEntryOfMonday, 'innerText'); expect(result).toEqual(fourPm); }); xit(`should check Hank Pym worked 8:20 hours`, async() => { await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '08:20 h.'); await page.waitForTextInElement(selectors.workerTimeControl.weekWorkedHours, '08:20 h.'); }); xit('should remove first entry of monday', async() => { await page.waitForTextInElement(selectors.workerTimeControl.firstEntryOfMonday, eightAm); await page.waitForTextInElement(selectors.workerTimeControl.secondEntryOfMonday, fourPm); await page.waitToClick(selectors.workerTimeControl.firstEntryOfMondayDelete); await page.respondToDialog('accept'); const message = await page.waitForSnackbar(); expect(message.text).toContain('Entry removed'); }); xit(`should be the 'out' the first entry of monday`, async() => { const result = await page.waitToGetProperty(selectors.workerTimeControl.firstEntryOfMonday, 'innerText'); expect(result).toEqual(fourPm); }); it('should change week of month', async() => { await page.waitToClick(selectors.workerTimeControl.thrirdWeekDay); await page.waitForTextInElement(selectors.workerTimeControl.mondayWorkedHours, '00:00 h.'); }); });