salix/e2e/paths/13-supplier/05_address.spec.js

80 lines
3.3 KiB
JavaScript

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');
});
});