205 lines
8.8 KiB
JavaScript
205 lines
8.8 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Item regularize path', () => {
|
|
let browser;
|
|
let page;
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
await page.loginAndModule('employee', 'item');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
it('should edit the user local warehouse', async() => {
|
|
await page.waitForSpinnerLoad();
|
|
await page.waitToClick(selectors.globalItems.userMenuButton);
|
|
await page.autocompleteSearch(selectors.globalItems.userLocalWarehouse, 'Warehouse Four');
|
|
const result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should check the local settings were saved', async() => {
|
|
const userLocalWarehouse = await page
|
|
.waitToGetProperty(selectors.globalItems.userLocalWarehouse, 'value');
|
|
|
|
await page.keyboard.press('Escape');
|
|
await page.waitForSelector('.user-popover.vn-popover', {hidden: true});
|
|
|
|
expect(userLocalWarehouse).toContain('Warehouse Four');
|
|
});
|
|
|
|
it('should search for an specific item', async() => {
|
|
await page.clearInput(selectors.itemsIndex.searchItemInput);
|
|
await page.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm');
|
|
await page.waitToClick(selectors.itemsIndex.searchButton);
|
|
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
|
|
const resultCount = await page.countElement(selectors.itemsIndex.searchResult);
|
|
|
|
expect(resultCount).toEqual(1);
|
|
});
|
|
|
|
it(`should click on the search result to access to the item tax`, async() => {
|
|
await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm');
|
|
await page.waitToClick(selectors.itemsIndex.searchResult);
|
|
await page.waitForURL('/summary');
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/summary');
|
|
});
|
|
|
|
it('should open the regularize dialog and check the warehouse matches the local user settings', async() => {
|
|
await page.waitToClick(selectors.itemDescriptor.moreMenu);
|
|
await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton);
|
|
const result = await page.waitToGetProperty(selectors.itemDescriptor.regularizeWarehouseAutocomplete, 'value');
|
|
|
|
expect(result).toEqual('Warehouse Four');
|
|
});
|
|
|
|
it('should regularize the item', async() => {
|
|
await page.write(selectors.itemDescriptor.regularizeQuantityInput, '100');
|
|
await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouseAutocomplete, 'Warehouse One');
|
|
await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
|
|
const result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should click on the Tickets button of the top bar menu', async() => {
|
|
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)
|
|
]);
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/ticket/index');
|
|
});
|
|
|
|
it('should clear the user local settings now', async() => {
|
|
await page.waitForTransitionEnd('vn-searchbar');
|
|
await page.waitToClick(selectors.globalItems.userMenuButton);
|
|
await page.clearInput(selectors.globalItems.userConfigFirstAutocomplete);
|
|
const result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should search for the ticket with alias missing', async() => {
|
|
await page.keyboard.press('Escape');
|
|
await page.write(selectors.ticketsIndex.searchTicketInput, 'missing');
|
|
await page.keyboard.press('Enter');
|
|
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
|
|
const result = await page.countElement(selectors.ticketsIndex.searchResult);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it(`should click on the search result to access to the ticket summary`, async() => {
|
|
await page.waitForTextInElement(selectors.ticketsIndex.searchResult, 'Missing');
|
|
await page.waitToClick(selectors.ticketsIndex.searchResult);
|
|
await page.waitForURL('/summary');
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/summary');
|
|
});
|
|
|
|
it(`should check the ticket sale quantity is showing a negative value`, async() => {
|
|
await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100');
|
|
const result = await page
|
|
.waitToGetProperty(selectors.ticketSummary.firstSaleQuantity, 'innerText');
|
|
|
|
expect(result).toContain('-100');
|
|
});
|
|
|
|
it(`should check the ticket sale discount is 100%`, async() => {
|
|
const result = await page
|
|
.waitToGetProperty(selectors.ticketSummary.firstSaleDiscount, 'innerText');
|
|
|
|
expect(result).toContain('100 %');
|
|
});
|
|
|
|
it('should now click on the Items button of the top bar menu', async() => {
|
|
await page.waitToClick(selectors.globalItems.applicationsMenuButton);
|
|
await page.wait(selectors.globalItems.applicationsMenuVisible);
|
|
await page.waitToClick(selectors.globalItems.itemsButton);
|
|
await page.wait(selectors.itemsIndex.searchItemInput);
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/item/index');
|
|
});
|
|
|
|
it('should search for the item once again', async() => {
|
|
await page.clearInput(selectors.itemsIndex.searchItemInput);
|
|
await page.write(selectors.itemsIndex.searchItemInput, 'Ranged weapon pistol 9mm');
|
|
await page.waitToClick(selectors.itemsIndex.searchButton);
|
|
await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 1);
|
|
const resultCount = await page.countElement(selectors.itemsIndex.searchResult);
|
|
|
|
expect(resultCount).toEqual(1);
|
|
});
|
|
|
|
it(`should click on the search result to access to the item tax`, async() => {
|
|
await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon pistol 9mm');
|
|
await page.waitToClick(selectors.itemsIndex.searchResult);
|
|
await page.waitForURL('/summary');
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/summary');
|
|
});
|
|
|
|
it('should regularize the item once more', async() => {
|
|
await page.waitToClick(selectors.itemDescriptor.moreMenu);
|
|
await page.waitToClick(selectors.itemDescriptor.moreMenuRegularizeButton);
|
|
await page.write(selectors.itemDescriptor.regularizeQuantityInput, '100');
|
|
await page.autocompleteSearch(selectors.itemDescriptor.regularizeWarehouseAutocomplete, 'Warehouse One');
|
|
await page.waitToClick(selectors.itemDescriptor.regularizeSaveButton);
|
|
const result = await page.waitForLastSnackbar();
|
|
|
|
expect(result).toEqual('Data saved!');
|
|
});
|
|
|
|
it('should again click on the Tickets button of the top bar menu', async() => {
|
|
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');
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toEqual('#!/ticket/index');
|
|
});
|
|
|
|
it('should search for the ticket with id 25 once again', async() => {
|
|
await page.write(selectors.ticketsIndex.searchTicketInput, '25');
|
|
await page.waitToClick(selectors.ticketsIndex.searchButton);
|
|
await page.waitForNumberOfElements(selectors.ticketsIndex.searchResult, 1);
|
|
const result = await page.countElement(selectors.ticketsIndex.searchResult);
|
|
|
|
expect(result).toEqual(1);
|
|
});
|
|
|
|
it(`should now click on the search result to access to the ticket summary`, async() => {
|
|
await page.waitForTextInElement(selectors.ticketsIndex.searchResult, '25');
|
|
await page.waitToClick(selectors.ticketsIndex.searchResult);
|
|
await page.waitForURL('/summary');
|
|
const url = await page.parsedUrl();
|
|
|
|
expect(url.hash).toContain('/summary');
|
|
});
|
|
|
|
it(`should check the ticket contains now two sales`, async() => {
|
|
await page.waitForTextInElement(selectors.ticketSummary.firstSaleQuantity, '-100');
|
|
const result = await page.countElement(selectors.ticketSummary.sale);
|
|
|
|
expect(result).toEqual(2);
|
|
});
|
|
});
|