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);
|
2020-02-04 15:21:10 +00:00
|
|
|
let url = await page.expectURL('order/create');
|
2019-05-02 09:23:54 +00:00
|
|
|
|
2020-02-04 15:21:10 +00:00
|
|
|
expect(url).toBe(true);
|
2019-05-02 09:23:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should create a new order', async() => {
|
|
|
|
let today = new Date().getDate();
|
2020-01-23 15:01:29 +00:00
|
|
|
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.createOrderView.client, 'Tony Stark');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.datePicker(selectors.createOrderView.landedDatePicker, 0, today);
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.createOrderView.createButton);
|
2020-02-04 15:21:10 +00:00
|
|
|
let url = await page.expectURL('/catalog');
|
2019-05-02 09:23:54 +00:00
|
|
|
|
2020-02-04 15:21:10 +00:00
|
|
|
expect(url).toBe(true);
|
2019-05-02 09:23:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.orderCatalog.type, 'Anthurium');
|
2020-01-23 15:01:29 +00:00
|
|
|
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-02-03 14:55:11 +00:00
|
|
|
await page.write(selectors.orderCatalog.itemTagValue, '+1');
|
2020-01-23 15:01:29 +00:00
|
|
|
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);
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.orderCatalog.tag, 'categoria');
|
|
|
|
await page.write(selectors.orderCatalog.tagValue, '+1');
|
2020-01-23 15:01:29 +00:00
|
|
|
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-27 17:35:39 +00:00
|
|
|
await page.waitForContentLoaded();
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.orderCatalog.fourthFilterRemoveButton);
|
2020-02-04 15:21:10 +00:00
|
|
|
await page.waitForContentLoaded();
|
2020-01-23 15:01:29 +00:00
|
|
|
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() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.write(selectors.orderCatalog.itemId, '2');
|
2020-01-23 15:01:29 +00:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|