2021-04-28 16:29:29 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
|
2021-08-06 10:03:39 +00:00
|
|
|
describe('Entry import, create and edit buys path', () => {
|
2021-04-28 16:29:29 +00:00
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
|
|
|
await page.loginAndModule('buyer', 'entry');
|
2022-01-28 13:11:26 +00:00
|
|
|
await page.accessToSearchResult('3');
|
2021-04-28 16:29:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2022-01-28 13:11:26 +00:00
|
|
|
expect(buysCount).toEqual(2);
|
2021-04-28 16:29:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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');
|
|
|
|
});
|
|
|
|
|
2021-11-12 15:13:47 +00:00
|
|
|
it('should fill the form, import the a JSON file and select items for each import and confirm import', async() => {
|
2021-04-28 16:29:29 +00:00
|
|
|
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]);
|
|
|
|
|
2021-08-05 13:08:53 +00:00
|
|
|
await page.waitForTextInField(selectors.entryBuys.ref, '200573095, 200573106, 200573117, 200573506');
|
|
|
|
await page.waitForTextInField(selectors.entryBuys.observation, '729-6340 2846');
|
|
|
|
|
2022-01-28 13:11:26 +00:00
|
|
|
await page.autocompleteSearch(selectors.entryBuys.firstImportedItem, 'Ranged weapon longbow 2m');
|
2022-02-01 11:45:06 +00:00
|
|
|
await page.autocompleteSearch(selectors.entryBuys.secondImportedItem, 'Ranged weapon longbow 2m');
|
2022-01-28 13:11:26 +00:00
|
|
|
await page.autocompleteSearch(selectors.entryBuys.thirdImportedItem, 'Ranged weapon sniper rifle 300mm');
|
|
|
|
await page.autocompleteSearch(selectors.entryBuys.fourthImportedItem, 'Melee weapon heavy shield 1x0.5m');
|
2021-04-28 16:29:29 +00:00
|
|
|
|
|
|
|
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 count the buys to find 4 buys have been added', async() => {
|
2022-01-28 13:11:26 +00:00
|
|
|
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 6);
|
2021-04-28 16:29:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should delete the four buys that were just added', async() => {
|
|
|
|
await page.waitToClick(selectors.entryBuys.allBuyCheckbox);
|
|
|
|
await page.waitToClick(selectors.entryBuys.firstBuyCheckbox);
|
|
|
|
await page.waitToClick(selectors.entryBuys.deleteBuysButton);
|
|
|
|
await page.waitToClick(selectors.globalItems.acceptButton);
|
|
|
|
await page.waitForNumberOfElements(selectors.entryBuys.anyBuyLine, 1);
|
|
|
|
});
|
|
|
|
});
|