63 lines
2.5 KiB
JavaScript
63 lines
2.5 KiB
JavaScript
import selectors from '../../helpers/selectors.js';
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
describe('Entry import buys path', () => {
|
|
let browser;
|
|
let page;
|
|
|
|
beforeAll(async() => {
|
|
browser = await getBrowser();
|
|
page = browser.page;
|
|
await page.loginAndModule('buyer', 'entry');
|
|
await page.accessToSearchResult('1');
|
|
});
|
|
|
|
afterAll(async() => {
|
|
await browser.close();
|
|
});
|
|
|
|
it('should count the summary buys and find there only one at this point', async() => {
|
|
const buysCount = await page.countElement(selectors.entrySummary.anyBuyLine);
|
|
|
|
expect(buysCount).toEqual(1);
|
|
});
|
|
|
|
it('should navigate to the buy section and then click the import button opening the import form', async() => {
|
|
await page.accessToSection('entry.card.buy.index');
|
|
await page.waitToClick(selectors.entryBuys.importButton);
|
|
await page.waitForState('entry.card.buy.import');
|
|
});
|
|
|
|
it('should fill the form, import the designated JSON file and select items for each import and confirm import', async() => {
|
|
await page.write(selectors.entryBuys.ref, 'a reference');
|
|
await page.write(selectors.entryBuys.observation, 'an observation');
|
|
|
|
let currentDir = process.cwd();
|
|
let filePath = `${currentDir}/e2e/assets/07_import_buys.json`;
|
|
|
|
const [fileChooser] = await Promise.all([
|
|
page.waitForFileChooser(),
|
|
page.waitToClick(selectors.entryBuys.file)
|
|
]);
|
|
await fileChooser.accept([filePath]);
|
|
|
|
await page.autocompleteSearch(selectors.entryBuys.firstImportedItem, 'Ranged Reinforced weapon pistol 9mm');
|
|
await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, 'Melee Reinforced weapon heavy shield 1x0.5m');
|
|
await page.autocompleteSearch(selectors.entryBuys.thirdImportedItem, 'Container medical box 1m');
|
|
await page.autocompleteSearch(selectors.entryBuys.fourthImportedItem, 'Container ammo box 1m');
|
|
|
|
await page.waitToClick(selectors.entryBuys.importBuysButton);
|
|
|
|
const message = await page.waitForSnackbar();
|
|
const state = await page.getState();
|
|
|
|
expect(message.text).toContain('Data saved!');
|
|
expect(state).toBe('entry.card.buy.index');
|
|
});
|
|
|
|
it('should navigate to the entry summary and count the buys to find 4 buys have been added', async() => {
|
|
await page.waitToClick('vn-icon[icon="preview"]');
|
|
await page.waitForNumberOfElements(selectors.entrySummary.anyBuyLine, 5);
|
|
});
|
|
});
|