import selectors from '../../helpers/selectors.js'; import getBrowser from '../../helpers/puppeteer'; describe('Item summary path', () => { let browser; let page; beforeAll(async() => { browser = await getBrowser(); page = browser.page; await page.loginAndModule('employee', 'item'); }); afterAll(async() => { await browser.close(); }); it('should search for an item', async() => { await page.clearInput(selectors.itemsIndex.topbarSearch); await page.write(selectors.itemsIndex.topbarSearch, 'Ranged weapon'); await page.waitToClick(selectors.itemsIndex.searchButton); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 3); await page.waitForTextInElement(selectors.itemsIndex.searchResult, 'Ranged weapon'); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); const isVisible = await page.isVisible(selectors.itemSummary.basicData); expect(isVisible).toBeTruthy(); }); it(`should check the item summary preview shows fields from basic data`, async() => { await page.waitForTextInElement(selectors.itemSummary.basicData, 'Ranged weapon longbow 2m'); const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); expect(result).toContain('Ranged weapon longbow 2m'); }); it(`should check the item summary preview shows fields from tags`, async() => { await page.waitForTextInElement(selectors.itemSummary.tags, 'Brown'); const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText'); expect(result).toContain('Brown'); }); it(`should check the item summary preview shows fields from niche`, async() => { await page.waitForTextInElement(selectors.itemSummary.niche, 'A1'); const result = await page.waitToGetProperty(selectors.itemSummary.niche, 'innerText'); expect(result).toContain('A1'); }); it(`should check the item summary preview shows fields from botanical`, async() => { await page.waitForTextInElement(selectors.itemSummary.botanical, 'Hedera helix'); const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText'); expect(result).toContain('Hedera helix'); }); it(`should check the item summary preview shows fields from barcode`, async() => { await page.waitForTextInElement(selectors.itemSummary.barcode, '1'); const result = await page.waitToGetProperty(selectors.itemSummary.barcode, 'innerText'); expect(result).toContain('1'); }); it(`should close the summary popup`, async() => { await page.closePopup(); await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true}); }); it('should search for other item', async() => { await page.clearInput('vn-searchbar'); await page.write(selectors.itemsIndex.topbarSearch, 'Melee Reinforced'); await page.keyboard.press('Enter'); await page.waitForNumberOfElements(selectors.itemsIndex.searchResult, 2); await page.waitToClick(selectors.itemsIndex.firstResultPreviewButton); await page.waitForSelector(selectors.itemSummary.basicData, {visible: true}); }); it(`should now check the item summary preview shows fields from basic data`, async() => { await page.waitForTextInElement(selectors.itemSummary.basicData, 'Melee Reinforced weapon combat fist 15cm'); const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); expect(result).toContain('Melee Reinforced weapon combat fist 15cm'); }); it(`should now check the item summary preview shows fields from tags`, async() => { await page.waitForTextInElement(selectors.itemSummary.tags, 'Silver'); const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText'); expect(result).toContain('Silver'); }); it(`should now check the item summary preview shows fields from botanical`, async() => { await page.waitForTextInElement(selectors.itemSummary.botanical, '-'); const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText'); expect(result).toContain('-'); }); it(`should now close the summary popup`, async() => { await page.closePopup(); await page.waitForSelector(selectors.itemSummary.basicData, {hidden: true}); }); it(`should navigate to the one of the items detailed section`, async() => { await page.accessToSearchResult('Melee weapon combat fist 15cm'); await page.waitForState('item.card.summary'); }); it(`should check the descritor edit button is not visible for employee`, async() => { const visibleButton = await page.isVisible(selectors.itemDescriptor.editButton); expect(visibleButton).toBeFalsy(); }); it(`should check the item summary shows fields from basic data section`, async() => { await page.waitForTextInElement(selectors.itemSummary.basicData, 'Melee weapon combat fist 15cm'); const result = await page.waitToGetProperty(selectors.itemSummary.basicData, 'innerText'); expect(result).toContain('Melee weapon combat fist 15cm'); }); it(`should check the item summary shows fields from tags section`, async() => { const result = await page.waitToGetProperty(selectors.itemSummary.tags, 'innerText'); expect(result).toContain('Silver'); }); it(`should check the item summary shows fields from niches section`, async() => { const result = await page.waitToGetProperty(selectors.itemSummary.niche, 'innerText'); expect(result).toContain('One A4'); }); it(`should check the item summary shows fields from botanical section`, async() => { const result = await page.waitToGetProperty(selectors.itemSummary.botanical, 'innerText'); expect(result).toContain('-'); }); it(`should check the item summary shows fields from barcodes section`, async() => { const result = await page.waitToGetProperty(selectors.itemSummary.barcode, 'innerText'); expect(result).toContain('4'); }); });