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');
|
2023-03-24 08:21:55 +00:00
|
|
|
await page.write(selectors.travelIndex.generalSearchFilter, '3');
|
|
|
|
await page.keyboard.press('Enter');
|
2020-02-28 15:49:39 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
|
2023-11-21 09:12:07 +00:00
|
|
|
it('should set a wrong delivery date then receive an error on submit', async() => {
|
|
|
|
await page.loginAndModule('buyer', 'travel');
|
|
|
|
await page.write(selectors.travelIndex.generalSearchFilter, '4');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
await page.accessToSection('travel.card.basicData');
|
|
|
|
await page.waitForState('travel.card.basicData');
|
|
|
|
|
|
|
|
const lastMonth = Date.vnNew();
|
|
|
|
lastMonth.setMonth(lastMonth.getMonth() - 2);
|
|
|
|
|
|
|
|
await page.pickDate(selectors.travelBasicData.deliveryDate, lastMonth);
|
|
|
|
await page.waitToClick(selectors.travelBasicData.save);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Landing cannot be lesser than shipment');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should undo the changes', async() => {
|
2020-12-16 13:53:14 +00:00
|
|
|
await page.clearInput(selectors.travelBasicData.reference);
|
|
|
|
await page.write(selectors.travelBasicData.reference, 'totally pointless ref');
|
|
|
|
await page.waitToClick(selectors.travelBasicData.undoChanges);
|
|
|
|
const result = await page.waitToGetProperty(selectors.travelBasicData.reference, 'value');
|
2020-02-28 15:49:39 +00:00
|
|
|
|
2023-11-21 09:12:07 +00:00
|
|
|
expect(result).toEqual('fourth travel');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should now edit the whole form then save', async() => {
|
2020-12-16 13:53:14 +00:00
|
|
|
await page.clearInput(selectors.travelBasicData.reference);
|
|
|
|
await page.write(selectors.travelBasicData.reference, 'new reference!');
|
|
|
|
await page.autocompleteSearch(selectors.travelBasicData.agency, 'Entanglement');
|
|
|
|
await page.autocompleteSearch(selectors.travelBasicData.outputWarehouse, 'Warehouse Three');
|
|
|
|
await page.autocompleteSearch(selectors.travelBasicData.inputWarehouse, 'Warehouse Four');
|
|
|
|
await page.waitToClick(selectors.travelBasicData.delivered);
|
|
|
|
await page.waitToClick(selectors.travelBasicData.received);
|
|
|
|
await page.waitToClick(selectors.travelBasicData.save);
|
2020-04-08 09:24:40 +00:00
|
|
|
const message = await page.waitForSnackbar();
|
2020-02-28 15:49:39 +00:00
|
|
|
|
2020-11-10 11:06:21 +00:00
|
|
|
expect(message.text).toContain('Data saved!');
|
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');
|
2020-12-16 13:53:14 +00:00
|
|
|
const result = await page.waitToGetProperty(selectors.travelBasicData.reference, 'value');
|
2020-02-28 15:49:39 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('new reference!');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should check the agency was saved', async() => {
|
2020-12-16 13:53:14 +00:00
|
|
|
const result = await page.waitToGetProperty(selectors.travelBasicData.agency, 'value');
|
2020-02-28 15:49:39 +00:00
|
|
|
|
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() => {
|
2020-12-16 13:53:14 +00:00
|
|
|
const result = await page.waitToGetProperty(selectors.travelBasicData.outputWarehouse, 'value');
|
2020-02-28 15:49:39 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Warehouse Three');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should check the input warehouse date was saved', async() => {
|
2020-12-16 13:53:14 +00:00
|
|
|
const result = await page.waitToGetProperty(selectors.travelBasicData.inputWarehouse, 'value');
|
2020-02-28 15:49:39 +00:00
|
|
|
|
|
|
|
expect(result).toEqual('Warehouse Four');
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should check the delivered checkbox was saved even tho it doesn't make sense`, async() => {
|
2020-12-16 13:53:14 +00:00
|
|
|
await page.waitForClassPresent(selectors.travelBasicData.delivered, 'checked');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it(`should check the received checkbox was saved even tho it doesn't make sense`, async() => {
|
2020-12-16 13:53:14 +00:00
|
|
|
await page.waitForClassPresent(selectors.travelBasicData.received, 'checked');
|
2020-02-28 15:49:39 +00:00
|
|
|
});
|
|
|
|
});
|