2020-02-28 15:49:39 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
|
|
|
|
describe('Travel basic data path', () => {
|
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('buyer', 'travel');
|
|
|
|
await page.accessToSearchResult('3');
|
|
|
|
await page.accessToSection('travel.card.basicData');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should reach the thermograph section', async() => {
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('travel.card.basicData');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should set a wrong delivery date then receive an error on submit', async() => {
|
2020-03-23 22:57:11 +00:00
|
|
|
const lastMonth = new Date();
|
|
|
|
lastMonth.setMonth(lastMonth.getMonth() - 1);
|
|
|
|
|
|
|
|
await page.pickDate(selectors.travelBasicDada.deliveryDate, lastMonth);
|
2020-02-28 15:49:39 +00:00
|
|
|
await page.waitToClick(selectors.travelBasicDada.save);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2020-02-28 15:49:39 +00:00
|
|
|
|
2020-04-08 09:24:40 +00:00
|
|
|
expect(message.text).toBe('Landing cannot be lesser than shipment');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should undo the changes', async() => {
|
|
|
|
await page.waitToClick(selectors.travelBasicDada.undoChanges);
|
|
|
|
await page.waitToClick(selectors.travelBasicDada.save);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2020-02-28 15:49:39 +00:00
|
|
|
|
2020-04-08 09:24:40 +00:00
|
|
|
expect(message.text).toBe('No changes to save');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should now edit the whole form then save', async() => {
|
|
|
|
await page.clearInput(selectors.travelBasicDada.reference);
|
|
|
|
await page.write(selectors.travelBasicDada.reference, 'new reference!');
|
2020-03-03 11:03:06 +00:00
|
|
|
await page.waitFor(2000);
|
2020-02-28 15:58:21 +00:00
|
|
|
await page.autocompleteSearch(selectors.travelBasicDada.agency, 'Entanglement');
|
2020-02-28 15:49:39 +00:00
|
|
|
await page.autocompleteSearch(selectors.travelBasicDada.outputWarehouse, 'Warehouse Three');
|
|
|
|
await page.autocompleteSearch(selectors.travelBasicDada.inputWarehouse, 'Warehouse Four');
|
|
|
|
await page.waitToClick(selectors.travelBasicDada.delivered);
|
|
|
|
await page.waitToClick(selectors.travelBasicDada.received);
|
|
|
|
await page.waitToClick(selectors.travelBasicDada.save);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2020-02-28 15:49:39 +00:00
|
|
|
|
2020-04-08 09:24:40 +00:00
|
|
|
expect(message.type).toBe('success');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should reload the section and check the reference was saved', async() => {
|
|
|
|
await page.reloadSection('travel.card.basicData');
|
|
|
|
const result = await page.waitToGetProperty(selectors.travelBasicDada.reference, 'value');
|
|
|
|
|
|
|
|
expect(result).toEqual('new reference!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should check the agency was saved', async() => {
|
|
|
|
const result = await page.waitToGetProperty(selectors.travelBasicDada.agency, 'value');
|
|
|
|
|
2020-02-28 15:58:21 +00:00
|
|
|
expect(result).toEqual('Entanglement');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should check the output warehouse date was saved', async() => {
|
|
|
|
const result = await page.waitToGetProperty(selectors.travelBasicDada.outputWarehouse, 'value');
|
|
|
|
|
|
|
|
expect(result).toEqual('Warehouse Three');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should check the input warehouse date was saved', async() => {
|
|
|
|
const result = await page.waitToGetProperty(selectors.travelBasicDada.inputWarehouse, 'value');
|
|
|
|
|
|
|
|
expect(result).toEqual('Warehouse Four');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should check the delivered checkbox was saved even tho it doesn't make sense`, async() => {
|
|
|
|
await page.waitForClassPresent(selectors.travelBasicDada.delivered, 'checked');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => {
|
|
|
|
await page.waitForClassPresent(selectors.travelBasicDada.received, 'checked');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should navigate to the travel logs', async() => {
|
|
|
|
await page.accessToSection('travel.card.log');
|
2020-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('travel.card.log');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should check the 1st log contains details from the changes made', async() => {
|
2020-02-28 15:58:21 +00:00
|
|
|
const result = await page.waitToGetProperty(selectors.travelLog.firstLogFirstTD, 'innerText');
|
2020-02-28 15:49:39 +00:00
|
|
|
|
|
|
|
expect(result).toContain('new reference!');
|
|
|
|
});
|
|
|
|
});
|