86 lines
3.2 KiB
JavaScript
86 lines
3.2 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Order catalog', () => {
|
|
let browser;
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
await page.loginAndModule('employee', 'order');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
it('should open the create new order form', async() => {
|
|
await page.waitToClick(selectors.ordersIndex.createOrderButton);
|
|
let url = await page.expectURL('order/create');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it('should create a new order', async() => {
|
|
let today = new Date().getDate();
|
|
|
|
await page.autocompleteSearch(selectors.createOrderView.client, 'Tony Stark');
|
|
await page.datePicker(selectors.createOrderView.landedDatePicker, 0, today);
|
|
await page.autocompleteSearch(selectors.createOrderView.agency, 'Other agency');
|
|
await page.waitToClick(selectors.createOrderView.createButton);
|
|
let url = await page.expectURL('/catalog');
|
|
|
|
expect(url).toBe(true);
|
|
});
|
|
|
|
it('should add the realm and type filters and obtain results', async() => {
|
|
await page.waitToClick(selectors.orderCatalog.plantRealmButton);
|
|
await page.autocompleteSearch(selectors.orderCatalog.type, 'Anthurium');
|
|
await page.waitForNumberOfElements('section.product', 4);
|
|
const result = await page.countElement('section.product');
|
|
|
|
expect(result).toEqual(4);
|
|
});
|
|
|
|
it('should search for the item tag value +1 and find two results', async() => {
|
|
await page.write(selectors.orderCatalog.itemTagValue, '+1');
|
|
await page.keyboard.press('Enter');
|
|
await page.waitForNumberOfElements('section.product', 2);
|
|
const result = await page.countElement('section.product');
|
|
|
|
expect(result).toEqual(2);
|
|
});
|
|
|
|
it('should search for the item tag categoria +1 and find two results', async() => {
|
|
await page.waitToClick(selectors.orderCatalog.openTagSearch);
|
|
await page.autocompleteSearch(selectors.orderCatalog.tag, 'categoria');
|
|
await page.write(selectors.orderCatalog.tagValue, '+1');
|
|
await page.waitToClick(selectors.orderCatalog.searchTagButton);
|
|
await page.waitForNumberOfElements('section.product', 1);
|
|
const result = await page.countElement('section.product');
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it('should remove the tag filters and have 4 results', async() => {
|
|
await page.waitForContentLoaded();
|
|
await page.waitToClick(selectors.orderCatalog.fourthFilterRemoveButton);
|
|
await page.waitForContentLoaded();
|
|
await page.waitToClick(selectors.orderCatalog.thirdFilterRemoveButton);
|
|
await page.waitForNumberOfElements('.product', 4);
|
|
const result = await page.countElement('section.product');
|
|
|
|
expect(result).toEqual(4);
|
|
});
|
|
|
|
it('should search for an item by id', async() => {
|
|
await page.write(selectors.orderCatalog.itemId, '2');
|
|
await page.keyboard.press('Enter');
|
|
await page.waitForNumberOfElements('section.product', 1);
|
|
const result = await page.countElement('section.product');
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
});
|