salix/e2e/paths/02-client-module/06_add_address_notes.spec.js

57 lines
2.4 KiB
JavaScript

import selectors from '../../helpers/selectors';
import getBrowser from '../../helpers/puppeteer';
describe('Client add address notes path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('employee', 'client');
await page.accessToSearchResult('Petter Parker');
await page.accessToSection('client.card.address.index');
});
afterAll(async() => {
await browser.close();
});
it(`should click on the edit icon of the default address`, async() => {
await page.waitForTextInElement(selectors.clientAddresses.defaultAddress, '20 Ingram Street');
await page.waitToClick(selectors.clientAddresses.firstEditAddress);
await page.waitForURL('/edit');
const url = await page.parsedUrl();
expect(url.hash).toContain('/edit');
});
it('should not save a description without observation type', async() => {
await page.waitToClick(selectors.clientAddresses.addObservationButton);
await page.write(selectors.clientAddresses.firstObservationDescription, 'first description');
await page.waitToClick(selectors.clientAddresses.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
});
it('should not save an observation type without description', async() => {
await page.clearInput(selectors.clientAddresses.firstObservationDescription);
await page.autocompleteSearch(selectors.clientAddresses.firstObservationType, 'comercial');
await page.waitToClick(selectors.clientAddresses.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Some fields are invalid');
});
it('should create two new observations', async() => {
await page.write(selectors.clientAddresses.firstObservationDescription, 'first description');
await page.waitToClick(selectors.clientAddresses.addObservationButton);
await page.autocompleteSearch(selectors.clientAddresses.secondObservationType, 'observation one');
await page.write(selectors.clientAddresses.secondObservationDescription, 'second description');
await page.waitToClick(selectors.clientAddresses.saveButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
});