2021-11-12 10:03:23 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
|
2023-05-05 06:12:38 +00:00
|
|
|
const $ = {
|
|
|
|
form: 'vn-item-create form'
|
|
|
|
};
|
|
|
|
|
2021-11-12 10:03:23 +00:00
|
|
|
describe('Item Create', () => {
|
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('buyer', 'item');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should access to the create item view by clicking the create floating button', async() => {
|
|
|
|
await page.waitToClick(selectors.itemsIndex.createItemButton);
|
|
|
|
await page.waitForState('item.create');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return to the item index by clickig the cancel button', async() => {
|
|
|
|
await page.waitToClick(selectors.itemCreateView.cancelButton);
|
|
|
|
await page.waitForState('item.index');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should now access to the create item view by clicking the create floating button', async() => {
|
|
|
|
await page.waitToClick(selectors.itemsIndex.createItemButton);
|
|
|
|
await page.waitForState('item.create');
|
|
|
|
});
|
|
|
|
|
2023-01-17 09:01:49 +00:00
|
|
|
it('should throw an error when insert an invalid priority', async() => {
|
2023-05-05 06:12:38 +00:00
|
|
|
const values = {
|
|
|
|
name: 'Infinity Gauntlet',
|
|
|
|
type: 'Crisantemo',
|
|
|
|
intrastat: 'Coral y materiales similares',
|
|
|
|
origin: 'Holand',
|
|
|
|
priority: null
|
|
|
|
};
|
|
|
|
const message = await page.sendForm($.form, values);
|
2023-01-17 09:01:49 +00:00
|
|
|
|
|
|
|
expect(message.text).toContain('Valid priorities');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should create the Infinity Gauntlet item', async() => {
|
2023-05-05 06:12:38 +00:00
|
|
|
const values = {
|
|
|
|
name: 'Infinity Gauntlet',
|
|
|
|
type: 'Crisantemo',
|
|
|
|
intrastat: 'Coral y materiales similares',
|
|
|
|
origin: 'Holand',
|
|
|
|
priority: '2'
|
|
|
|
};
|
|
|
|
|
|
|
|
await page.fillForm($.form, values);
|
|
|
|
const formValues = await page.fetchForm($.form, Object.keys(values));
|
|
|
|
const message = await page.sendForm($.form);
|
|
|
|
|
|
|
|
expect(message.isSuccess).toBeTrue();
|
|
|
|
expect(formValues).toEqual(values);
|
2021-11-12 10:03:23 +00:00
|
|
|
});
|
|
|
|
});
|