@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
74 lines • 2.87 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ScriptUiHelper = void 0;
const test_1 = require("@playwright/test");
const UiBaseLocators_1 = require("./UiBaseLocators");
const ConstantHelper_1 = require("./ConstantHelper");
class ScriptUiHelper extends UiBaseLocators_1.UiBaseLocators {
newJavascriptFileBtn;
scriptTree;
newFolderThreeDots;
constructor(page) {
super(page);
this.newJavascriptFileBtn = page.getByLabel('New Javascript file');
this.scriptTree = page.locator('umb-tree[alias="Umb.Tree.Script"]');
this.newFolderThreeDots = page.getByLabel('New Folder...');
}
async clickActionsMenuForScript(name) {
await this.clickActionsMenuForName(name);
}
async createScriptFolder(folderName) {
await this.clickCreateOptionsActionMenuOption();
await this.newFolderThreeDots.click();
await this.enterFolderName(folderName);
await this.clickConfirmCreateFolderButton();
}
async clickActionsMenuAtRoot() {
await this.clickActionsMenuForScript('Scripts');
}
async clickRootFolderCaretButton() {
await this.openCaretButtonForName('Scripts');
}
async clickNewJavascriptFileButton() {
await this.newJavascriptFileBtn.click();
}
async waitForScriptToBeCreated() {
await this.waitForNetworkToBeIdle();
}
async waitForScriptToBeDeleted() {
await this.waitForNetworkToBeIdle();
}
async waitForScriptToBeRenamed() {
await this.waitForNetworkToBeIdle();
}
// Will only work for root scripts
async goToScript(scriptName) {
await this.goToSection(ConstantHelper_1.ConstantHelper.sections.settings);
await this.reloadScriptTree();
await this.page.getByLabel(scriptName, { exact: true }).click();
}
async enterScriptName(scriptContent) {
await (0, test_1.expect)(this.enterAName).toBeVisible();
await this.enterAName.fill(scriptContent);
}
async enterScriptContent(scriptContent) {
await (0, test_1.expect)(this.textAreaInputArea).toBeVisible();
await this.textAreaInputArea.clear();
await this.textAreaInputArea.fill(scriptContent);
}
async openScriptAtRoot(scriptName) {
await this.reloadScriptTree();
await this.page.getByLabel(scriptName, { exact: true }).click();
}
async reloadScriptTree() {
await this.reloadTree('Scripts');
}
async isScriptRootTreeItemVisible(scriptName, isVisible = true, toReload = true) {
if (toReload) {
await this.reloadScriptTree();
}
return (0, test_1.expect)(this.scriptTree.getByText(scriptName, { exact: true })).toBeVisible({ visible: isVisible });
}
}
exports.ScriptUiHelper = ScriptUiHelper;
//# sourceMappingURL=ScriptUiHelper.js.map