salix/e2e/paths/04-item-module/06_botanical.spec.js

88 lines
3.5 KiB
JavaScript

import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
describe('Item Create botanical path', () => {
let browser;
let page;
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
await page.accessToSearchResult('Ranged weapon pistol 9mm');
await page.accessToSection('item.card.botanical');
});
afterAll(async() => {
await browser.close();
});
it(`should create a new botanical for the item`, async() => {
await page.write(selectors.itemBotanical.botanicalInput, 'Cicuta maculata');
await page.autocompleteSearch(selectors.itemBotanical.genusAutocomplete, 'Abelia');
await page.autocompleteSearch(selectors.itemBotanical.speciesAutocomplete, 'dealbata');
await page.waitToClick(selectors.itemBotanical.submitBotanicalButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the botanical for the item was created`, async() => {
await page.reloadSection('item.card.botanical');
await page.waitForTextInField(selectors.itemBotanical.botanicalInput, 'Cicuta maculata');
const result = await page
.waitToGetProperty(selectors.itemBotanical.botanicalInput, 'value');
expect(result).toEqual('Cicuta maculata');
});
it(`should confirm the Genus for the item was created`, async() => {
await page.waitForTextInField(selectors.itemBotanical.genusAutocomplete, 'Abelia');
const result = await page
.waitToGetProperty(selectors.itemBotanical.genusAutocomplete, 'value');
expect(result).toEqual('Abelia');
});
it(`should confirm the Species for the item was created`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBotanical.speciesAutocomplete, 'value');
expect(result).toEqual('dealbata');
});
it(`should edit botanical for the item`, async() => {
await page.clearInput(selectors.itemBotanical.botanicalInput);
await page.write(selectors.itemBotanical.botanicalInput, 'Herp Derp');
await page.autocompleteSearch(selectors.itemBotanical.genusAutocomplete, 'Abies');
await page.autocompleteSearch(selectors.itemBotanical.speciesAutocomplete, 'decurrens');
await page.waitToClick(selectors.itemBotanical.submitBotanicalButton);
const result = await page.waitForLastSnackbar();
expect(result).toEqual('Data saved!');
});
it(`should confirm the botanical for the item was edited`, async() => {
await page.reloadSection('item.card.botanical');
await page.waitForTextInField(selectors.itemBotanical.botanicalInput, 'Herp Derp');
const result = await page
.waitToGetProperty(selectors.itemBotanical.botanicalInput, 'value');
expect(result).toEqual('Herp Derp');
});
it(`should confirm the Genus for the item was edited`, async() => {
await page.waitForTextInField(selectors.itemBotanical.genusAutocomplete, 'Abies');
const result = await page
.waitToGetProperty(selectors.itemBotanical.genusAutocomplete, 'value');
expect(result).toEqual('Abies');
});
it(`should confirm the Species for the item was edited`, async() => {
const result = await page
.waitToGetProperty(selectors.itemBotanical.speciesAutocomplete, 'value');
expect(result).toEqual('decurrens');
});
});