@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
88 lines • 3.86 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PartialViewUiHelper = void 0;
const test_1 = require("@playwright/test");
const UiBaseLocators_1 = require("./UiBaseLocators");
class PartialViewUiHelper extends UiBaseLocators_1.UiBaseLocators {
newEmptyPartialViewBtn;
newPartialViewFromSnippetBtn;
partialViewTree;
partialViewUiLoader;
newFolderThreeDots;
constructor(page) {
super(page);
this.newEmptyPartialViewBtn = page.getByLabel('New empty partial view');
this.newPartialViewFromSnippetBtn = page.getByLabel('New partial view from snippet...');
this.partialViewTree = page.locator('umb-tree[alias="Umb.Tree.PartialView"]');
this.partialViewUiLoader = page.locator('uui-loader');
this.newFolderThreeDots = page.getByLabel('New Folder...');
}
async clickActionsMenuForPartialView(name) {
await this.clickActionsMenuForName(name);
}
async clickActionsMenuAtRoot() {
await this.clickActionsMenuForPartialView('Partial Views');
}
async clickRootFolderCaretButton() {
await this.openCaretButtonForName('Partial Views');
}
async waitForPartialViewToBeCreated() {
await this.waitForNetworkToBeIdle();
}
async waitForPartialViewToBeDeleted() {
await this.waitForNetworkToBeIdle();
}
async waitForPartialViewToBeRenamed() {
await this.waitForNetworkToBeIdle();
}
async clickNewEmptyPartialViewButton() {
await this.newEmptyPartialViewBtn.click();
}
async clickNewPartialViewFromSnippetButton() {
await this.newPartialViewFromSnippetBtn.click();
}
async enterPartialViewName(partialViewName) {
await (0, test_1.expect)(this.enterAName).toBeVisible();
await this.enterAName.click();
await this.enterAName.clear();
await this.enterAName.fill(partialViewName);
await (0, test_1.expect)(this.enterAName).toHaveValue(partialViewName);
}
async enterPartialViewContent(partialViewContent) {
// The waits in this method is currently needed as the test will fail with expects
await this.waitUntilPartialViewLoaderIsNoLongerVisible();
await (0, test_1.expect)(this.textAreaInputArea).toBeVisible();
await this.textAreaInputArea.click({ force: true });
await this.page.waitForTimeout(500);
await this.textAreaInputArea.clear();
await this.page.waitForTimeout(500);
await (0, test_1.expect)(this.textAreaInputArea).toHaveValue('');
await this.textAreaInputArea.fill(partialViewContent);
await this.page.waitForTimeout(500);
}
async openPartialViewAtRoot(partialViewName) {
await this.reloadPartialViewTree();
await this.page.locator('uui-menu-item[label="' + partialViewName + '"]').click();
await (0, test_1.expect)(this.enterAName).toBeVisible();
}
async createPartialViewFolder(folderName) {
await this.clickCreateOptionsActionMenuOption();
await this.newFolderThreeDots.click();
await this.enterFolderName(folderName);
await this.clickConfirmCreateFolderButton();
}
async reloadPartialViewTree() {
await this.reloadTree('Partial Views');
}
async waitUntilPartialViewLoaderIsNoLongerVisible() {
await (0, test_1.expect)(this.partialViewUiLoader).toBeVisible({ visible: false });
}
async isPartialViewRootTreeItemVisible(partialView, isVisible = true, toReload = true) {
if (toReload) {
await this.reloadPartialViewTree();
}
return (0, test_1.expect)(this.partialViewTree.getByText(partialView, { exact: true })).toBeVisible({ visible: isVisible });
}
}
exports.PartialViewUiHelper = PartialViewUiHelper;
//# sourceMappingURL=PartialViewUiHelper.js.map