@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
70 lines • 2.67 kB
JavaScript
;
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;
constructor(page) {
super(page);
this.newJavascriptFileBtn = page.getByRole('link', { name: 'New Javascript file' });
this.scriptTree = page.locator('umb-tree[alias="Umb.Tree.Script"]');
this.newFolderThreeDots = page.getByRole('button', { name: 'New Folder...' });
}
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 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 this.enterText(this.enterAName, scriptContent);
}
async enterScriptContent(scriptContent) {
await this.enterMonacoEditorValue(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 this.isVisible(this.scriptTree.getByText(scriptName, { exact: true }), isVisible);
}
}
exports.ScriptUiHelper = ScriptUiHelper;
//# sourceMappingURL=ScriptUiHelper.js.map