UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

106 lines 4.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DictionaryUiHelper = void 0; const UiBaseLocators_1 = require("./UiBaseLocators"); class DictionaryUiHelper extends UiBaseLocators_1.UiBaseLocators { createDictionaryItemBtn; dictionaryNameTxt; searchTxt; exportBtn; includeDescendantsCheckbox; importBtn; importFileTxt; emptySearchResultMessage; dictionaryList; dictionaryListRows; dictionaryTree; dictionaryCollection; exportModalBtn; importModalBtn; constructor(page) { super(page); this.createDictionaryItemBtn = page.getByLabel('Create dictionary item', { exact: true }); this.dictionaryNameTxt = page.locator('umb-workspace-header-name-editable').locator('input'); this.exportBtn = page.getByRole('button', { name: /^Export(…)?$/ }); this.importBtn = page.getByRole('button', { name: /^Import(…)?$/ }); this.searchTxt = page.locator('uui-input').getByLabel('Search'); this.dictionaryList = page.locator('umb-dictionary-table-collection-view'); this.dictionaryListRows = this.dictionaryList.locator('uui-table-row'); this.exportModalBtn = page.locator('umb-export-dictionary-modal').getByLabel('Export'); this.includeDescendantsCheckbox = page.locator('umb-export-dictionary-modal #includeDescendants'); this.importModalBtn = page.locator('uui-button').filter({ hasText: 'Import' }).getByLabel('Import'); this.importFileTxt = page.locator('umb-import-dictionary-modal #input'); this.emptySearchResultMessage = page.locator('#empty-state'); this.dictionaryTree = page.locator('umb-tree[alias="Umb.Tree.Dictionary"]'); this.dictionaryCollection = page.locator('umb-dictionary-collection'); } async clickCreateDictionaryItemButton() { await this.click(this.createDictionaryItemBtn); } async enterDictionaryName(name) { await this.enterText(this.dictionaryNameTxt, name); } async clickActionsMenuForDictionary(name) { await this.clickActionsMenuForName(name); } async enterSearchKeywordAndPressEnter(keyword) { await this.enterText(this.searchTxt, keyword); await this.page.keyboard.press('Enter'); } async clickExportButton() { await this.exportBtn.click(); } async clickImportButton() { await this.importBtn.click(); } async waitForDictionaryToBeCreated() { await this.waitForNetworkToBeIdle(); } async waitForDictionaryToBeDeleted() { await this.waitForNetworkToBeIdle(); } async waitForDictionaryToBeImported() { await this.waitForNetworkToBeIdle(); } async deleteDictionary() { await this.clickDeleteActionMenuOption(); await this.confirmToDeleteBtn.click(); } async doesDictionaryListHaveText(text) { await this.isVisible(this.dictionaryList); const allRows = await this.dictionaryListRows.all(); for (let currentRow of allRows) { const currentText = await currentRow.innerText(); if (currentText.includes(text)) { return true; } } return false; } // This function will export dictionary and return the file name async exportDictionary(includesDescendants) { if (includesDescendants) { await this.includeDescendantsCheckbox.click(); } const [downloadPromise] = await Promise.all([ this.page.waitForEvent('download'), await this.exportModalBtn.click() ]); return downloadPromise.suggestedFilename(); } async importDictionary(filePath) { await this.importFileTxt.setInputFiles(filePath); await this.click(this.importModalBtn); } async isSearchResultMessageDisplayEmpty(message) { return await this.hasText(this.emptySearchResultMessage, message); } async isDictionaryTreeItemVisible(dictionaryName, isVisible = true) { return await this.isVisible(this.dictionaryTree.getByText(dictionaryName, { exact: true }), isVisible); } async doesDictionaryCollectionContainText(text) { return await this.containsText(this.dictionaryCollection, text); } } exports.DictionaryUiHelper = DictionaryUiHelper; //# sourceMappingURL=DictionaryUiHelper.js.map