diff --git a/e2e/paths/client-module/12_lock_of_verified_data.spec.js b/e2e/paths/client-module/12_lock_of_verified_data.spec.js index eaff804ed..1db1ca112 100644 --- a/e2e/paths/client-module/12_lock_of_verified_data.spec.js +++ b/e2e/paths/client-module/12_lock_of_verified_data.spec.js @@ -7,478 +7,408 @@ describe('Client lock verified data path', () => { describe('as salesPerson', () => { beforeAll(() => { return nightmare - .waitForLogin('salesPerson'); + .waitForLogin('salesPerson'); }); - it('should click on the Clients button of the top bar menu', done => { - 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('#!/client/index'); - done(); - }).catch(done.fail); + it('should click on the Clients button of the top bar menu', async () => { + const 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 Petter Parker', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + it('should search for the user Petter Parker', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') + .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`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the search result to access to the client's fiscal data`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it(`should click on the fiscal data button to start editing`, done => { - return nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the fiscal data button to start editing`, async () => { + const url = await nightmare + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it('should confirm verified data button is disabled for salesPerson', done => { - return nightmare - .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) - .evaluate(selector => { - return document.querySelector(selector).disabled; - }, selectors.clientFiscalData.verifiedDataCheckbox) - .then(result => { - expect(result).toBeTruthy(); - done(); - }).catch(done.fail); + it('should confirm verified data button is disabled for salesPerson', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) + .evaluate((selector) => { + return document.querySelector(selector).disabled; + }, selectors.clientFiscalData.verifiedDataCheckbox); + + expect(result).toBeTruthy(); }); - it('should edit the social name', done => { - return nightmare - .wait(selectors.clientFiscalData.socialNameInput) - .clearInput(selectors.clientFiscalData.socialNameInput) - .type(selectors.clientFiscalData.socialNameInput, 'salesPerson was here') - .click(selectors.clientFiscalData.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it('should edit the social name', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.socialNameInput) + .clearInput(selectors.clientFiscalData.socialNameInput) + .type(selectors.clientFiscalData.socialNameInput, 'salesPerson was here') + .click(selectors.clientFiscalData.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should confirm the social name have been edited', done => { - return nightmare - .waitToClick(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .wait(selectors.clientFiscalData.socialNameInput) - .getInputValue(selectors.clientFiscalData.socialNameInput) - .then(result => { - expect(result).toEqual('salesPerson was here'); - done(); - }).catch(done.fail); + it('should confirm the social name have been edited', async () => { + const result = await nightmare + .waitToClick(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .wait(selectors.clientFiscalData.socialNameInput) + .getInputValue(selectors.clientFiscalData.socialNameInput); + + expect(result).toEqual('salesPerson was here'); }); }); describe('as administrative', () => { beforeAll(() => { return nightmare - .waitToClick(selectors.globalItems.logOutButton) - .waitForLogin('administrative'); + .waitToClick(selectors.globalItems.logOutButton) + .waitForLogin('administrative'); }); - it('should navigate to clients index', done => { - 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('#!/client/index'); - done(); - }).catch(done.fail); + it('should navigate to clients index', async () => { + const 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 again for the user Petter Parker', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + it('should search again for the user Petter Parker', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') + .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 Petter Parkers fiscal data`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the search result to access to the Petter Parkers fiscal data`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it(`should click on the fiscal data button`, done => { - return nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the fiscal data button`, async () => { + const url = await nightmare + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it('should confirm verified data button is enabled for administrative', done => { - return nightmare - .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) - .evaluate(selector => { - return document.querySelector(selector).disabled; - }, selectors.clientFiscalData.verifiedDataCheckbox) - .then(result => { - expect(result).not.toBeTruthy(); - done(); - }).catch(done.fail); + it('should confirm verified data button is enabled for administrative', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) + .evaluate((selector) => { + return document.querySelector(selector).disabled; + }, selectors.clientFiscalData.verifiedDataCheckbox); + + expect(result).not.toBeTruthy(); }); - it('should check the Verified data checkbox', done => { - return nightmare - .waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput) - .waitToClick(selectors.clientFiscalData.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it('should check the Verified data checkbox', async () => { + const result = await nightmare + .waitToClick(selectors.clientFiscalData.verifiedDataCheckboxInput) + .waitToClick(selectors.clientFiscalData.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should confirm Verified data checkbox is checked', done => { - return nightmare - .waitToClick(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) - .evaluate(selector => { - return document.querySelector(selector).checked; - }, selectors.clientFiscalData.verifiedDataCheckboxInput) - .then(value => { - expect(value).toBeTruthy(); - done(); - }).catch(done.fail); + it('should confirm Verified data checkbox is checked', async () => { + const result = await nightmare + .waitToClick(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) + .evaluate((selector) => { + return document.querySelector(selector).checked; + }, selectors.clientFiscalData.verifiedDataCheckboxInput); + + expect(result).toBeTruthy(); }); - it('should again edit the social name', done => { - return nightmare - .wait(selectors.clientFiscalData.socialNameInput) - .clearInput(selectors.clientFiscalData.socialNameInput) - .type(selectors.clientFiscalData.socialNameInput, 'administrative was here') - .click(selectors.clientFiscalData.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it('should again edit the social name', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.socialNameInput) + .clearInput(selectors.clientFiscalData.socialNameInput) + .type(selectors.clientFiscalData.socialNameInput, 'administrative was here') + .click(selectors.clientFiscalData.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should again confirm the social name have been edited', done => { - return nightmare - .waitToClick(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .wait(selectors.clientFiscalData.socialNameInput) - .getInputValue(selectors.clientFiscalData.socialNameInput) - .then(result => { - expect(result).toEqual('administrative was here'); - done(); - }).catch(done.fail); + it('should again confirm the social name have been edited', async () => { + const result = await nightmare + .waitToClick(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .wait(selectors.clientFiscalData.socialNameInput) + .getInputValue(selectors.clientFiscalData.socialNameInput); + + expect(result).toEqual('administrative was here'); }); }); describe('as salesPerson second run', () => { beforeAll(() => { return nightmare - .waitToClick(selectors.globalItems.logOutButton) - .waitForLogin('salesPerson'); + .waitToClick(selectors.globalItems.logOutButton) + .waitForLogin('salesPerson'); }); - it('should again click on the Clients button of the top bar menu', done => { - 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('#!/client/index'); - done(); - }).catch(done.fail); + it('should again click on the Clients button of the top bar menu', async () => { + const 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 again search for the user Petter Parker', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + it('should again search for the user Petter Parker', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') + .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`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the search result to access to the client's fiscal data`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it(`should click on the fiscal data button to start editing`, done => { - return nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the fiscal data button to start editing`, async () => { + const url = await nightmare + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it('should confirm verified data button is disabled once again for salesPerson', done => { - return nightmare - .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) - .evaluate(selector => { - return document.querySelector(selector).disabled; - }, selectors.clientFiscalData.verifiedDataCheckbox) - .then(result => { - expect(result).toBe(true); - done(); - }).catch(done.fail); + it('should confirm verified data button is disabled once again for salesPerson', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) + .evaluate((selector) => { + return document.querySelector(selector).disabled; + }, selectors.clientFiscalData.verifiedDataCheckbox); + + expect(result).toBe(true); }); - it('should not be able to save change throwing a verified data error', done => { - return nightmare - .wait(selectors.clientFiscalData.socialNameInput) - .clearInput(selectors.clientFiscalData.socialNameInput) - .type(selectors.clientFiscalData.socialNameInput, 'salesPerson was here') - .click(selectors.clientFiscalData.saveButton) - .waitForSnackbar() - .then(result => { - expect(result).toEqual(jasmine.arrayContaining([`You can't make changes on a client with verified data`])); - done(); - }).catch(done.fail); + it('should not be able to save change throwing a verified data error', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.socialNameInput) + .clearInput(selectors.clientFiscalData.socialNameInput) + .type(selectors.clientFiscalData.socialNameInput, 'salesPerson was here') + .click(selectors.clientFiscalData.saveButton) + .waitForSnackbar(); + + expect(result).toEqual(jasmine.arrayContaining([`You can't make changes on a client with verified data`])); }); }); describe('as salesAssistant', () => { beforeAll(() => { return nightmare - .waitToClick(selectors.globalItems.logOutButton) - .waitForLogin('salesAssistant'); + .waitToClick(selectors.globalItems.logOutButton) + .waitForLogin('salesAssistant'); }); - it('should now navigate to clients index', done => { - 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('#!/client/index'); - done(); - }).catch(done.fail); + it('should now navigate to clients index', async () => { + const 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 now search again for the user Petter Parker', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + it('should now search again for the user Petter Parker', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') + .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 Petter Parkers fiscal data`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the search result to access to the Petter Parkers fiscal data`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it(`should click on the fiscal data button`, done => { - return nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the fiscal data button`, async () => { + const url = await nightmare + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it('should confirm verified data button is disabled for salesAssistant', done => { - return nightmare - .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) - .evaluate(selector => { - return document.querySelector(selector).disabled; - }, selectors.clientFiscalData.verifiedDataCheckbox) - .then(result => { - expect(result).toBeTruthy(); - done(); - }).catch(done.fail); + it('should confirm verified data button is disabled for salesAssistant', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) + .evaluate((selector) => { + return document.querySelector(selector).disabled; + }, selectors.clientFiscalData.verifiedDataCheckbox); + + expect(result).toBeTruthy(); }); - it('should now edit the social name', done => { - return nightmare - .wait(selectors.clientFiscalData.socialNameInput) - .clearInput(selectors.clientFiscalData.socialNameInput) - .type(selectors.clientFiscalData.socialNameInput, 'salesAssistant was here') - .click(selectors.clientFiscalData.saveButton) - .waitForLastSnackbar() - .then(result => { - expect(result).toEqual('Data saved!'); - done(); - }).catch(done.fail); + it('should now edit the social name', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.socialNameInput) + .clearInput(selectors.clientFiscalData.socialNameInput) + .type(selectors.clientFiscalData.socialNameInput, 'salesAssistant was here') + .click(selectors.clientFiscalData.saveButton) + .waitForLastSnackbar(); + + expect(result).toEqual('Data saved!'); }); - it('should now confirm the social name have been edited once and for all', done => { - return nightmare - .waitToClick(selectors.clientBasicData.basicDataButton) - .wait(selectors.clientBasicData.nameInput) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .wait(selectors.clientFiscalData.socialNameInput) - .getInputValue(selectors.clientFiscalData.socialNameInput) - .then(result => { - expect(result).toEqual('salesAssistant was here'); - done(); - }).catch(done.fail); + it('should now confirm the social name have been edited once and for all', async () => { + const result = await nightmare + .waitToClick(selectors.clientBasicData.basicDataButton) + .wait(selectors.clientBasicData.nameInput) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .wait(selectors.clientFiscalData.socialNameInput) + .getInputValue(selectors.clientFiscalData.socialNameInput); + + expect(result).toEqual('salesAssistant was here'); }); }); describe('as salesPerson third run', () => { beforeAll(() => { return nightmare - .waitToClick(selectors.globalItems.logOutButton) - .waitForLogin('salesPerson'); + .waitToClick(selectors.globalItems.logOutButton) + .waitForLogin('salesPerson'); }); - it('should now click on the Clients button of the top bar menu', done => { - 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('#!/client/index'); - done(); - }).catch(done.fail); + it('should now click on the Clients button of the top bar menu', async () => { + const 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 once again search for the user Petter Parker', done => { - return nightmare - .wait(selectors.clientsIndex.searchResult) - .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') - .click(selectors.clientsIndex.searchButton) - .waitForNumberOfElements(selectors.clientsIndex.searchResult, 1) - .countElement(selectors.clientsIndex.searchResult) - .then(result => { - expect(result).toEqual(1); - done(); - }).catch(done.fail); + it('should once again search for the user Petter Parker', async () => { + const resultCount = await nightmare + .wait(selectors.clientsIndex.searchResult) + .type(selectors.clientsIndex.searchClientInput, 'Petter Parker') + .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`, done => { - return nightmare - .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') - .waitToClick(selectors.clientsIndex.searchResult) - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the search result to access to the client's fiscal data`, async () => { + const url = await nightmare + .waitForTextInElement(selectors.clientsIndex.searchResult, 'Petter Parker') + .waitToClick(selectors.clientsIndex.searchResult) + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it(`should click on the fiscal data button to start editing`, done => { - return nightmare - .waitToClick(selectors.clientFiscalData.fiscalDataButton) - .waitForURL('fiscal-data') - .parsedUrl() - .then(url => { - expect(url.hash).toContain('fiscal-data'); - done(); - }).catch(done.fail); + it(`should click on the fiscal data button to start editing`, async () => { + const url = await nightmare + .waitToClick(selectors.clientFiscalData.fiscalDataButton) + .waitForURL('fiscal-data') + .parsedUrl(); + + expect(url.hash).toContain('fiscal-data'); }); - it('should confirm verified data button is enabled once again', done => { - return nightmare - .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) - .evaluate(selector => { - return document.querySelector(selector).disabled; - }, selectors.clientFiscalData.verifiedDataCheckbox) - .then(result => { - expect(result).toBe(true); - done(); - }).catch(done.fail); + it('should confirm verified data button is enabled once again', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.verifiedDataCheckboxInput) + .evaluate((selector) => { + return document.querySelector(selector).disabled; + }, selectors.clientFiscalData.verifiedDataCheckbox); + + expect(result).toBe(true); }); - it('should confirm the form is enabled for salesPerson', done => { - return nightmare - .wait(selectors.clientFiscalData.socialNameInput) - .evaluate(selector => { - return document.querySelector(selector).disabled; - }, 'vn-textfield[field="$ctrl.client.socialName"] > div') - .then(result => { - expect(result).not.toBe(true); - done(); - }).catch(done.fail); + it('should confirm the form is enabled for salesPerson', async () => { + const result = await nightmare + .wait(selectors.clientFiscalData.socialNameInput) + .evaluate((selector) => { + return document.querySelector(selector).disabled; + }, 'vn-textfield[field="$ctrl.client.socialName"] > div'); + + expect(result).not.toBe(true); }); }); });