@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
122 lines • 5.65 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocumentTypeUiHelper = void 0;
const UiBaseLocators_1 = require("./UiBaseLocators");
const test_1 = require("@playwright/test");
class DocumentTypeUiHelper extends UiBaseLocators_1.UiBaseLocators {
newDocumentTypeBtn;
sharedAcrossCulturesToggle;
documentTypeSettingsTabBtn;
documentTypeTemplatesTabBtn;
varyBySegmentsBtn;
varyByCultureBtn;
createDocumentTypeBtn;
createDocumentTypeWithTemplateBtn;
createElementTypeBtn;
createDocumentFolderBtn;
preventCleanupBtn;
setAsDefaultBtn;
tabGroup;
documentTypesMenu;
constructor(page) {
super(page);
this.newDocumentTypeBtn = page.getByLabel('New Document Type…');
this.sharedAcrossCulturesToggle = page.locator('label').filter({ hasText: 'Shared across cultures' }).locator('#toggle');
this.tabGroup = page.getByTestId('workspace:view-links');
this.documentTypeSettingsTabBtn = this.tabGroup.locator('[data-mark*="Settings"]');
this.documentTypeTemplatesTabBtn = this.tabGroup.locator('[data-mark*="Templates"]');
this.varyBySegmentsBtn = page.getByText('Vary by segment', { exact: true });
this.varyByCultureBtn = page.getByText('Vary by culture', { exact: true });
this.createDocumentTypeBtn = page.locator('umb-ref-item').getByText('Document Type', { exact: true });
this.createDocumentTypeWithTemplateBtn = page.locator('umb-ref-item').getByText('Document Type with Template', { exact: true });
this.createElementTypeBtn = page.locator('umb-ref-item').getByText('Element Type', { exact: true });
this.createDocumentFolderBtn = page.locator('umb-ref-item').getByText('Folder', { exact: true });
this.preventCleanupBtn = page.getByText('Prevent clean up');
this.setAsDefaultBtn = page.getByText('Set as default');
this.documentTypesMenu = page.locator('#menu-item').getByRole('link', { name: 'Document Types' });
}
async clickActionsMenuForDocumentType(name) {
await this.clickActionsMenuForName(name);
}
async clickActionsMenuAtRoot() {
await this.clickActionsMenuForDocumentType("Document Types");
}
async clickRootFolderCaretButton() {
await this.openCaretButtonForName('Document Types');
}
async clickNewDocumentTypeButton() {
await (0, test_1.expect)(this.newDocumentTypeBtn).toBeVisible();
await this.newDocumentTypeBtn.click();
}
async clickSharedAcrossCulturesToggle() {
await (0, test_1.expect)(this.sharedAcrossCulturesToggle).toBeVisible();
await this.sharedAcrossCulturesToggle.click();
}
async clickDocumentTypeSettingsTab() {
await (0, test_1.expect)(this.documentTypeSettingsTabBtn).toBeVisible();
await this.documentTypeSettingsTabBtn.click();
}
async clickDocumentTypeTemplatesTab() {
await (0, test_1.expect)(this.documentTypeTemplatesTabBtn).toBeVisible();
await this.documentTypeTemplatesTabBtn.click();
}
async clickVaryBySegmentsButton() {
await (0, test_1.expect)(this.varyBySegmentsBtn).toBeVisible();
await this.varyBySegmentsBtn.click();
}
async clickVaryByCultureButton() {
await (0, test_1.expect)(this.varyByCultureBtn).toBeVisible();
await this.varyByCultureBtn.click();
}
async clickPreventCleanupButton() {
await (0, test_1.expect)(this.preventCleanupBtn).toBeVisible();
await this.preventCleanupBtn.click();
}
async goToDocumentType(documentTypeName) {
await this.clickRootFolderCaretButton();
await this.clickLabelWithName(documentTypeName);
}
async waitForDocumentTypeToBeCreated() {
await this.waitForNetworkToBeIdle();
}
async waitForDocumentTypeToBeDeleted() {
await this.waitForNetworkToBeIdle();
}
async waitForDocumentTypeToBeRenamed() {
await this.waitForNetworkToBeIdle();
}
async enterDocumentTypeName(documentTypeName) {
await (0, test_1.expect)(this.enterAName).toBeVisible();
await this.enterAName.fill(documentTypeName);
await (0, test_1.expect)(this.enterAName).toHaveValue(documentTypeName);
}
async clickCreateDocumentTypeButton() {
await (0, test_1.expect)(this.createDocumentTypeBtn).toBeVisible();
await this.createDocumentTypeBtn.click();
}
async clickCreateDocumentTypeWithTemplateButton() {
await (0, test_1.expect)(this.createDocumentTypeWithTemplateBtn).toBeVisible();
await this.createDocumentTypeWithTemplateBtn.click();
}
async clickCreateElementTypeButton() {
await (0, test_1.expect)(this.createElementTypeBtn).toBeVisible();
await this.createElementTypeBtn.click();
}
async clickCreateDocumentFolderButton() {
await (0, test_1.expect)(this.createDocumentFolderBtn).toBeVisible();
await this.createDocumentFolderBtn.click();
}
async isDocumentTreeItemVisible(name, isVisible = true) {
await (0, test_1.expect)(this.page.locator('umb-tree-item').locator('[label="' + name + '"]')).toBeVisible({ visible: isVisible });
}
async clickSetAsDefaultButton() {
await (0, test_1.expect)(this.setAsDefaultBtn).toBeVisible();
await this.setAsDefaultBtn.click();
}
async clickDocumentTypesMenu() {
await (0, test_1.expect)(this.documentTypesMenu).toBeVisible();
await this.documentTypesMenu.click();
}
}
exports.DocumentTypeUiHelper = DocumentTypeUiHelper;
//# sourceMappingURL=DocumentTypeUiHelper.js.map