salix/e2e/paths/04-item/13_fixedPrice.spec.js

98 lines
3.1 KiB
JavaScript
Raw Permalink Normal View History

2021-01-19 19:56:33 +00:00
import selectors from '../../helpers/selectors.js';
import getBrowser from '../../helpers/puppeteer';
2023-05-05 06:12:38 +00:00
const $ = selectors.itemFixedPrice;
2021-01-19 19:56:33 +00:00
describe('Item fixed prices path', () => {
let browser;
let page;
2023-03-27 10:12:42 +00:00
let httpRequest;
2021-01-19 19:56:33 +00:00
beforeAll(async() => {
browser = await getBrowser();
page = browser.page;
await page.loginAndModule('buyer', 'item');
await page.accessToSection('item.fixedPrice');
2023-03-27 10:12:42 +00:00
page.on('request', req => {
if (req.url().includes(`FixedPrices/filter`))
httpRequest = req.url();
});
2021-01-19 19:56:33 +00:00
});
afterAll(async() => {
await browser.close();
});
2023-03-27 10:12:42 +00:00
it('should filter using all the fields', async() => {
2023-05-05 06:12:38 +00:00
await page.write($.generalSearchFilter, 'item');
2023-03-27 10:12:42 +00:00
await page.keyboard.press('Enter');
expect(httpRequest).toContain('search=item');
2023-05-05 06:12:38 +00:00
await page.click($.chip);
await page.click($.reignFilter);
2023-03-27 10:12:42 +00:00
expect(httpRequest).toContain('categoryFk');
2023-05-05 06:12:38 +00:00
await page.autocompleteSearch($.typeFilter, 'Alstroemeria');
2023-03-27 10:12:42 +00:00
expect(httpRequest).toContain('typeFk');
2023-05-05 06:12:38 +00:00
await page.click($.chip);
await page.autocompleteSearch($.buyerFilter, 'buyerNick');
2023-03-27 10:12:42 +00:00
expect(httpRequest).toContain('buyerFk');
2023-05-05 06:12:38 +00:00
await page.click($.chip);
await page.autocompleteSearch($.warehouseFilter, 'Algemesi');
2023-03-27 10:12:42 +00:00
expect(httpRequest).toContain('warehouseFk');
2023-05-05 06:12:38 +00:00
await page.click($.chip);
await page.click($.mineFilter);
2023-03-27 10:12:42 +00:00
expect(httpRequest).toContain('mine=true');
2023-05-05 06:12:38 +00:00
await page.click($.chip);
await page.click($.hasMinPriceFilter);
2023-03-27 10:12:42 +00:00
expect(httpRequest).toContain('hasMinPrice=true');
2023-05-05 06:12:38 +00:00
await page.click($.chip);
await page.click($.addTag);
await page.autocompleteSearch($.tagFilter, 'Color');
await page.autocompleteSearch($.tagValueFilter, 'Brown');
2023-03-27 10:12:42 +00:00
expect(httpRequest).toContain('tags');
2023-05-05 06:12:38 +00:00
await page.click($.chip);
2023-03-27 10:12:42 +00:00
});
it('should click on the add new fixed price button', async() => {
2023-05-05 06:12:38 +00:00
await page.waitToClick($.add);
await page.waitForSelector($.fourthFixedPrice);
2021-01-19 19:56:33 +00:00
});
it('should fill the fixed price data', async() => {
2023-01-16 14:18:24 +00:00
const now = Date.vnNew();
2023-05-05 06:12:38 +00:00
await page.autocompleteSearch($.fourthWarehouse, 'Warehouse one');
await page.writeOnEditableTD($.fourthGroupingPrice, '1');
await page.writeOnEditableTD($.fourthPackingPrice, '1');
await page.write($.fourthMinPrice, '1');
await page.pickDate($.fourthStarted, now);
await page.pickDate($.fourthEnded, now);
2021-01-19 19:56:33 +00:00
const message = await page.waitForSnackbar();
expect(message.text).toContain('Data saved!');
});
it('should reload the section and check the created price has the expected ID', async() => {
2023-03-27 10:12:42 +00:00
await page.goto(`http://localhost:5000/#!/item/fixed-price`);
2023-05-26 09:53:32 +00:00
await page.autocompleteSearch($.warehouseFilter, 'Warehouse one');
await page.click($.chip);
2023-05-05 06:12:38 +00:00
const result = await page.waitToGetProperty($.fourthItemID, 'value');
2021-01-19 19:56:33 +00:00
expect(result).toContain('13');
});
});