2020-08-28 17:52:54 +00:00
|
|
|
import selectors from '../../helpers/selectors.js';
|
|
|
|
import getBrowser from '../../helpers/puppeteer';
|
|
|
|
|
|
|
|
describe('Entry lastest buys path', () => {
|
|
|
|
let browser;
|
|
|
|
let page;
|
2023-02-03 14:21:27 +00:00
|
|
|
const httpRequests = [];
|
2020-08-28 17:52:54 +00:00
|
|
|
|
|
|
|
beforeAll(async() => {
|
|
|
|
browser = await getBrowser();
|
|
|
|
page = browser.page;
|
2023-02-03 14:21:27 +00:00
|
|
|
page.on('request', req => {
|
|
|
|
if (req.url().includes(`Buys/latestBuysFilter`))
|
|
|
|
httpRequests.push(req.url());
|
|
|
|
});
|
2020-08-28 17:52:54 +00:00
|
|
|
await page.loginAndModule('buyer', 'entry');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async() => {
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should access the latest buys seccion and search not seeing the edit buys button yet', async() => {
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.latestBuysSectionButton);
|
|
|
|
await page.waitForSelector(selectors.entryLatestBuys.editBuysButton, {visible: false});
|
|
|
|
});
|
|
|
|
|
2023-02-03 14:21:27 +00:00
|
|
|
it('should filter by name', async() => {
|
|
|
|
await page.write(selectors.entryLatestBuys.generalSearchInput, 'Melee');
|
|
|
|
await page.keyboard.press('Enter');
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('search=Melee')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should filter by reign and type', async() => {
|
|
|
|
await page.click(selectors.entryLatestBuys.firstReignIcon);
|
|
|
|
await page.autocompleteSearch(selectors.entryLatestBuys.typeInput, 'Alstroemeria');
|
|
|
|
await page.click(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('categoryFk')))).toBeDefined();
|
|
|
|
expect(httpRequests.find(req => req.includes(('typeFk')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should filter by from date', async() => {
|
|
|
|
await page.pickDate(selectors.entryLatestBuys.fromInput, new Date());
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('from')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should filter by to date', async() => {
|
|
|
|
await page.pickDate(selectors.entryLatestBuys.toInput, new Date());
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('to')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should filter by sales person', async() => {
|
|
|
|
await page.autocompleteSearch(selectors.entryLatestBuys.salesPersonInput, 'buyerNick');
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('salesPersonFk')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should filter by supplier', async() => {
|
|
|
|
await page.autocompleteSearch(selectors.entryLatestBuys.supplierInput, 'Farmer King');
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('supplierFk')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should filter by active', async() => {
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.activeCheck);
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.activeCheck);
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('active=true')))).toBeDefined();
|
|
|
|
expect(httpRequests.find(req => req.includes(('active=false')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should filter by visible', async() => {
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.visibleCheck);
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.visibleCheck);
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('visible=true')))).toBeDefined();
|
|
|
|
expect(httpRequests.find(req => req.includes(('visible=false')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should filter by floramondo', async() => {
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.floramondoCheck);
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.floramondoCheck);
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('floramondo=true')))).toBeDefined();
|
|
|
|
expect(httpRequests.find(req => req.includes(('floramondo=false')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should filter by tag Color', async() => {
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.addTagButton);
|
|
|
|
await page.autocompleteSearch(selectors.entryLatestBuys.itemTagInput, 'Color');
|
|
|
|
await page.autocompleteSearch(selectors.entryLatestBuys.itemTagValueInput, 'Brown');
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.chip);
|
|
|
|
|
|
|
|
expect(httpRequests.find(req => req.includes(('tags')))).toBeDefined();
|
|
|
|
});
|
|
|
|
|
2020-08-28 17:52:54 +00:00
|
|
|
it('should select all lines but one and then check the edit buys button appears', async() => {
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.allBuysCheckBox);
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.secondBuyCheckBox);
|
|
|
|
await page.waitForSelector(selectors.entryLatestBuys.editBuysButton, {visible: true});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should open the edit dialog', async() => {
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.editBuysButton);
|
|
|
|
await page.waitForSelector(selectors.entryLatestBuys.fieldAutocomplete, {visible: true});
|
|
|
|
});
|
|
|
|
|
2021-11-12 15:13:47 +00:00
|
|
|
it('should search for the "Description" and type a new one for the items in each selected buy', async() => {
|
2020-08-28 17:52:54 +00:00
|
|
|
await page.autocompleteSearch(selectors.entryLatestBuys.fieldAutocomplete, 'Description');
|
|
|
|
await page.write(selectors.entryLatestBuys.newValueInput, 'Crafted item');
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.acceptEditBuysDialog);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should navigate to the entry.buy section by clicking one of the buys', async() => {
|
|
|
|
await page.waitToClick(selectors.entryLatestBuys.firstBuy);
|
2021-03-12 07:45:41 +00:00
|
|
|
await page.waitForState('entry.card.buy.index');
|
2020-08-28 17:52:54 +00:00
|
|
|
});
|
|
|
|
});
|