UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

90 lines 4.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StylesheetUiHelper = void 0; const UiBaseLocators_1 = require("./UiBaseLocators"); const ConstantHelper_1 = require("./ConstantHelper"); class StylesheetUiHelper extends UiBaseLocators_1.UiBaseLocators { newStylesheetBtn; newStylesheetFolderBtn; stylesheetNameTxt; stylesheetTree; stylesheetCreateModal; constructor(page) { super(page); this.stylesheetCreateModal = page.locator('umb-entity-create-option-action-list-modal'); this.newStylesheetBtn = this.stylesheetCreateModal.locator('umb-ref-item', { hasText: 'Stylesheet' }); this.newStylesheetFolderBtn = this.stylesheetCreateModal.locator('umb-ref-item', { hasText: 'Folder' }); this.stylesheetNameTxt = page.locator('umb-stylesheet-workspace-editor').locator('#nameInput #input'); this.stylesheetTree = page.locator('umb-tree[alias="Umb.Tree.Stylesheet"]'); } async clickActionsMenuForStylesheet(name) { await this.clickActionsMenuForName(name); } async createStylesheetFolder(folderName) { await this.clickCreateActionMenuOption(); await this.clickNewStylesheetFolderButton(); await this.enterFolderName(folderName); await this.clickConfirmCreateFolderButton(); } async clickActionsMenuAtRoot() { await this.clickActionsMenuForStylesheet('Stylesheets'); } async clickRootFolderCaretButton() { await this.openCaretButtonForName('Stylesheets'); } async clickNewStylesheetButton() { await this.click(this.newStylesheetBtn); } async clickNewStylesheetFolderButton() { await this.click(this.newStylesheetFolderBtn); } async clickSaveButtonAndWaitForStylesheetToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.stylesheet, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickSaveButtonAndWaitForStylesheetToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.stylesheet, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async enterStylesheetName(stylesheetName) { await this.enterText(this.stylesheetNameTxt, stylesheetName); } async enterStylesheetContent(stylesheetContent) { await this.enterMonacoEditorValue(stylesheetContent); } async openStylesheetByNameAtRoot(stylesheetName) { await this.reloadStylesheetTree(); await this.click(this.page.getByLabel(stylesheetName, { exact: true })); } async reloadStylesheetTree() { await this.reloadTree('Stylesheets'); } async isStylesheetRootTreeItemVisible(stylesheetName, isVisible = true, toReload = true) { if (toReload) { await this.reloadStylesheetTree(); } return await this.isVisible(this.stylesheetTree.getByText(stylesheetName, { exact: true }), isVisible); } async goToStylesheet(stylesheetName) { await this.goToSection(ConstantHelper_1.ConstantHelper.sections.settings); await this.reloadStylesheetTree(); await this.click(this.page.getByLabel(stylesheetName, { exact: true })); } async clickConfirmToDeleteButtonAndWaitForStylesheetToBeDeleted() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.stylesheet, this.clickConfirmToDeleteButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickDeleteAndConfirmButtonAndWaitForStylesheetToBeDeleted() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.stylesheet, this.clickDeleteAndConfirmButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async createStylesheetFolderAndWaitForStylesheetToBeCreated(folderName) { await this.clickCreateActionMenuOption(); await this.clickNewStylesheetFolderButton(); await this.enterFolderName(folderName); return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.stylesheetFolder, this.clickConfirmCreateFolderButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async renameAndWaitForStylesheetToBeRenamed(newName) { await this.clickRenameActionMenuOption(); await this.enterText(this.newNameTxt, newName); return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.stylesheet, this.click(this.renameModalBtn), ConstantHelper_1.ConstantHelper.statusCodes.ok); } } exports.StylesheetUiHelper = StylesheetUiHelper; //# sourceMappingURL=StylesheetUiHelper.js.map