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

43 lines
1.3 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
fdescribe('Travel create path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'travel');
});
afterAll(async() => {
await browser.close();
});
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);
await page.waitToClick(selectors.travelIndex.newTravelButton);
await page.waitForState('travel.create');
const values = {
reference: 'Testing reference',
agencyMode: 'inhouse pickup',
shipped: date,
landed: date,
warehouseOut: 'Warehouse One',
warehouseIn: 'Warehouse Five'
};
const message = await page.sendForm('vn-travel-create form', values);
await page.waitForState('travel.card.basicData');
const formValues = await page.fetchForm('vn-travel-basic-data form', Object.keys(values));
expect(message.isSuccess).toBeTrue();
expect(formValues).toEqual(values);
});
});