import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('SmartTable SearchBar integration', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('salesPerson', 'item'); await page.waitToClick(selectors.globalItems.searchButton); }); afterAll(async() => { await browser.close(); }); describe('as filters', () => { it('should search by type in searchBar', async() => { await page.waitToClick(selectors.itemsIndex.openAdvancedSearchButton); await page.autocompleteSearch(selectors.itemsIndex.advancedSearchItemType, 'Anthurium'); await page.waitToClick(selectors.itemsIndex.advancedSearchButton); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3); }); it('should reload page and have same results', async() => { await page.reload({ waitUntil: 'networkidle2' }); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3); }); it('should search by grouping in smartTable', async() => { await page.waitToClick(selectors.itemsIndex.advancedSmartTableButton); await page.write(selectors.itemsIndex.advancedSmartTableGrouping, '1'); await page.keyboard.press('Enter'); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); }); it('should now reload page and have same results', async() => { await page.reload({ waitUntil: 'networkidle2' }); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); }); }); describe('as orders', () => { it('should order by first id', async() => { await page.loginAndModule('developer', 'item'); await page.accessToSection('item.fixedPrice'); await page.doSearch(); const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); expect(result).toEqual('1'); }); it('should order by last id', async() => { await page.waitToClick(selectors.itemFixedPrice.orderColumnId); const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); expect(result).toEqual('13'); }); it('should reload page and have same order', async() => { await page.reload({ waitUntil: 'networkidle2' }); const result = await page.waitToGetProperty(selectors.itemFixedPrice.firstItemID, 'value'); expect(result).toEqual('13'); }); }); });