From d16a39b1808f636a88ace35639e1b36c9884e8a8 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Mon, 3 May 2021 13:31:43 +0200 Subject: [PATCH] e2e path for supplier address --- e2e/helpers/selectors.js | 44 ++++++++--- ...g_data.spec.js => 04_billing_data.spec.js} | 0 e2e/paths/13-supplier/05_address.spec.js | 79 +++++++++++++++++++ ...{04_contact.spec.js => 06_contact.spec.js} | 0 4 files changed, 111 insertions(+), 12 deletions(-) rename e2e/paths/13-supplier/{05_billing_data.spec.js => 04_billing_data.spec.js} (100%) create mode 100644 e2e/paths/13-supplier/05_address.spec.js rename e2e/paths/13-supplier/{04_contact.spec.js => 06_contact.spec.js} (100%) diff --git a/e2e/helpers/selectors.js b/e2e/helpers/selectors.js index dd80f0021..f8e0cbf47 100644 --- a/e2e/helpers/selectors.js +++ b/e2e/helpers/selectors.js @@ -1097,17 +1097,6 @@ export default { 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"]' - }, supplierBasicData: { alias: 'vn-supplier-basic-data vn-textfield[ng-model="$ctrl.supplier.nickname"]', isSerious: 'vn-supplier-basic-data vn-check[ng-model="$ctrl.supplier.isSerious"]', @@ -1132,5 +1121,36 @@ export default { payDem: 'vn-supplier-billing-data vn-autocomplete[ng-model="$ctrl.supplier.payDemFk"]', payDay: 'vn-supplier-billing-data vn-input-number[ng-model="$ctrl.supplier.payDay"]', saveButton: 'vn-supplier-billing-data button[type=submit]' - } + }, + supplierAddress: { + anyAddress: 'vn-supplier-address-index a', + thirdAddress: 'vn-supplier-address-index vn-card > div:nth-child(3) > a', + newAddress: 'vn-supplier-address-index vn-float-button[icon="add"]', + newNickname: 'vn-supplier-address-create vn-textfield[ng-model="$ctrl.address.nickname"]', + newStreet: 'vn-supplier-address-create vn-textfield[ng-model="$ctrl.address.street"]', + newPostcode: 'vn-supplier-address-create vn-datalist[ng-model="$ctrl.address.postalCode"]', + newCity: 'vn-supplier-address-create vn-datalist[ng-model="$ctrl.address.city"]', + newProvince: 'vn-supplier-address-create vn-autocomplete[ng-model="$ctrl.address.provinceFk"]', + newPhone: 'vn-supplier-address-create vn-textfield[ng-model="$ctrl.address.phone"]', + newMobile: 'vn-supplier-address-create vn-textfield[ng-model="$ctrl.address.mobile"]', + editNickname: 'vn-supplier-address-edit vn-textfield[ng-model="$ctrl.address.nickname"]', + editStreet: 'vn-supplier-address-edit vn-textfield[ng-model="$ctrl.address.street"]', + editPostcode: 'vn-supplier-address-edit vn-datalist[ng-model="$ctrl.address.postalCode"]', + editCity: 'vn-supplier-address-edit vn-datalist[ng-model="$ctrl.address.city"]', + editProvince: 'vn-supplier-address-edit vn-autocomplete[ng-model="$ctrl.address.provinceFk"]', + editPhone: 'vn-supplier-address-edit vn-textfield[ng-model="$ctrl.address.phone"]', + editMobile: 'vn-supplier-address-edit vn-textfield[ng-model="$ctrl.address.mobile"]', + saveButton: 'button[type="submit"]' + }, + 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/05_billing_data.spec.js b/e2e/paths/13-supplier/04_billing_data.spec.js similarity index 100% rename from e2e/paths/13-supplier/05_billing_data.spec.js rename to e2e/paths/13-supplier/04_billing_data.spec.js diff --git a/e2e/paths/13-supplier/05_address.spec.js b/e2e/paths/13-supplier/05_address.spec.js new file mode 100644 index 000000000..5bccba3ee --- /dev/null +++ b/e2e/paths/13-supplier/05_address.spec.js @@ -0,0 +1,79 @@ +import selectors from '../../helpers/selectors.js'; +import getBrowser from '../../helpers/puppeteer'; + +describe('Supplier address path', () => { + let browser; + let page; + + beforeAll(async() => { + browser = await getBrowser(); + page = browser.page; + await page.loginAndModule('employee', 'supplier'); + await page.accessToSearchResult('1'); + await page.accessToSection('supplier.card.address.index'); + }); + + afterAll(async() => { + await browser.close(); + }); + + it('should count the addresses before creating one', async() => { + const count = await page.countElement(selectors.supplierAddress.anyAddress); + + expect(count).toEqual(2); + }); + + it('should open the new address form by clicking the add button', async() => { + await page.waitToClick(selectors.supplierAddress.newAddress); + await page.waitForState('supplier.card.address.create'); + }); + + it('should create a new address', async() => { + await page.write(selectors.supplierAddress.newNickname, 'Darkest dungeon'); + await page.write(selectors.supplierAddress.newStreet, 'Wayne manor'); + await page.write(selectors.supplierAddress.newPostcode, '46000'); + await page.write(selectors.supplierAddress.newCity, 'Valencia'); + await page.autocompleteSearch(selectors.supplierAddress.newProvince, 'Province one'); + await page.write(selectors.supplierAddress.newPhone, '888888888'); + await page.write(selectors.supplierAddress.newMobile, '444444444'); + await page.waitToClick(selectors.supplierAddress.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should have been redirected to the addresses index', async() => { + await page.waitForState('supplier.card.address.index'); + }); + + it('should count the addresses and find one more now', async() => { + const count = await page.countElement(selectors.supplierAddress.anyAddress); + + expect(count).toEqual(3); + }); + + it('should open the edit address form by clicking the new address', async() => { + await page.waitToClick(selectors.supplierAddress.thirdAddress); + await page.waitForState('supplier.card.address.edit'); + }); + + it('should edit the address', async() => { + await page.overwrite(selectors.supplierAddress.editNickname, 'Wayne manor'); + await page.overwrite(selectors.supplierAddress.editStreet, '1007 Mountain Drive'); + await page.overwrite(selectors.supplierAddress.editPostcode, '46000'); + await page.overwrite(selectors.supplierAddress.editCity, 'Valencia'); + await page.autocompleteSearch(selectors.supplierAddress.editProvince, 'Province one'); + await page.overwrite(selectors.supplierAddress.editPhone, '777777777'); + await page.overwrite(selectors.supplierAddress.editMobile, '555555555'); + await page.waitToClick(selectors.supplierAddress.saveButton); + const message = await page.waitForSnackbar(); + + expect(message.text).toContain('Data saved!'); + }); + + it('should check the address has now the expected data', async() => { + let thirdAddress = await page.waitToGetProperty(selectors.supplierAddress.thirdAddress, 'innerText'); + + expect(thirdAddress).toContain('Wayne manor'); + }); +}); diff --git a/e2e/paths/13-supplier/04_contact.spec.js b/e2e/paths/13-supplier/06_contact.spec.js similarity index 100% rename from e2e/paths/13-supplier/04_contact.spec.js rename to e2e/paths/13-supplier/06_contact.spec.js