import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Client log path', () => { const nightmare = createNightmare(); beforeAll(() => { return nightmare .waitForLogin('employee'); }); it('should click on the Clients button of the top bar menu', async () => { let url = await nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) .parsedUrl(); expect(url.hash).toEqual('#!/client/index'); }); it('should search for the user David Charles Haller', async () => { let resultCount = await nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'DavidCharlesHaller') .click(selectors.clientsIndex.searchButton) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .countElement(selectors.clientsIndex.searchResult); expect(resultCount).toEqual(1); }); it(`should click on the search result to access to the client's fiscal data`, async () => { let url = await nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'DavidCharlesHaller') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientBasicData.basicDataButton) .waitForURL('basic-data') .parsedUrl(); expect(url.hash).toContain('basic-data'); }); it('should update the clients name', async () => { let result = await nightmare .wait(selectors.clientBasicData.nameInput) .clearInput(selectors.clientBasicData.nameInput) .type(selectors.clientBasicData.nameInput, 'this is a test') .waitToClick(selectors.clientBasicData.saveButton) .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should navigate to the log section', async () => { let url = await nightmare .waitToClick(selectors.clientLog.logButton) .waitForURL('log') .parsedUrl(); expect(url.hash).toContain('log'); }); it('should check the previous value of the last logged change', async () => { let lastModificationPreviousValue = await nightmare .getInnerText(selectors.clientLog.lastModificationPreviousValue); expect(lastModificationPreviousValue).toContain('DavidCharlesHaller'); }); it('should check the current value of the last logged change', async () => { let lastModificationCurrentValue = await nightmare .getInnerText(selectors.clientLog.lastModificationCurrentValue); expect(lastModificationCurrentValue).toContain('this is a test'); }); });