diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index f34491ba3..52e359687 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -912,5 +912,16 @@ export default { alias: 'vn-supplier-descriptor vn-label-value[label="Alias"]', clientButton: 'vn-supplier-descriptor vn-icon[icon="person"]', entriesButton: 'vn-supplier-descriptor vn-icon[icon="icon-entry"]', + }, + supplierContact: { + anyContact: 'vn-supplier-contact > form > vn-card > div', + addNewContact: 'vn-supplier-contact vn-icon[icon="add_circle"]', + thirdContactName: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.name"]', + thirdContactPhone: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.phone"]', + thirdContactMobile: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.mobile"]', + thirdContactEmail: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.email"]', + thirdContactNotes: 'vn-supplier-contact div:nth-child(3) vn-textfield[ng-model="contact.observation"]', + saveButton: 'vn-supplier-contact button[type="submit"]', + thirdContactDeleteButton: 'vn-supplier-contact div:nth-child(3) vn-icon-button[icon="delete"]' } }; diff --git a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js index 953a9ee28..21609fced 100644 --- a/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js +++ b/e2e/paths/13-supplier/01_summary_and_descriptor.spec.js @@ -1,7 +1,7 @@ import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; -describe('Supplier descriptor path', () => { +describe('Supplier summary & descriptor path', () => { let browser; let page; diff --git a/e2e/paths/13-supplier/02_contact.spec.js b/e2e/paths/13-supplier/02_contact.spec.js new file mode 100644 index 000000000..9a102cf93 --- /dev/null +++ b/e2e/paths/13-supplier/02_contact.spec.js @@ -0,0 +1,84 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Supplier contact path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('administrative', 'supplier'); + await page.accessToSearchResult('1'); + await page.accessToSection('supplier.card.contact'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should create a new contact', async() => { + await page.waitToClick(selectors.supplierContact.addNewContact); + await page.write(selectors.supplierContact.thirdContactName, 'The tester'); + await page.write(selectors.supplierContact.thirdContactPhone, '99 999 99 99'); + await page.write(selectors.supplierContact.thirdContactMobile, '555 55 55 55'); + await page.write(selectors.supplierContact.thirdContactEmail, 'testing@puppeteer.com'); + await page.write(selectors.supplierContact.thirdContactNotes, 'the end to end integration tester'); + await page.waitToClick(selectors.supplierContact.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toBe('Data saved!'); + }); + + it(`should reload the section and count the contacts`, async() => { + await page.reloadSection('supplier.card.contact'); + const result = await page.countElement(selectors.supplierContact.anyContact); + + expect(result).toEqual(3); + }); + + it(`should check the new contact name was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactName, 'value'); + + expect(result).toContain('The tester'); + }); + + it(`should check the new contact phone was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactPhone, 'value'); + + expect(result).toContain('99 999 99 99'); + }); + + it(`should check the new contact mobile was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactMobile, 'value'); + + expect(result).toContain('555 55 55 55'); + }); + + it(`should check the new contact email was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactEmail, 'value'); + + expect(result).toContain('testing@puppeteer.com'); + }); + + it(`should check the new contact note was saved correctly`, async() => { + const result = await page.waitToGetProperty(selectors.supplierContact.thirdContactNotes, 'value'); + + expect(result).toContain('the end to end integration tester'); + }); + + it(`should remove the created contact`, async() => { + await page.waitToClick(selectors.supplierContact.thirdContactDeleteButton, 'value'); + await page.waitToClick(selectors.supplierContact.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toBe('Data saved!'); + }); + + it(`should reload the section and count the amount of contacts went back to 2`, async() => { + await page.reloadSection('supplier.card.contact'); + const result = await page.countElement(selectors.supplierContact.anyContact); + + expect(result).toEqual(2); + }); +});