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

198 lines
8.3 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');
const result = await page.waitForLastSnackbar();
2019-02-07 14:02:22 +00:00
expect(result).toEqual('Data saved!');
});
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-01-09 12:07:16 +00:00
it('should search for an specific item', async() => {
2020-02-03 14:55:11 +00:00
await page.clearInput(selectors.itemsIndex.topbarSearch);
await page.write(selectors.itemsIndex.topbarSearch, 'Ranged weapon pistol 9mm');
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.searchButton);
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
const resultCount = await page.countElement(selectors.itemsIndex.searchResult);
2018-11-14 17:05:24 +00:00
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() => {
2020-01-09 12:07:16 +00:00
await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm');
await page.waitToClick(selectors.itemsIndex.searchResult);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('/summary');
2018-11-14 17:05:24 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
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);
const result = await page.waitForLastSnackbar();
2018-11-14 17:05:24 +00:00
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() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await Promise.all([
page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
page.waitToClick(selectors.globalItems.ticketsButton)
]);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('#!/ticket/index');
2018-11-14 17:05:24 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
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.clearInput(selectors.globalItems.userConfigFirstAutocomplete);
const result = await page.waitForLastSnackbar();
2019-02-07 14:02:22 +00:00
expect(result).toEqual('Data saved!');
});
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-02-03 14:55:11 +00:00
await page.write(selectors.ticketsIndex.topbarSearch, 'missing');
await page.keyboard.press('Enter');
2020-01-09 12:07:16 +00:00
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
2018-11-14 17:05:24 +00:00
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() => {
2020-01-09 12:07:16 +00:00
await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Missing');
await page.waitToClick(selectors.ticketsIndex.searchResult);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('/summary');
2018-11-14 17:05:24 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
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.wait(selectors.globalItems.applicationsMenuVisible);
await page.waitToClick(selectors.globalItems.itemsButton);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('#!/item/index');
2018-11-14 17:05:24 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
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-02-03 14:55:11 +00:00
await page.clearInput(selectors.itemsIndex.topbarSearch);
await page.write(selectors.itemsIndex.topbarSearch, 'Ranged weapon pistol 9mm');
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.searchButton);
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
const resultCount = await page.countElement(selectors.itemsIndex.searchResult);
2018-11-14 17:05:24 +00:00
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() => {
2020-01-09 12:07:16 +00:00
await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm');
await page.waitToClick(selectors.itemsIndex.searchResult);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('/summary');
2018-11-14 17:05:24 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
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);
const result = await page.waitForLastSnackbar();
2018-11-14 17:05:24 +00:00
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() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
await page.wait(selectors.globalItems.applicationsMenuVisible);
await Promise.all([
page.waitForNavigation({waitUntil: ['load', 'networkidle0', 'domcontentloaded']}),
page.waitToClick(selectors.globalItems.ticketsButton)
]);
await page.waitForTransitionEnd('vn-searchbar');
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('#!/ticket/index');
2018-11-14 17:05:24 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
2018-11-14 17:05:24 +00:00
});
it('should search for the ticket with id 25 once again', async() => {
2020-02-03 14:55:11 +00:00
await page.write(selectors.ticketsIndex.topbarSearch, '25');
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.ticketsIndex.searchButton);
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
const result = await page.countElement(selectors.ticketsIndex.searchResult);
2018-11-14 17:05:24 +00:00
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() => {
2020-01-09 12:07:16 +00:00
await page.waitForTextInElement(selectors.ticketsIndex.searchResult, '25');
await page.waitToClick(selectors.ticketsIndex.searchResult);
2020-02-04 15:21:10 +00:00
let url = await page.expectURL('/summary');
2018-11-14 17:05:24 +00:00
2020-02-04 15:21:10 +00:00
expect(url).toBe(true);
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);
});
});