import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Item fixed prices path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('buyer', 'item'); await page.accessToSection('item.fixedPrice'); }); afterAll(async() => { await browser.close(); }); it('should click on the add new foxed price button', async() => { await page.waitToClick(selectors.itemFixedPrice.add); await page.waitForSelector(selectors.itemFixedPrice.fourthFixedPrice); }); it('should fill the fixed price data', async() => { const now = new Date(); const searchValue = 'Chest ammo box'; await page.waitToClick(selectors.itemFixedPrice.fourthItemID); await page.write('body > div > div > div.content > div.filter.ng-scope > vn-textfield', searchValue); try { await page.waitForFunction(searchValue => { const element = document.querySelector('li.active'); if (element) return element.innerText.toLowerCase().includes(searchValue.toLowerCase()); }, {}, searchValue); } catch (error) { const builtSelector = await page.selectorFormater(selectors.ticketSales.moreMenuState); const inputValue = await page.evaluate(() => { return document.querySelector('.vn-drop-down.shown vn-textfield input').value; }); throw new Error(`${builtSelector} value is ${inputValue}! ${error}`); } await page.keyboard.press('Enter'); await page.autocompleteSearch(selectors.itemFixedPrice.fourthWarehouse, 'Warehouse one'); await page.writeOnEditableTD(selectors.itemFixedPrice.fourthPPU, '20'); await page.writeOnEditableTD(selectors.itemFixedPrice.fourthPPP, '10'); await page.writeOnEditableTD(selectors.itemFixedPrice.fourthMinPrice, '5'); await page.pickDate(selectors.itemFixedPrice.fourthStarted, now); await page.pickDate(selectors.itemFixedPrice.fourthEnded, now); await page.waitForTimeout(1000); 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() => { await page.accessToSection('item.index'); await page.accessToSection('item.fixedPrice'); const result = await page.getProperty('vn-fixed-price > div > vn-card > vn-table > div > vn-tbody > vn-tr:nth-child(4) > vn-td:nth-child(1) > span', 'innerText'); expect(result).toContain('13'); }); });