salix/e2e/paths/07-order-module/02_catalog.spec.js

84 lines
3.1 KiB
JavaScript
Raw Normal View History

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Order catalog', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('employee', 'order');
});
it('should open the create new order form', async() => {
const url = await nightmare
.waitToClick(selectors.ordersIndex.createOrderButton)
.waitForURL('order/create')
.parsedUrl();
expect(url.hash).toContain('order/create');
});
it('should create a new order', async() => {
let today = new Date().getDate();
const url = await nightmare
.autocompleteSearch(selectors.createOrderView.clientAutocomplete, 'Tony Stark')
.datePicker(selectors.createOrderView.landedDatePicker, 0, today)
2019-05-31 07:18:20 +00:00
.autocompleteSearch(selectors.createOrderView.agencyAutocomplete, 'inhouse pickup')
.waitToClick(selectors.createOrderView.createButton)
.waitForURL('/catalog')
.parsedUrl();
expect(url.hash).toContain('/catalog');
});
it('should add the realm and type filters and obtain results', async() => {
const result = await nightmare
.waitToClick(selectors.orderCatalog.plantRealmButton)
.autocompleteSearch(selectors.orderCatalog.typeAutocomplete, 'Anthurium')
.waitForNumberOfElements('section.product', 4)
.countElement('section.product');
expect(result).toEqual(4);
});
it('should search for the item tag value +1 and find two results', async() => {
const result = await nightmare
.write(selectors.orderCatalog.itemTagValueInput, '+1\u000d')
.waitForNumberOfElements('section.product', 2)
.countElement('section.product');
expect(result).toEqual(2);
});
it('should search for the item tag categoria +1 and find two results', async() => {
const result = await nightmare
.waitToClick(selectors.orderCatalog.openTagSearch)
.autocompleteSearch(selectors.orderCatalog.tagAutocomplete, 'categoria')
.write(selectors.orderCatalog.tagValueInput, '+1')
.waitToClick(selectors.orderCatalog.searchTagButton)
.waitForNumberOfElements('section.product', 1)
.countElement('section.product');
expect(result).toEqual(1);
});
it('should remove the tag filters and have 4 results', async() => {
const result = await nightmare
.waitToClick(selectors.orderCatalog.fourthFilterRemoveButton)
.waitToClick(selectors.orderCatalog.thirdFilterRemoveButton)
2019-10-18 19:36:30 +00:00
.waitForNumberOfElements('.product', 4)
.countElement('section.product');
expect(result).toEqual(4);
});
it('should search for the item id 1 and have only 1 result', async() => {
const result = await nightmare
.write(selectors.orderCatalog.itemIdInput, '2\u000d')
.waitForNumberOfElements('section.product', 1)
.countElement('section.product');
expect(result).toEqual(1);
});
});