@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
103 lines • 4.52 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TemplateUiHelper = void 0;
const test_1 = require("@playwright/test");
const UiBaseLocators_1 = require("./UiBaseLocators");
const ConstantHelper_1 = require("./ConstantHelper");
class TemplateUiHelper extends UiBaseLocators_1.UiBaseLocators {
changeMasterTemplateBtn;
sectionsBtn;
removeMasterTemplateBtn;
sectionNameTxt;
templateTree;
constructor(page) {
super(page);
this.changeMasterTemplateBtn = page.locator('#master-template-button');
this.sectionsBtn = page.locator('#sections-button', { hasText: 'Sections' });
this.removeMasterTemplateBtn = page.locator('[name="icon-delete"] svg');
this.sectionNameTxt = page.getByLabel('Section Name');
this.templateTree = page.locator('umb-tree[alias="Umb.Tree.Template"]');
}
async clickActionsMenuForTemplate(name) {
await this.clickActionsMenuForName(name);
}
async clickActionsMenuAtRoot() {
await this.clickActionsMenuForTemplate('Templates');
}
async clickRootFolderCaretButton() {
await this.openCaretButtonForName('Templates');
}
async waitForTemplateToBeCreated() {
await this.waitForNetworkToBeIdle();
}
async waitForTemplateToBeDeleted() {
await this.waitForNetworkToBeIdle();
}
async waitForTemplateToBeRenamed() {
await this.waitForNetworkToBeIdle();
}
async goToTemplate(templateName, childTemplateName = '') {
await this.goToSection(ConstantHelper_1.ConstantHelper.sections.settings);
await this.reloadTemplateTree();
if (childTemplateName === '') {
await this.page.getByLabel(templateName, { exact: true }).click();
await (0, test_1.expect)(this.enterAName).toHaveValue(templateName);
}
else {
await this.openCaretButtonForName(templateName);
await this.page.getByLabel(childTemplateName, { exact: true }).click();
await (0, test_1.expect)(this.enterAName).toHaveValue(childTemplateName);
}
await this.page.waitForTimeout(1000);
}
async clickSectionsButton() {
await (0, test_1.expect)(this.sectionsBtn).toBeVisible();
await this.sectionsBtn.click();
}
async clickChangeMasterTemplateButton() {
await (0, test_1.expect)(this.changeMasterTemplateBtn).toBeVisible();
await this.changeMasterTemplateBtn.click();
}
async enterTemplateName(templateName) {
await (0, test_1.expect)(this.enterAName).toBeVisible();
await this.enterAName.clear();
await this.enterAName.fill(templateName);
}
async enterTemplateContent(templateContent) {
// We need this wait, to be sure that the template content is loaded.
await this.page.waitForTimeout(200);
await this.textAreaInputArea.clear();
await this.textAreaInputArea.fill(templateContent);
}
async isMasterTemplateNameVisible(templateName, isVisible = true) {
await (0, test_1.expect)(this.page.getByLabel('Master template: ' + templateName)).toBeVisible({ visible: isVisible });
}
async clickRemoveMasterTemplateButton() {
await (0, test_1.expect)(this.removeMasterTemplateBtn).toBeVisible();
await this.removeMasterTemplateBtn.click();
}
async insertSection(sectionType, sectionName = '') {
await this.clickSectionsButton();
await (0, test_1.expect)(this.submitBtn).toBeVisible();
await this.page.locator('[label="' + sectionType + '"]').click();
if (sectionName !== '') {
await (0, test_1.expect)(this.sectionNameTxt).toBeVisible();
await this.sectionNameTxt.fill(sectionName);
}
await this.clickSubmitButton();
}
async isTemplateTreeItemVisible(templateName, isVisible = true) {
return (0, test_1.expect)(this.templateTree.getByText(templateName, { exact: true })).toBeVisible({ visible: isVisible });
}
async reloadTemplateTree() {
await this.reloadTree('Templates');
}
async isTemplateRootTreeItemVisible(templateName, isVisible = true, toReload = true) {
if (toReload) {
await this.reloadTemplateTree();
}
return (0, test_1.expect)(this.templateTree.getByText(templateName, { exact: true })).toBeVisible({ visible: isVisible });
}
}
exports.TemplateUiHelper = TemplateUiHelper;
//# sourceMappingURL=TemplateUiHelper.js.map