salix/e2e/paths/04-item-module/10_item_index.spec.js

89 lines
3.8 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Item index path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('salesPerson', 'item')
.waitToClick(selectors.itemsIndex.searchIcon);
});
it('should click on the fields to show button to open the list of columns to show', async() => {
const visible = await nightmare
.waitToClick(selectors.itemsIndex.fieldsToShowButton)
.isVisible(selectors.itemsIndex.fieldsToShowForm);
expect(visible).toBeTruthy();
});
it('should unmark all checkboxes except the first and the last ones', async() => {
const result = await nightmare
.waitToClick(selectors.itemsIndex.idCheckbox)
.waitToClick(selectors.itemsIndex.stemsCheckbox)
.waitToClick(selectors.itemsIndex.sizeCheckbox)
.waitToClick(selectors.itemsIndex.nicheCheckbox)
.waitToClick(selectors.itemsIndex.typeCheckbox)
.waitToClick(selectors.itemsIndex.categoryCheckbox)
.waitToClick(selectors.itemsIndex.intrastadCheckbox)
.waitToClick(selectors.itemsIndex.originCheckbox)
.waitToClick(selectors.itemsIndex.buyerCheckbox)
.waitToClick(selectors.itemsIndex.destinyCheckbox)
// .waitToClick(selectors.itemsIndex.taxClassCheckbox)
.waitToClick(selectors.itemsIndex.saveFieldsButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should navigate forth and back to see the images column is still visible', async() => {
const imageVisible = await nightmare
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton)
.waitToClick(selectors.itemsIndex.searchIcon)
.wait(selectors.itemsIndex.searchResult)
.isVisible(selectors.itemsIndex.firstItemImage);
expect(imageVisible).toBeTruthy();
});
it('should check the ids column is not visible', async() => {
const idVisible = await nightmare
.isVisible(selectors.itemsIndex.firstItemId);
expect(idVisible).toBeFalsy();
});
it('should mark all unchecked boxes to leave the index as it was', async() => {
const result = await nightmare
.waitToClick(selectors.itemsIndex.fieldsToShowButton)
.waitToClick(selectors.itemsIndex.idCheckbox)
.waitToClick(selectors.itemsIndex.stemsCheckbox)
.waitToClick(selectors.itemsIndex.sizeCheckbox)
.waitToClick(selectors.itemsIndex.nicheCheckbox)
.waitToClick(selectors.itemsIndex.typeCheckbox)
.waitToClick(selectors.itemsIndex.categoryCheckbox)
.waitToClick(selectors.itemsIndex.intrastadCheckbox)
.waitToClick(selectors.itemsIndex.originCheckbox)
.waitToClick(selectors.itemsIndex.buyerCheckbox)
.waitToClick(selectors.itemsIndex.destinyCheckbox)
// .waitToClick(selectors.itemsIndex.taxClassCheckbox)
.waitToClick(selectors.itemsIndex.saveFieldsButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it('should now navigate forth and back to see the ids column is now visible', async() => {
const idVisible = await nightmare
.waitToClick(selectors.itemsIndex.searchResult)
.waitToClick(selectors.itemsIndex.goBackToModuleIndexButton)
.waitToClick(selectors.itemsIndex.searchIcon)
.wait(selectors.itemsIndex.searchResult)
.isVisible(selectors.itemsIndex.firstItemId);
expect(idVisible).toBeTruthy();
});
});