import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/helpers'; describe('Client', () => { describe('invoice path', () => { const nightmare = createNightmare(); beforeAll(() => { return nightmare .waitForLogin('developer'); }); it('should click on the Clients button of the top bar menu', () => { return nightmare .waitToClick(selectors.globalItems.applicationsMenuButton) .wait(selectors.globalItems.applicationsMenuVisible) .waitToClick(selectors.globalItems.clientsButton) .wait(selectors.clientsIndex.createClientButton) .parsedUrl() .then(url => { expect(url.hash).toEqual('#!/clients'); }); }); it('should search for the user Petter Parker', () => { return nightmare .wait(selectors.clientsIndex.searchResult) .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') .click(selectors.clientsIndex.searchButton) .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) .countSearchResults(selectors.clientsIndex.searchResult) .then(result => { expect(result).toEqual(1); }); }); it(`should click on the search result to access to the client invoices`, () => { return nightmare .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter') .waitToClick(selectors.clientsIndex.searchResult) .waitToClick(selectors.clientInvoices.invoicesButton) .waitForURL('invoices') .parsedUrl() .then(url => { expect(url.hash).toContain('invoices'); }); }); it('should confirm the client has an invoice', () => { return nightmare .wait(selectors.clientInvoices.firstInvoiceText) .getInnerText(selectors.clientInvoices.firstInvoiceText) .then(value => { expect(value).toContain('V2800001'); expect(value).toContain('350.50'); }); }); }); });