import selectors from '../../helpers/selectors.js'; import createNightmare from '../../helpers/nightmare'; describe('Item log path', () => { const nightmare = createNightmare(); beforeAll(() => { nightmare .loginAndModule('developer', 'item'); }); it(`should search for the Knowledge artifact to confirm it isn't created yet`, async() => { const result = await nightmare .write(selectors.itemsIndex.searchItemInput, 'Knowledge artifact') .waitToClick(selectors.itemsIndex.searchButton) .waitForNumberOfElements(selectors.itemsIndex.searchResult, 0) .countElement(selectors.itemsIndex.searchResult); expect(result).toEqual(0); }); it('should access to the create item view by clicking the create floating button', async() => { const url = await nightmare .waitToClick(selectors.itemsIndex.createItemButton) .wait(selectors.itemCreateView.createButton) .parsedUrl(); expect(url.hash).toEqual('#!/item/create'); }); it('should create the Knowledge artifact item', async() => { const result = await nightmare .write(selectors.itemCreateView.temporalName, 'Knowledge artifact') .autocompleteSearch(selectors.itemCreateView.typeAutocomplete, 'Crisantemo') .autocompleteSearch(selectors.itemCreateView.intrastatAutocomplete, 'Coral y materiales similares') .autocompleteSearch(selectors.itemCreateView.originAutocomplete, 'Holand') .waitToClick(selectors.itemCreateView.createButton) .waitForLastSnackbar(); expect(result).toEqual('Data saved!'); }); it('should return to the items index by clicking the return to items button', async() => { const url = await nightmare .waitToClick(selectors.itemBasicData.goToItemIndexButton) .wait(selectors.itemsIndex.createItemButton) .waitForURL('#!/item/index') .parsedUrl(); expect(url.hash).toContain('#!/item/index'); }); it(`should search for the created item and navigate to it's log section`, async() => { const url = await nightmare .accessToSearchResult('Knowledge artifact') .accessToSection('item.card.log') .waitForURL('/log') .parsedUrl(); expect(url.hash).toContain('/log'); }); it(`should confirm the log is showing 5 entries`, async() => { const anyLineCreatedCount = await nightmare .wait(selectors.itemLog.anyLineCreated) .countElement(selectors.itemLog.anyLineCreated); expect(anyLineCreatedCount).toEqual(5); }); it(`should confirm the log is showing the intrastat for the created item`, async() => { const fifthLineCreatedProperty = await nightmare .waitToGetProperty(selectors.itemLog.fifthLineCreatedProperty, 'innerText'); expect(fifthLineCreatedProperty).toEqual('Coral y materiales similares'); }); });