84 lines
3.1 KiB
JavaScript
84 lines
3.1 KiB
JavaScript
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)
|
|
.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)
|
|
.waitForNumberOfElements('section.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);
|
|
});
|
|
});
|