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

67 lines
2.5 KiB
JavaScript

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