@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
95 lines • 3.93 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TemplateUiHelper = void 0;
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 this.hasValue(this.enterAName, templateName);
}
else {
await this.openCaretButtonForName(templateName);
await this.page.getByLabel(childTemplateName, { exact: true }).click();
await this.hasValue(this.enterAName, childTemplateName);
}
await this.page.waitForTimeout(1000);
}
async clickSectionsButton() {
await this.click(this.sectionsBtn);
}
async clickChangeMasterTemplateButton() {
await this.click(this.changeMasterTemplateBtn);
}
async enterTemplateName(templateName) {
await this.enterText(this.enterAName, templateName);
}
async enterTemplateContent(templateContent) {
// We need this wait, to be sure that the template content is loaded.
await this.page.waitForTimeout(200);
await this.enterMonacoEditorValue(templateContent);
}
async isMasterTemplateNameVisible(templateName, isVisible = true) {
await this.isVisible(this.page.getByLabel('Master template: ' + templateName), isVisible);
}
async clickRemoveMasterTemplateButton() {
await this.click(this.removeMasterTemplateBtn);
}
async insertSection(sectionType, sectionName = '') {
await this.clickSectionsButton();
await this.isVisible(this.submitBtn);
await this.page.locator('[label="' + sectionType + '"]').click();
if (sectionName !== '') {
await this.enterText(this.sectionNameTxt, sectionName);
}
await this.clickSubmitButton();
}
async isTemplateTreeItemVisible(templateName, isVisible = true) {
return this.isVisible(this.templateTree.getByText(templateName, { exact: true }), isVisible);
}
async reloadTemplateTree() {
await this.reloadTree('Templates');
}
async isTemplateRootTreeItemVisible(templateName, isVisible = true, toReload = true) {
if (toReload) {
await this.reloadTemplateTree();
}
return this.isVisible(this.templateTree.getByText(templateName, { exact: true }), isVisible);
}
}
exports.TemplateUiHelper = TemplateUiHelper;
//# sourceMappingURL=TemplateUiHelper.js.map