@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
87 lines • 4.49 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScriptUiHelper = void 0;
const UiBaseLocators_1 = require("./UiBaseLocators");
const ConstantHelper_1 = require("./ConstantHelper");
class ScriptUiHelper extends UiBaseLocators_1.UiBaseLocators {
newJavascriptFileBtn;
scriptTree;
newFolderThreeDots;
scriptCreateModal;
constructor(page) {
super(page);
this.scriptCreateModal = page.locator('umb-script-create-options-modal');
this.newJavascriptFileBtn = this.scriptCreateModal.locator('umb-ref-item', { hasText: 'JavaScript file' });
this.newFolderThreeDots = this.scriptCreateModal.locator('umb-ref-item', { hasText: 'Folder' });
this.scriptTree = page.locator('umb-tree[alias="Umb.Tree.Script"]');
}
async clickActionsMenuForScript(name) {
await this.clickActionsMenuForName(name);
}
async createScriptFolder(folderName) {
await this.clickCreateOptionsActionMenuOption();
await this.click(this.newFolderThreeDots);
await this.enterFolderName(folderName);
await this.clickConfirmCreateFolderButton();
}
async clickActionsMenuAtRoot() {
await this.clickActionsMenuForScript('Scripts');
}
async clickRootFolderCaretButton() {
await this.openCaretButtonForName('Scripts');
}
async clickNewJavascriptFileButton() {
await this.click(this.newJavascriptFileBtn);
}
async clickSaveButtonAndWaitForScriptToBeCreated() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.script, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.created);
}
async clickSaveButtonAndWaitForScriptToBeUpdated() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.script, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok);
}
// Will only work for root scripts
async goToScript(scriptName) {
await this.goToSection(ConstantHelper_1.ConstantHelper.sections.settings);
await this.reloadScriptTree();
await this.click(this.page.getByLabel(scriptName, { exact: true }));
}
async enterScriptName(scriptContent) {
await this.enterText(this.enterAName, scriptContent);
}
async enterScriptContent(scriptContent) {
await this.enterMonacoEditorValue(scriptContent);
}
async openScriptAtRoot(scriptName) {
await this.reloadScriptTree();
await this.click(this.page.getByLabel(scriptName, { exact: true }));
}
async reloadScriptTree() {
await this.reloadTree('Scripts');
}
async isScriptRootTreeItemVisible(scriptName, isVisible = true, toReload = true) {
if (toReload) {
await this.reloadScriptTree();
}
return await this.isVisible(this.scriptTree.getByText(scriptName, { exact: true }), isVisible);
}
async clickConfirmToDeleteButtonAndWaitForScriptToBeDeleted() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.script, this.clickConfirmToDeleteButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok);
}
async clickDeleteAndConfirmButtonAndWaitForScriptToBeDeleted() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.script, this.clickDeleteAndConfirmButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok);
}
async createScriptFolderAndWaitForScriptToBeCreated(folderName) {
await this.clickCreateOptionsActionMenuOption();
await this.click(this.newFolderThreeDots);
await this.enterFolderName(folderName);
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.scriptFolder, this.clickConfirmCreateFolderButton(), ConstantHelper_1.ConstantHelper.statusCodes.created);
}
async renameAndWaitForScriptToBeRenamed(newName) {
await this.clickRenameActionMenuOption();
await this.waitForVisible(this.newNameTxt);
await this.enterText(this.newNameTxt, newName);
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.script, this.click(this.renameModalBtn), ConstantHelper_1.ConstantHelper.statusCodes.ok);
}
}
exports.ScriptUiHelper = ScriptUiHelper;
//# sourceMappingURL=ScriptUiHelper.js.map