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-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('order.create');
|
2019-05-02 09:23:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should create a new order', async() => {
|
2020-02-03 14:55:11 +00:00
|
|
|
await page.autocompleteSearch(selectors.createOrderView.client, 'Tony Stark');
|
2020-03-23 22:57:11 +00:00
|
|
|
await page.pickDate(selectors.createOrderView.landedDatePicker);
|
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-03-24 15:49:36 +00:00
|
|
|
await page.waitForState('order.card.catalog');
|
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);
|
|
|
|
});
|
|
|
|
|
2020-09-16 14:10:43 +00:00
|
|
|
it('should perfom an "OR" search for the item tag colors silver and brown', async() => {
|
|
|
|
await page.waitToClick(selectors.orderCatalog.openTagSearch);
|
|
|
|
await page.autocompleteSearch(selectors.orderCatalog.tag, 'Color');
|
|
|
|
await page.autocompleteSearch(selectors.orderCatalog.firstTagAutocomplete, 'silver');
|
|
|
|
await page.waitToClick(selectors.orderCatalog.addTagButton);
|
|
|
|
await page.autocompleteSearch(selectors.orderCatalog.secondTagAutocomplete, 'brown');
|
|
|
|
await page.waitToClick(selectors.orderCatalog.searchTagButton);
|
|
|
|
await page.waitForNumberOfElements('section.product', 4);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should perfom an "OR" search for the item tag tallos 2 and 9', async() => {
|
|
|
|
await page.waitToClick(selectors.orderCatalog.openTagSearch);
|
|
|
|
await page.autocompleteSearch(selectors.orderCatalog.tag, 'Tallos');
|
|
|
|
await page.write(selectors.orderCatalog.firstTagValue, '2');
|
|
|
|
await page.waitToClick(selectors.orderCatalog.addTagButton);
|
|
|
|
await page.write(selectors.orderCatalog.secondTagValue, '9');
|
|
|
|
await page.waitToClick(selectors.orderCatalog.searchTagButton);
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitForNumberOfElements('section.product', 2);
|
2020-09-16 14:10:43 +00:00
|
|
|
});
|
2019-05-02 09:23:54 +00:00
|
|
|
|
2020-09-16 14:10:43 +00:00
|
|
|
it('should perform a general search for category', async() => {
|
|
|
|
await page.write(selectors.orderCatalog.itemTagValue, 'concussion');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
await page.waitForNumberOfElements('section.product', 2);
|
2019-05-02 09:23:54 +00:00
|
|
|
});
|
|
|
|
|
2020-09-16 14:10:43 +00:00
|
|
|
it('should perfom an "AND" search for the item tag tallos 2', async() => {
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.orderCatalog.openTagSearch);
|
2020-09-16 14:10:43 +00:00
|
|
|
await page.autocompleteSearch(selectors.orderCatalog.tag, 'Tallos');
|
|
|
|
await page.write(selectors.orderCatalog.firstTagValue, '2');
|
2020-01-23 15:01:29 +00:00
|
|
|
await page.waitToClick(selectors.orderCatalog.searchTagButton);
|
|
|
|
await page.waitForNumberOfElements('section.product', 1);
|
2019-05-02 09:23:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should remove the tag filters and have 4 results', async() => {
|
2020-09-16 14:10:43 +00:00
|
|
|
await page.waitForContentLoaded();
|
|
|
|
await page.waitToClick(selectors.orderCatalog.sixthFilterRemoveButton);
|
|
|
|
await page.waitForContentLoaded();
|
|
|
|
await page.waitToClick(selectors.orderCatalog.fifthFilterRemoveButton);
|
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);
|
2020-09-16 14:10:43 +00:00
|
|
|
|
2020-01-23 15:01:29 +00:00
|
|
|
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-03-25 12:44:51 +00:00
|
|
|
await page.accessToSearchResult('2');
|
2020-01-23 15:01:29 +00:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|