2019-05-02 09:23:54 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
2020-01-23 15:01:29 +00:00
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
2019-05-02 09:23:54 +00:00
|
|
|
|
|
|
|
describe('Order catalog', () => {
|
2020-01-23 15:01:29 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('employee', 'order');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
2019-05-02 09:23:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should open the create new order form', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.ordersIndex.createOrderButton);
|
|
|
|
await page.waitForURL('order/create');
|
|
|
|
const url = await page.parsedUrl();
|
2019-05-02 09:23:54 +00:00
|
|
|
|
|
|
|
expect(url.hash).toContain('order/create');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should create a new order', async() => {
|
|
|
|
let today = new Date().getDate();
|
2020-01-23 15:01:29 +00:00
|
|
|
|
|
|
|
await page.autocompleteSearch(selectors.createOrderView.clientAutocomplete, 'Tony Stark');
|
|
|
|
await page.datePicker(selectors.createOrderView.landedDatePicker, 0, today);
|
|
|
|
await page.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'inhouse pickup');
|
|
|
|
await page.waitToClick(selectors.createOrderView.createButton);
|
|
|
|
await page.waitForURL('/catalog');
|
|
|
|
const url = await page.parsedUrl();
|
2019-05-02 09:23:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
expect(url.hash).toContain('/catalog');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should add the realm and type filters and obtain results', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.orderCatalog.plantRealmButton);
|
|
|
|
await page.autocompleteSearch(selectors.orderCatalog.typeAutocomplete, 'Anthurium');
|
|
|
|
await page.waitForNumberOfElements('section.product', 4);
|
|
|
|
const result = await page.countElement('section.product');
|
2019-05-02 09:23:54 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(4);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should search for the item tag value +1 and find two results', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.write(selectors.orderCatalog.itemTagValueInput, '+1');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
await page.waitForNumberOfElements('section.product', 2);
|
|
|
|
const result = await page.countElement('section.product');
|
2019-05-02 09:23:54 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(2);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should search for the item tag categoria +1 and find two results', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.orderCatalog.openTagSearch);
|
|
|
|
await page.autocompleteSearch(selectors.orderCatalog.tagAutocomplete, 'categoria');
|
|
|
|
await page.write(selectors.orderCatalog.tagValueInput, '+1');
|
|
|
|
await page.waitToClick(selectors.orderCatalog.searchTagButton);
|
|
|
|
await page.waitForNumberOfElements('section.product', 1);
|
|
|
|
const result = await page.countElement('section.product');
|
2019-05-02 09:23:54 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should remove the tag filters and have 4 results', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.orderCatalog.fourthFilterRemoveButton);
|
|
|
|
await page.waitToClick(selectors.orderCatalog.thirdFilterRemoveButton);
|
|
|
|
await page.waitForNumberOfElements('.product', 4);
|
|
|
|
const result = await page.countElement('section.product');
|
2019-05-02 09:23:54 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(4);
|
|
|
|
});
|
|
|
|
|
2020-01-23 15:01:29 +00:00
|
|
|
it('should search for an item by id', async() => {
|
|
|
|
await page.write(selectors.orderCatalog.itemIdInput, '2');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
await page.waitForNumberOfElements('section.product', 1);
|
|
|
|
const result = await page.countElement('section.product');
|
2019-05-02 09:23:54 +00:00
|
|
|
|
|
|
|
expect(result).toEqual(1);
|
|
|
|
});
|
|
|
|
});
|