salix/e2e/paths/04-item-module/05_niche.spec.js

62 lines
2.3 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import createNightmare from '../../helpers/nightmare';
describe('Item create niche path', () => {
const nightmare = createNightmare();
beforeAll(() => {
nightmare
.loginAndModule('buyer', 'item')
.accessToSearchResult('Ranged weapon longbow 2m')
.accessToSection('item.card.niche');
});
it(`should click create a new niche and delete a former one`, async() => {
const result = await nightmare
.waitToClick(selectors.itemNiches.addNicheButton)
.waitToClick(selectors.itemNiches.secondNicheRemoveButton)
.autocompleteSearch(selectors.itemNiches.thirdWarehouseAutocomplete, 'Warehouse Two')
.write(selectors.itemNiches.thirdCodeInput, 'A4')
.waitToClick(selectors.itemNiches.submitNichesButton)
.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the first niche is the expected one`, async() => {
let result = await nightmare
.reloadSection('item.card.niche')
.waitForTextInInput(`${selectors.itemNiches.firstWarehouseAutocomplete} input`, 'Warehouse One')
.waitToGetProperty(`${selectors.itemNiches.firstWarehouseAutocomplete} input`, 'value');
expect(result).toEqual('Warehouse One');
result = await nightmare
.waitToGetProperty(selectors.itemNiches.firstCodeInput, 'value');
expect(result).toEqual('A1');
});
it(`should confirm the second niche is the expected one`, async() => {
let result = await nightmare
.waitToGetProperty(`${selectors.itemNiches.secondWarehouseAutocomplete} input`, 'value');
expect(result).toEqual('Warehouse Three');
result = await nightmare
.waitToGetProperty(selectors.itemNiches.secondCodeInput, 'value');
expect(result).toEqual('A3');
});
it(`should confirm the third niche is the expected one`, async() => {
let result = await nightmare
.waitToGetProperty(`${selectors.itemNiches.thirdWarehouseAutocomplete} input`, 'value');
expect(result).toEqual('Warehouse Two');
result = await nightmare
.waitToGetProperty(selectors.itemNiches.thirdCodeInput, 'value');
expect(result).toEqual('A4');
});
});