UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

112 lines 4.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DictionaryUiHelper = void 0; const test_1 = require("@playwright/test"); 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 (0, test_1.expect)(this.createDictionaryItemBtn).toBeVisible(); await this.createDictionaryItemBtn.click(); } async enterDictionaryName(name) { await (0, test_1.expect)(this.dictionaryNameTxt).toBeVisible(); await this.dictionaryNameTxt.clear(); await this.dictionaryNameTxt.fill(name); } async clickActionsMenuForDictionary(name) { await this.clickActionsMenuForName(name); } async enterSearchKeywordAndPressEnter(keyword) { await this.searchTxt.clear(); await this.searchTxt.fill(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 (0, test_1.expect)(this.dictionaryList).toBeVisible(); 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 (0, test_1.expect)(this.importModalBtn).toBeVisible(); await this.importModalBtn.click(); } async isSearchResultMessageDisplayEmpty(message) { return await (0, test_1.expect)(this.emptySearchResultMessage).toHaveText(message); } async isDictionaryTreeItemVisible(dictionaryName, isVisible = true) { return await (0, test_1.expect)(this.dictionaryTree.getByText(dictionaryName, { exact: true })).toBeVisible({ visible: isVisible }); } async doesDictionaryCollectionContainText(text) { return await (0, test_1.expect)(this.dictionaryCollection).toContainText(text); } } exports.DictionaryUiHelper = DictionaryUiHelper; //# sourceMappingURL=DictionaryUiHelper.js.map