salix/e2e/paths/04-item/10_index.spec.js

86 lines
4.0 KiB
JavaScript
Raw Normal View History

2019-03-06 08:50:12 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2019-03-06 08:50:12 +00:00
2020-03-17 10:00:16 +00:00
describe('Item index 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('salesPerson', 'item');
2020-10-01 06:53:31 +00:00
await page.waitToClick(selectors.globalItems.searchButton);
2020-01-09 12:07:16 +00:00
});
2019-03-06 08:50:12 +00:00
2020-01-09 12:07:16 +00:00
afterAll(async() => {
await browser.close();
2019-03-06 08:50:12 +00:00
});
it('should click on the fields to show button to open the list of columns to show', async() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.fieldsToShowButton);
const visible = await page.isVisible(selectors.itemsIndex.fieldsToShowForm);
2019-03-06 08:50:12 +00:00
expect(visible).toBeTruthy();
});
it('should unmark all checkboxes except the first and the last ones', async() => {
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.idCheckbox);
await page.waitToClick(selectors.itemsIndex.stemsCheckbox);
await page.waitToClick(selectors.itemsIndex.sizeCheckbox);
await page.waitToClick(selectors.itemsIndex.nicheCheckbox);
await page.waitToClick(selectors.itemsIndex.typeCheckbox);
await page.waitToClick(selectors.itemsIndex.categoryCheckbox);
await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
await page.waitToClick(selectors.itemsIndex.originCheckbox);
await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
await page.waitToClick(selectors.itemsIndex.destinyCheckbox);
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-03-06 08:50:12 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2019-03-06 08:50:12 +00:00
});
it('should navigate forth and back to see the images column is still visible', async() => {
2020-03-17 10:00:16 +00:00
await page.waitToClick(selectors.itemsIndex.firstSearchResult);
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
2020-10-01 06:53:31 +00:00
await page.waitToClick(selectors.globalItems.searchButton);
2020-01-09 12:07:16 +00:00
await page.wait(selectors.itemsIndex.searchResult);
await page.waitImgLoad(selectors.itemsIndex.firstItemImage);
const imageVisible = await page.isVisible(selectors.itemsIndex.firstItemImageTd);
2019-03-06 08:50:12 +00:00
expect(imageVisible).toBeTruthy();
});
it('should check the ids column is not visible', async() => {
await page.waitForSelector(selectors.itemsIndex.firstItemId, {hidden: true});
2019-03-06 08:50:12 +00:00
});
2020-03-17 10:00:16 +00:00
it('should mark all unchecked boxes to leave the index as it was', async() => {
2020-09-03 09:53:39 +00:00
await page.waitFor(500); // otherwise the snackbar doesnt appear some times.
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemsIndex.fieldsToShowButton);
await page.waitToClick(selectors.itemsIndex.idCheckbox);
await page.waitToClick(selectors.itemsIndex.stemsCheckbox);
await page.waitToClick(selectors.itemsIndex.sizeCheckbox);
await page.waitToClick(selectors.itemsIndex.nicheCheckbox);
await page.waitToClick(selectors.itemsIndex.typeCheckbox);
await page.waitToClick(selectors.itemsIndex.categoryCheckbox);
await page.waitToClick(selectors.itemsIndex.intrastadCheckbox);
await page.waitToClick(selectors.itemsIndex.originCheckbox);
await page.waitToClick(selectors.itemsIndex.buyerCheckbox);
await page.waitToClick(selectors.itemsIndex.destinyCheckbox);
await page.waitToClick(selectors.itemsIndex.saveFieldsButton);
2020-04-08 09:24:40 +00:00
const message = await page.waitForSnackbar();
2019-03-06 08:50:12 +00:00
2020-11-10 11:06:21 +00:00
expect(message.text).toContain('Data saved!');
2019-03-06 08:50:12 +00:00
});
it('should now navigate forth and back to see the ids column is now visible', async() => {
2020-03-17 10:00:16 +00:00
await page.waitToClick(selectors.itemsIndex.firstSearchResult);
2020-01-09 12:07:16 +00:00
await page.waitToClick(selectors.itemDescriptor.goBackToModuleIndexButton);
2020-10-01 06:53:31 +00:00
await page.waitToClick(selectors.globalItems.searchButton);
2020-01-09 12:07:16 +00:00
await page.wait(selectors.itemsIndex.searchResult);
const idVisible = await page.isVisible(selectors.itemsIndex.firstItemId);
2019-03-06 08:50:12 +00:00
expect(idVisible).toBeTruthy();
});
});