UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

99 lines 4.87 kB
"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 goToTemplate(templateName, childTemplateName = '') { await this.goToSection(ConstantHelper_1.ConstantHelper.sections.settings); await this.reloadTemplateTree(); if (childTemplateName === '') { await this.click(this.page.getByLabel(templateName, { exact: true })); await this.hasValue(this.enterAName, templateName); } else { await this.openCaretButtonForName(templateName); await this.click(this.page.getByLabel(childTemplateName, { exact: true })); await this.hasValue(this.enterAName, childTemplateName); } await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.medium); } 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(ConstantHelper_1.ConstantHelper.wait.minimal); 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.waitForVisible(this.submitBtn); await this.click(this.page.locator(`[label="${sectionType}"]`)); if (sectionName !== '') { await this.waitForVisible(this.sectionNameTxt); await this.sectionNameTxt.fill(sectionName); } await this.clickSubmitButton(); } async isTemplateTreeItemVisible(templateName, isVisible = true) { await 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(); } await this.isVisible(this.templateTree.getByText(templateName, { exact: true }), isVisible); } async clickSaveButtonAndWaitForTemplateToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.template, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickSaveButtonAndWaitForTemplateToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.template, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickConfirmToDeleteButtonAndWaitForTemplateToBeDeleted() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.template, this.clickConfirmToDeleteButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickDeleteAndConfirmButtonAndWaitForTemplateToBeDeleted() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.template, this.clickDeleteAndConfirmButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } } exports.TemplateUiHelper = TemplateUiHelper; //# sourceMappingURL=TemplateUiHelper.js.map