salix/e2e/paths/10-travel/01_create.spec.js

43 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2021-03-02 15:43:45 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2023-05-05 11:03:01 +00:00
describe('Travel create path', () => {
2021-03-02 15:43:45 +00:00
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'travel');
});
afterAll(async() => {
await browser.close();
});
2023-05-05 11:00:45 +00:00
it('should create a new travel and check it was created with the correct data', async() => {
const date = Date.vnNew();
date.setDate(15);
date.setUTCHours(0, 0, 0, 0);
2021-03-02 15:43:45 +00:00
await page.waitToClick(selectors.travelIndex.newTravelButton);
await page.waitForState('travel.create');
2023-05-05 11:00:45 +00:00
const values = {
reference: 'Testing reference',
agencyMode: 'inhouse pickup',
shipped: date,
landed: date,
warehouseOut: 'Warehouse One',
warehouseIn: 'Warehouse Five'
};
2021-03-02 15:43:45 +00:00
2023-05-05 11:00:45 +00:00
const message = await page.sendForm('vn-travel-create form', values);
2021-03-02 15:43:45 +00:00
await page.waitForState('travel.card.basicData');
2023-05-05 11:00:45 +00:00
const formValues = await page.fetchForm('vn-travel-basic-data form', Object.keys(values));
2021-03-02 15:43:45 +00:00
2023-05-05 11:00:45 +00:00
expect(message.isSuccess).toBeTrue();
expect(formValues).toEqual(values);
2021-03-02 15:43:45 +00:00
});
});