salix/e2e/paths/04-item/08_regularize.spec.js

142 lines
5.8 KiB
JavaScript
Raw Normal View History

2018-11-14 17:05:24 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2018-11-14 17:05:24 +00:00
2019-04-29 11:22:32 +00:00
describe('Item regularize path', () => {
let browser;
2020-01-09 12:07:16 +00:00
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
2020-01-09 12:07:16 +00:00
await page.loginAndModule('employee', 'item');
2018-11-14 17:05:24 +00:00
});
2020-01-09 12:07:16 +00:00
afterAll(async() => {
await browser.close();
2020-01-09 12:07:16 +00:00
});
2019-02-07 14:02:22 +00:00
it('should edit the user local warehouse', async() => {
2020-01-09 12:07:16 +00:00
await page.waitForSpinnerLoad();
await page.waitToClick(selectors.globalItems.userMenuButton);
await page.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four');
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-02-07 14:02:22 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2019-02-07 14:02:22 +00:00
});
it('should check the local settings were saved', async() => {
2020-01-09 12:07:16 +00:00
const userLocalWarehouse = await page
.waitToGetProperty(selectors.globalItems.userLocalWarehouse, 'value');
2019-02-07 14:02:22 +00:00
2020-02-12 13:36:05 +00:00
await page.closePopup();
2019-02-07 14:02:22 +00:00
expect(userLocalWarehouse).toContain('Warehouse Four');
});
2020-10-08 14:00:19 +00:00
it('should search for a specific item', async() => {
2020-03-17 13:01:25 +00:00
await page.accessToSearchResult('Ranged weapon pistol 9mm');
await page.waitForState('item.card.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() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemDescriptor.moreMenu);
await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton);
2020-02-03 14:55:11 +00:00
const result = await page.waitToGetProperty(selectors.itemDescriptor.regularizeWarehouse, 'value');
2019-02-07 14:02:22 +00:00
expect(result).toEqual('Warehouse Four');
});
it('should regularize the item', async() => {
2020-02-03 14:55:11 +00:00
await page.write(selectors.itemDescriptor.regularizeQuantity, '100');
await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouse, 'Warehouse One');
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-14 17:05:24 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2018-11-14 17:05:24 +00:00
});
2019-01-07 08:33:07 +00:00
it('should click on the Tickets button of the top bar menu', async() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
2020-01-09 12:07:16 +00:00
await Promise.all([
page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
page.waitToClick(selectors.globalItems.ticketsButton)
]);
await page.waitForState('ticket.index');
2018-11-14 17:05:24 +00:00
});
2019-12-31 11:00:16 +00:00
it('should clear the user local settings now', async() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.globalItems.userMenuButton);
await page.waitForContentLoaded();
2020-01-09 12:07:16 +00:00
await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-02-07 14:02:22 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2019-02-07 14:02:22 +00:00
});
2019-01-07 08:33:07 +00:00
it('should search for the ticket with alias missing', async() => {
2020-01-09 12:07:16 +00:00
await page.keyboard.press('Escape');
2020-03-17 13:01:25 +00:00
await page.accessToSearchResult('missing');
await page.waitForState('ticket.card.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() => {
2020-01-09 12:07:16 +00:00
await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100');
const result = await page
.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() => {
2020-01-09 12:07:16 +00:00
const result = await page
.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() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.globalItems.itemsButton);
await page.waitForState('item.index');
2018-11-14 17:05:24 +00:00
});
2019-01-10 06:26:10 +00:00
it('should search for the item once again', async() => {
2020-03-17 13:01:25 +00:00
await page.accessToSearchResult('Ranged weapon pistol 9mm');
await page.waitForState('item.card.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() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemDescriptor.moreMenu);
await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton);
2020-02-03 14:55:11 +00:00
await page.write(selectors.itemDescriptor.regularizeQuantity, '100');
await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouse, 'Warehouse One');
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2018-11-14 17:05:24 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2018-11-14 17:05:24 +00:00
});
2019-01-07 08:33:07 +00:00
it('should again click on the Tickets button of the top bar menu', async() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.waitForSelector(selectors.globalItems.applicationsMenuVisible);
2020-01-09 12:07:16 +00:00
await Promise.all([
page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
page.waitToClick(selectors.globalItems.ticketsButton)
]);
await page.waitForState('ticket.index');
2018-11-14 17:05:24 +00:00
});
it('should search for the ticket with id 25 once again', async() => {
2020-03-17 13:01:25 +00:00
await page.accessToSearchResult('25');
await page.waitForState('ticket.card.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() => {
2020-01-09 12:07:16 +00:00
await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100');
const result = await page.countElement(selectors.ticketSummary.sale);
2018-11-14 17:05:24 +00:00
expect(result).toEqual(2);
});
});