salix/e2e/paths/04-item-module/09_regularize.spec.js

205 lines
8.2 KiB
JavaScript
Raw Normal View History

2018-11-14 17:05:24 +00:00
import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
2019-04-29 11:22:32 +00:00
describe('Item regularize path', () => {
2018-11-14 17:05:24 +00:00
const nightmare = createNightmare();
beforeAll(() => {
2018-11-20 13:22:00 +00:00
nightmare
.loginAndModule('employee', 'item');
2018-11-14 17:05:24 +00:00
});
2019-02-07 14:02:22 +00:00
it('should edit the user local warehouse', async() => {
let result = await nightmare
.waitToClick(selectors.globalItems.userMenuButton)
.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four')
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should open the user config form to check the local settings', async() => {
let userLocalWarehouse = await nightmare
.waitToClick(selectors.globalItems.userMenuButton)
.waitToGetProperty(`${selectors.globalItems.userLocalWarehouse} input`, 'value');
expect(userLocalWarehouse).toContain('Warehouse Four');
});
2019-01-10 06:26:10 +00:00
it('should search for the item', async() => {
2018-11-14 17:05:24 +00:00
const resultCount = await nightmare
2019-03-27 07:44:15 +00:00
.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm')
2019-01-23 14:33:25 +00:00
.waitToClick(selectors.itemsIndex.searchButton)
2018-11-14 17:05:24 +00:00
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult);
expect(resultCount).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should click on the search result to access to the item tax`, async() => {
2018-11-14 17:05:24 +00:00
const url = await nightmare
2019-03-27 07:44:15 +00:00
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm')
2018-11-14 17:05:24 +00:00
.waitToClick(selectors.itemsIndex.searchResult)
.waitForURL('/summary')
.parsedUrl();
2018-11-14 17:05:24 +00:00
expect(url.hash).toContain('/summary');
2018-11-14 17:05:24 +00:00
});
2019-02-07 14:02:22 +00:00
it('should open the regularize dialog and check the warehouse matches the local user settings', async() => {
2018-11-14 17:05:24 +00:00
const result = await nightmare
.waitToClick(selectors.itemDescriptor.moreMenu)
.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton)
2019-02-07 14:02:22 +00:00
.waitToGetProperty(`${selectors.itemDescriptor.regularizeWarehouseAutocomplete} input`, 'value');
expect(result).toEqual('Warehouse Four');
});
it('should regularize the item', async() => {
const result = await nightmare
2019-01-23 14:33:25 +00:00
.write(selectors.itemDescriptor.regularizeQuantityInput, 100)
2019-01-07 08:33:07 +00:00
.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouseAutocomplete, 'Warehouse One')
2018-11-14 17:05:24 +00:00
.waitToClick(selectors.itemDescriptor.regularizeSaveButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should click on the Tickets button of the top bar menu', async() => {
2018-11-14 17:05:24 +00:00
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
2018-11-14 17:05:24 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
2019-02-07 14:02:22 +00:00
it('should now clear the user local settings', async() => {
let result = await nightmare
.waitToClick(selectors.globalItems.userMenuButton)
.waitToClick(selectors.globalItems.userConfigFirstAutocompleteClear)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should search for the ticket with alias missing', async() => {
2018-11-14 17:05:24 +00:00
const result = await nightmare
2019-01-23 14:33:25 +00:00
.write(selectors.ticketsIndex.searchTicketInput, 'missing')
.waitToClick(selectors.ticketsIndex.searchButton)
2018-11-14 17:05:24 +00:00
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should click on the search result to access to the ticket summary`, async() => {
2018-11-14 17:05:24 +00:00
const url = await nightmare
2018-11-15 08:30:14 +00:00
.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Missing')
2018-11-14 17:05:24 +00:00
.waitToClick(selectors.ticketsIndex.searchResult)
.waitForURL('/summary')
.parsedUrl();
2018-11-14 17:05:24 +00:00
expect(url.hash).toContain('/summary');
2018-11-14 17:05:24 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should check the ticket sale quantity is showing a negative value`, async() => {
2018-11-14 17:05:24 +00:00
const result = await nightmare
2018-11-14 17:55:40 +00:00
.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100')
.waitToGetProperty(selectors.ticketSummary.firstSaleQuantity, 'innerText');
2018-11-14 17:05:24 +00:00
2018-11-14 17:55:40 +00:00
expect(result).toContain('-100');
2018-11-14 17:05:24 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should check the ticket sale discount is 100%`, async() => {
2018-11-14 17:05:24 +00:00
const result = await nightmare
.waitToGetProperty(selectors.ticketSummary.firstSaleDiscount, 'innerText');
2018-11-14 17:05:24 +00:00
expect(result).toContain('100 %');
});
2019-01-07 08:33:07 +00:00
it('should now click on the Items button of the top bar menu', async() => {
2018-11-14 17:05:24 +00:00
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.itemsButton)
.wait(selectors.itemsIndex.searchItemInput)
2018-11-14 17:05:24 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/item/index');
});
2019-01-10 06:26:10 +00:00
it('should search for the item once again', async() => {
2018-11-14 17:05:24 +00:00
const resultCount = await nightmare
2019-03-27 07:44:15 +00:00
.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm')
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.itemsIndex.searchButton)
2018-11-14 17:05:24 +00:00
.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1)
.countElement(selectors.itemsIndex.searchResult);
expect(resultCount).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should click on the search result to access to the item tax`, async() => {
2018-11-14 17:05:24 +00:00
const url = await nightmare
2019-03-27 07:44:15 +00:00
.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm')
2018-11-14 17:05:24 +00:00
.waitToClick(selectors.itemsIndex.searchResult)
.waitForURL('/summary')
.parsedUrl();
2018-11-14 17:05:24 +00:00
expect(url.hash).toContain('/summary');
2018-11-14 17:05:24 +00:00
});
2019-01-07 08:33:07 +00:00
it('should regularize the item once more', async() => {
2018-11-14 17:05:24 +00:00
const result = await nightmare
.waitToClick(selectors.itemDescriptor.moreMenu)
.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton)
2019-01-23 14:33:25 +00:00
.write(selectors.itemDescriptor.regularizeQuantityInput, 100)
2019-01-07 08:33:07 +00:00
.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouseAutocomplete, 'Warehouse One')
2018-11-14 17:05:24 +00:00
.waitToClick(selectors.itemDescriptor.regularizeSaveButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
2019-01-07 08:33:07 +00:00
it('should again click on the Tickets button of the top bar menu', async() => {
2018-11-14 17:05:24 +00:00
const url = await nightmare
.waitToClick(selectors.globalItems.applicationsMenuButton)
.wait(selectors.globalItems.applicationsMenuVisible)
.waitToClick(selectors.globalItems.ticketsButton)
.wait(selectors.ticketsIndex.searchTicketInput)
2018-11-14 17:05:24 +00:00
.parsedUrl();
expect(url.hash).toEqual('#!/ticket/index');
});
2019-01-21 12:48:32 +00:00
it('should search for the ticket with id 23 once again', async() => {
2018-11-14 17:05:24 +00:00
const result = await nightmare
2019-04-29 11:22:32 +00:00
.write(selectors.ticketsIndex.searchTicketInput, 23)
2019-01-23 15:00:56 +00:00
.waitToClick(selectors.ticketsIndex.searchButton)
2018-11-14 17:05:24 +00:00
.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1)
.countElement(selectors.ticketsIndex.searchResult);
expect(result).toEqual(1);
});
2019-01-07 08:33:07 +00:00
it(`should now click on the search result to access to the ticket summary`, async() => {
2018-11-14 17:05:24 +00:00
const url = await nightmare
2019-04-29 11:22:32 +00:00
.waitForTextInElement(selectors.ticketsIndex.searchResult, '23')
2018-11-14 17:05:24 +00:00
.waitToClick(selectors.ticketsIndex.searchResult)
.waitForURL('/summary')
.parsedUrl();
2018-11-14 17:05:24 +00:00
expect(url.hash).toContain('/summary');
2018-11-14 17:05:24 +00:00
});
2019-01-07 08:33:07 +00:00
it(`should check the ticket contains now two sales`, async() => {
2018-11-14 17:05:24 +00:00
const result = await nightmare
2018-11-14 17:55:40 +00:00
.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100')
2018-11-14 17:05:24 +00:00
.countElement(selectors.ticketSummary.sale);
expect(result).toEqual(2);
});
});