2020-12-31 15:42:38 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
|
|
|
|
describe('Entry observations path', () => {
|
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('developer', 'entry');
|
|
|
|
await page.accessToSearchResult('2');
|
|
|
|
await page.accessToSection('entry.card.observation');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should add two new observations of the same type then fail to save as they can't be repeated`, async() => {
|
|
|
|
await page.waitToClick(selectors.entryObservations.addNewObservation);
|
|
|
|
await page.waitToClick(selectors.entryObservations.addNewObservation);
|
2021-05-17 09:08:00 +00:00
|
|
|
await page.autocompleteSearch(selectors.entryObservations.firstObservationType, 'SalesPerson');
|
|
|
|
await page.autocompleteSearch(selectors.entryObservations.secondObservationType, 'SalesPerson');
|
2020-12-31 15:42:38 +00:00
|
|
|
await page.write(selectors.entryObservations.firstObservationDescription, 'first observation');
|
|
|
|
await page.write(selectors.entryObservations.secondObservationDescription, 'second observation');
|
|
|
|
await page.waitToClick(selectors.entryObservations.saveObservationsButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.text).toContain(`The observation type can't be repeated`);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should set the 2nd observation of a different one and successfully save both', async() => {
|
2021-05-17 08:38:53 +00:00
|
|
|
await page.autocompleteSearch(selectors.entryObservations.secondObservationType, 'Delivery');
|
2020-12-31 15:42:38 +00:00
|
|
|
await page.waitToClick(selectors.entryObservations.saveObservationsButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should reload the section and make sure the first observation type was saved correctly', async() => {
|
|
|
|
await page.reloadSection('entry.card.observation');
|
|
|
|
const result = await page.waitToGetProperty(selectors.entryObservations.firstObservationType, 'value');
|
|
|
|
|
2021-05-17 09:08:00 +00:00
|
|
|
expect(result).toEqual('SalesPerson');
|
2020-12-31 15:42:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should make sure the first observation description was saved correctly', async() => {
|
|
|
|
const result = await page.waitToGetProperty(selectors.entryObservations.firstObservationDescription, 'value');
|
|
|
|
|
|
|
|
expect(result).toEqual('first observation');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should make sure the second observation type was saved correctly', async() => {
|
|
|
|
const result = await page.waitToGetProperty(selectors.entryObservations.secondObservationType, 'value');
|
|
|
|
|
2021-05-17 08:38:53 +00:00
|
|
|
expect(result).toEqual('Delivery');
|
2020-12-31 15:42:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should make sure the second observation description was saved correctly', async() => {
|
|
|
|
const result = await page.waitToGetProperty(selectors.entryObservations.secondObservationDescription, 'value');
|
|
|
|
|
|
|
|
expect(result).toEqual('second observation');
|
|
|
|
});
|
|
|
|
});
|