UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

100 lines 4.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StylesheetUiHelper = void 0; const test_1 = require("@playwright/test"); const UiBaseLocators_1 = require("./UiBaseLocators"); const ConstantHelper_1 = require("./ConstantHelper"); class StylesheetUiHelper extends UiBaseLocators_1.UiBaseLocators { newStylesheetBtn; stylesheetNameTxt; addRTEBtn; styleNameTxt; styleSelectorTxt; styleStylesTxt; newRichTextEditorStylesheetBtn; stylesheetTree; newFolderThreeDots; constructor(page) { super(page); this.stylesheetNameTxt = page.locator('umb-stylesheet-workspace-editor').locator('#nameInput #input'); this.addRTEBtn = page.getByLabel('Add rule'); this.styleNameTxt = page.getByLabel('Rule name'); this.styleSelectorTxt = page.getByLabel('Rule selector'); this.styleStylesTxt = page.getByLabel('Rule styles'); this.newStylesheetBtn = page.getByLabel('New Stylesheet'); this.newRichTextEditorStylesheetBtn = page.getByLabel('New Rich Text Editor Stylesheet'); this.stylesheetTree = page.locator('umb-tree[alias="Umb.Tree.Stylesheet"]'); this.newFolderThreeDots = page.getByLabel('New Folder...'); } async clickActionsMenuForStylesheet(name) { await this.clickActionsMenuForName(name); } async createStylesheetFolder(folderName) { await this.clickActionsMenuCreateButton(); await this.newFolderThreeDots.click(); await this.enterFolderName(folderName); await this.clickConfirmCreateFolderButton(); } async clickActionsMenuAtRoot() { await this.clickActionsMenuForStylesheet('Stylesheets'); } async clickRootFolderCaretButton() { await this.clickCaretButtonForName('Stylesheets'); } async clickNewStylesheetButton() { await this.newStylesheetBtn.click(); } async clickNewRichTextEditorStylesheetButton() { await this.newRichTextEditorStylesheetBtn.click(); } async enterStylesheetName(stylesheetName) { await (0, test_1.expect)(this.stylesheetNameTxt).toBeVisible(); await this.stylesheetNameTxt.clear(); await this.stylesheetNameTxt.fill(stylesheetName); } async enterStylesheetContent(stylesheetContent) { await this.textAreaInputArea.clear(); await this.textAreaInputArea.fill(stylesheetContent); } async addRTEStyle(styleName, styleSelector, styleStyles) { await this.addRTEBtn.click(); await this.fillRTEStyleForm(styleName, styleSelector, styleStyles); } async openStylesheetByNameAtRoot(stylesheetName) { await this.reloadStylesheetTree(); await this.page.getByLabel(stylesheetName).click(); } async editRTEStyle(styleName, newStyleName, newStyleSelector, newStyleStyles) { await this.page.locator('umb-stylesheet-rule-ref[name="' + styleName + '"] #name').click(); await this.fillRTEStyleForm(newStyleName, newStyleSelector, newStyleStyles); } async fillRTEStyleForm(styleName, styleSelector, styleStyles) { await (0, test_1.expect)(this.styleNameTxt).toBeVisible(); await this.styleNameTxt.clear(); await this.styleNameTxt.fill(styleName); await this.styleSelectorTxt.clear(); await this.styleSelectorTxt.fill(styleSelector); await this.styleStylesTxt.clear(); await this.styleStylesTxt.fill(styleStyles); await this.clickSubmitButton(); } async removeRTEStyle(styleName) { await this.page.locator('umb-stylesheet-rule-ref[name="' + styleName + '"] [label="Remove"]').click(); } async reloadStylesheetTree() { await this.reloadTree('Stylesheets'); } async isStylesheetRootTreeItemVisible(stylesheetName, isVisible = true, toReload = true) { if (toReload) { await this.reloadStylesheetTree(); } return (0, test_1.expect)(this.stylesheetTree.getByText(stylesheetName, { exact: true })).toBeVisible({ visible: isVisible }); } async goToStylesheet(stylesheetName) { await this.goToSection(ConstantHelper_1.ConstantHelper.sections.settings); await this.reloadStylesheetTree(); await this.page.getByLabel(stylesheetName).click(); } } exports.StylesheetUiHelper = StylesheetUiHelper; //# sourceMappingURL=StylesheetUiHelper.js.map