@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
1,102 lines • 59 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UiBaseLocators = void 0;
const test_1 = require("@playwright/test");
const ConstantHelper_1 = require("./ConstantHelper");
const BasePage_1 = require("./BasePage");
class UiBaseLocators extends BasePage_1.BasePage {
// Core Action Buttons
saveBtn;
submitBtn;
confirmBtn;
chooseBtn;
chooseModalBtn;
createBtn;
addBtn;
updateBtn;
changeBtn;
deleteBtn;
deleteExactBtn;
removeExactBtn;
insertBtn;
renameBtn;
reloadBtn;
reloadChildrenBtn;
restoreBtn;
disableBtn;
enableBtn;
actionBtn;
nextBtn;
// Confirmation Buttons
confirmToDeleteBtn;
confirmCreateFolderBtn;
confirmToRemoveBtn;
confirmToSubmitBtn;
confirmDisableBtn;
confirmEnableBtn;
confirmRenameBtn;
confirmTrashBtn;
// Folder Management
createFolderBtn;
folderNameTxt;
folderBtn;
newFolderThreeDotsBtn;
renameFolderThreeDotsBtn;
renameFolderBtn;
updateFolderBtn;
deleteFolderThreeDotsBtn;
// Navigation & Menu
breadcrumbBtn;
leftArrowBtn;
caretBtn;
modalCaretBtn;
backOfficeHeader;
backOfficeMain;
sectionLinks;
sectionSidebar;
menuItem;
actionsMenuContainer;
treeItem;
// Three Dots Menu Buttons
createThreeDotsBtn;
renameThreeDotsBtn;
deleteThreeDotsBtn;
// Modal & Container
sidebarModal;
sidebarSaveBtn;
openedModal;
container;
containerChooseBtn;
containerSaveAndPublishBtn;
createModalBtn;
// Document Type & Property Editor
documentTypeNode;
propertyNameTxt;
selectPropertyEditorBtn;
editorSettingsBtn;
enterPropertyEditorDescriptionTxt;
property;
addPropertyBtn;
labelAboveBtn;
// Group & Tab Management
addGroupBtn;
groupLabel;
typeGroups;
addTabBtn;
unnamedTabTxt;
structureTabBtn;
// Validation & Mandatory
mandatoryToggle;
validation;
regexTxt;
regexMessageTxt;
validationMessage;
// Composition & Structure
compositionsBtn;
allowAtRootBtn;
allowedChildNodesModal;
addCollectionBtn;
// Reorder
iAmDoneReorderingBtn;
reorderBtn;
// Query Builder
queryBuilderBtn;
queryBuilderOrderedBy;
queryBuilderCreateDate;
queryBuilderShowCode;
wherePropertyAliasBtn;
whereOperatorBtn;
whereConstrainValueTxt;
orderByPropertyAliasBtn;
ascendingBtn;
chooseRootContentBtn;
returnedItemsCount;
queryResults;
// Insert & Template
insertValueBtn;
insertPartialViewBtn;
insertDictionaryItemBtn;
chooseFieldDropDown;
systemFieldsOption;
chooseFieldValueDropDown;
breadcrumbsTemplateModal;
// Rename
newNameTxt;
renameModalBtn;
// State & Notification
successState;
successStateIcon;
failedStateButton;
successNotification;
errorNotification;
// Search & Filter
typeToFilterSearchTxt;
filterChooseBtn;
// Text Input
textAreaInputArea;
enterAName;
descriptionBtn;
enterDescriptionTxt;
aliasLockBtn;
aliasNameTxt;
// Icon
iconBtn;
// Create Link
createLink;
// Recycle Bin
recycleBinBtn;
recycleBinMenuItem;
recycleBinMenuItemCaretBtn;
// View Options
gridBtn;
listBtn;
viewBundleBtn;
// Media
mediaCardItems;
mediaPickerModalSubmitBtn;
mediaCaptionAltTextModalSubmitBtn;
clickToUploadBtn;
inputDropzone;
imageCropperField;
inputUploadField;
chooseMediaInputBtn;
// Embedded Media
embeddedMediaModal;
embeddedURLTxt;
embeddedRetrieveBtn;
embeddedMediaModalConfirmBtn;
embeddedPreview;
// Document & Content
chooseDocumentInputBtn;
createDocumentBlueprintBtn;
createDocumentBlueprintModal;
createNewDocumentBlueprintBtn;
// User
currentUserAvatarBtn;
newPasswordTxt;
confirmPasswordTxt;
currentPasswordTxt;
// Collection & Table
collectionTreeItemTableRow;
createActionButtonCollection;
createActionBtn;
createOptionActionListModal;
// Reference & Entity
confirmActionModalEntityReferences;
referenceHeadline;
entityItemRef;
entityItem;
// Workspace & Action
workspaceAction;
workspaceActionMenuBtn;
entityAction;
openEntityAction;
// Pagination
firstPaginationBtn;
nextPaginationBtn;
// Editor
monacoEditor;
// Loader
uiLoader;
constructor(page) {
super(page);
// Core Action Buttons
this.saveBtn = page.getByLabel('Save', { exact: true });
this.submitBtn = page.getByLabel('Submit');
this.confirmBtn = page.getByLabel('Confirm');
this.chooseBtn = page.getByLabel('Choose', { exact: true });
this.chooseModalBtn = page.locator('uui-modal-sidebar').locator('[look="primary"]').getByLabel('Choose');
this.createBtn = page.getByRole('button', { name: /^Create(…)?$/ });
this.addBtn = page.getByRole('button', { name: 'Add', exact: true });
this.updateBtn = page.getByLabel('Update');
this.changeBtn = page.getByLabel('Change');
this.deleteBtn = page.getByRole('button', { name: /^Delete(…)?$/ });
this.deleteExactBtn = page.getByRole('button', { name: 'Delete', exact: true });
this.removeExactBtn = page.getByLabel('Remove', { exact: true });
this.insertBtn = page.locator('uui-box uui-button').filter({ hasText: 'Insert' });
this.renameBtn = page.getByRole('button', { name: /^Rename(…)?$/ });
this.reloadBtn = page.getByRole('button', { name: 'Reload', exact: true });
this.reloadChildrenBtn = page.getByRole('button', { name: 'Reload children' });
this.restoreBtn = page.getByLabel('Restore', { exact: true });
this.disableBtn = page.getByLabel('Disable', { exact: true });
this.enableBtn = page.getByLabel('Enable');
this.actionBtn = page.getByTestId('workspace:action-menu-button');
this.nextBtn = page.getByLabel('Next');
// Confirmation Buttons
this.confirmToDeleteBtn = page.locator('#confirm').getByLabel('Delete');
this.confirmCreateFolderBtn = page.locator('#confirm').getByLabel('Create Folder');
this.confirmToRemoveBtn = page.locator('#confirm').getByLabel('Remove');
this.confirmToSubmitBtn = page.locator('#confirm').getByLabel('Submit');
this.confirmDisableBtn = page.locator('#confirm').getByLabel('Disable');
this.confirmEnableBtn = page.locator('#confirm').getByLabel('Enable');
this.confirmRenameBtn = page.locator('#confirm').getByLabel('Rename');
this.confirmTrashBtn = page.locator('#confirm').getByLabel('Trash');
// Folder Management
this.createFolderBtn = page.getByLabel('Create folder');
this.folderNameTxt = page.getByLabel('Enter a folder name');
this.folderBtn = page.locator('umb-entity-create-option-action-list-modal').locator('umb-ref-item', { hasText: 'Folder' });
this.newFolderThreeDotsBtn = page.getByLabel('New Folder…');
this.renameFolderThreeDotsBtn = page.getByRole('button', { name: 'Rename folder…' });
this.renameFolderBtn = page.getByLabel('Rename folder');
this.updateFolderBtn = page.getByLabel('Update folder');
this.deleteFolderThreeDotsBtn = page.locator('#action-modal').getByLabel('Delete Folder...');
// Navigation & Menu
this.breadcrumbBtn = page.getByLabel('Breadcrumb');
this.leftArrowBtn = page.locator('[name="icon-arrow-left"] svg');
this.caretBtn = page.locator('#caret-button');
this.modalCaretBtn = page.locator('uui-modal-sidebar').locator('#caret-button');
this.backOfficeHeader = page.locator('umb-backoffice-header');
this.backOfficeMain = page.locator('umb-backoffice-main');
this.sectionLinks = page.getByTestId('section-links');
this.sectionSidebar = page.locator('umb-section-sidebar');
this.menuItem = page.locator('uui-menu-item');
this.actionsMenuContainer = page.locator('uui-scroll-container');
this.treeItem = page.locator('umb-tree-item');
// Three Dots Menu Buttons
this.createThreeDotsBtn = page.getByText('Create…', { exact: true });
this.renameThreeDotsBtn = page.getByLabel('Rename…', { exact: true });
this.deleteThreeDotsBtn = page.getByLabel('Delete…');
// Modal & Container
this.sidebarModal = page.locator('uui-modal-sidebar');
this.sidebarSaveBtn = this.sidebarModal.getByLabel('Save', { exact: true });
this.openedModal = page.locator('uui-modal-container[backdrop]');
this.container = page.locator('#container');
this.containerChooseBtn = page.locator('#container').getByLabel('Choose');
this.containerSaveAndPublishBtn = page.locator('#container').getByLabel('Save and Publish');
this.createModalBtn = page.locator('uui-modal-sidebar').getByLabel('Create', { exact: true });
// Document Type & Property Editor
this.documentTypeNode = page.locator('uui-ref-node-document-type');
this.propertyNameTxt = page.getByTestId('input:entity-name').locator('#input').first();
this.selectPropertyEditorBtn = page.getByLabel('Select Property Editor');
this.editorSettingsBtn = page.getByLabel('Editor settings');
this.enterPropertyEditorDescriptionTxt = page.locator('uui-modal-sidebar').getByTestId('input:entity-description').locator('#textarea');
this.property = page.locator('umb-property');
this.addPropertyBtn = page.getByLabel('Add property', { exact: true });
this.labelAboveBtn = page.locator('.appearance-option').filter({ hasText: 'Label above' });
// Group & Tab Management
this.addGroupBtn = page.getByLabel('Add group', { exact: true });
this.groupLabel = page.getByLabel('Group', { exact: true });
this.typeGroups = page.locator('umb-content-type-design-editor-group');
this.addTabBtn = page.getByLabel('Add tab');
this.unnamedTabTxt = page.getByTestId('tab:').getByTestId('tab:name-input').locator('#input');
this.structureTabBtn = page.locator('uui-tab').filter({ hasText: 'Structure' }).locator('svg');
// Validation & Mandatory
this.mandatoryToggle = page.locator('#mandatory #toggle');
this.validation = page.locator('#native');
this.regexTxt = page.locator('input[name="pattern"]');
this.regexMessageTxt = page.locator('textarea[name="pattern-message"]');
this.validationMessage = page.locator('umb-form-validation-message').locator('#messages');
// Composition & Structure
this.compositionsBtn = page.getByLabel('Compositions');
this.allowAtRootBtn = page.locator('label').filter({ hasText: 'Allow at root' });
this.allowedChildNodesModal = page.locator('umb-tree-picker-modal');
this.addCollectionBtn = page.locator('umb-input-content-type-collection-configuration #create-button');
// Reorder
this.iAmDoneReorderingBtn = page.getByLabel('I am done reordering');
this.reorderBtn = page.getByLabel('Reorder');
// Query Builder
this.queryBuilderBtn = page.locator('#query-builder-button');
this.queryBuilderOrderedBy = page.locator('#property-alias-dropdown').getByLabel('Property alias');
this.queryBuilderCreateDate = page.locator('#property-alias-dropdown').getByText('CreateDate').locator("..");
this.queryBuilderShowCode = page.locator('umb-code-block');
this.wherePropertyAliasBtn = page.locator('#property-alias-dropdown');
this.whereOperatorBtn = page.locator('#operator-dropdown');
this.whereConstrainValueTxt = page.getByLabel('constrain value');
this.orderByPropertyAliasBtn = page.locator('#sort-dropdown');
this.ascendingBtn = page.locator('[key="template_ascending"]');
this.chooseRootContentBtn = page.getByLabel('Choose root document');
this.returnedItemsCount = page.locator('#results-count');
this.queryResults = page.locator('.query-results');
// Insert & Template
this.insertValueBtn = page.locator('uui-button').filter({ has: page.locator('[key="template_insertPageField"]') });
this.insertPartialViewBtn = page.locator('uui-button').filter({ has: page.locator('[key="template_insertPartialView"]') });
this.insertDictionaryItemBtn = page.locator('uui-button').filter({ has: page.locator('[key="template_insertDictionaryItem"]') });
this.chooseFieldDropDown = page.locator('#preview #expand-symbol-wrapper');
this.systemFieldsOption = page.getByText('System fields');
this.chooseFieldValueDropDown = page.locator('#value #expand-symbol-wrapper');
this.breadcrumbsTemplateModal = page.locator('uui-modal-sidebar').locator('umb-template-workspace-editor uui-breadcrumbs');
// Rename
this.newNameTxt = page.getByRole('textbox', { name: 'Enter new name...' });
this.renameModalBtn = page.locator('umb-rename-modal').getByLabel('Rename');
// State & Notification
this.successState = page.locator('[state="success"]');
this.successStateIcon = page.locator('[state="success"]').locator('#state');
this.failedStateButton = page.locator('uui-button[state="failed"]');
this.successNotification = page.locator('uui-toast-notification[open][color="positive"]');
this.errorNotification = page.locator('uui-toast-notification[open][color="danger"]');
// Search & Filter
this.typeToFilterSearchTxt = page.locator('[type="search"] #input');
this.filterChooseBtn = page.locator('button').filter({ hasText: 'Choose' });
// Text Input
this.textAreaInputArea = page.locator('textarea.ime-text-area');
this.enterAName = page.getByLabel('Enter a name...', { exact: true });
this.descriptionBtn = page.getByLabel('Description');
this.enterDescriptionTxt = page.getByLabel('Enter a description...');
this.aliasLockBtn = page.locator('#name').getByLabel('Unlock input');
this.aliasNameTxt = page.locator('#name').getByLabel('alias');
// Icon
this.iconBtn = page.getByLabel('icon');
// Create Link
this.createLink = page.getByRole('link', { name: 'Create', exact: true });
// Recycle Bin
this.recycleBinBtn = page.getByLabel('Recycle Bin', { exact: true });
this.recycleBinMenuItem = page.locator('uui-menu-item[label="Recycle Bin"]');
this.recycleBinMenuItemCaretBtn = page.locator('uui-menu-item[label="Recycle Bin"]').locator('#caret-button');
// View Options
this.gridBtn = page.getByLabel('Grid');
this.listBtn = page.getByLabel('List');
this.viewBundleBtn = page.locator('umb-collection-view-bundle uui-button svg');
// Media
this.mediaCardItems = page.locator('uui-card-media');
this.mediaPickerModalSubmitBtn = page.locator('umb-media-picker-modal').getByLabel('Submit');
this.mediaCaptionAltTextModalSubmitBtn = page.locator('umb-media-caption-alt-text-modal').getByLabel('Submit');
this.clickToUploadBtn = page.locator('#splitViews').getByRole('button', { name: 'Click to upload' });
this.inputDropzone = page.locator('umb-input-dropzone');
this.imageCropperField = page.locator('umb-image-cropper-field');
this.inputUploadField = page.locator('umb-input-upload-field').locator('#wrapperInner');
this.chooseMediaInputBtn = page.locator('umb-input-media').getByLabel('Choose');
// Embedded Media
this.embeddedMediaModal = page.locator('umb-embedded-media-modal');
this.embeddedURLTxt = page.locator('umb-embedded-media-modal').locator('[label="URL"] #input');
this.embeddedRetrieveBtn = page.locator('umb-embedded-media-modal').locator('[label="Retrieve"]');
this.embeddedMediaModalConfirmBtn = page.locator('umb-embedded-media-modal').getByLabel('Confirm');
this.embeddedPreview = page.locator('umb-embedded-media-modal').locator('[label="Preview"]');
// Document & Content
this.chooseDocumentInputBtn = page.locator('umb-input-document').getByLabel('Choose');
this.createDocumentBlueprintBtn = page.getByLabel(/^Create Document Blueprint(…)?$/);
this.createDocumentBlueprintModal = page.locator('umb-document-blueprint-options-create-modal');
this.createNewDocumentBlueprintBtn = page.locator('umb-document-blueprint-options-create-modal').locator('umb-ref-item', { hasText: 'Document Blueprint for' });
// User
this.currentUserAvatarBtn = page.getByTestId('header-app:Umb.HeaderApp.CurrentUser').locator('uui-avatar');
this.currentPasswordTxt = page.locator('input[name="oldPassword"]');
this.newPasswordTxt = page.locator('input[name="newPassword"]');
this.confirmPasswordTxt = page.locator('input[name="confirmPassword"]');
// Collection & Table
this.collectionTreeItemTableRow = page.locator('umb-collection-workspace-view umb-table uui-table-row');
this.createActionButtonCollection = page.locator('umb-collection-create-action-button');
this.createActionBtn = page.locator('umb-collection-create-action-button').locator('[label="Create"]');
this.createOptionActionListModal = page.locator('umb-entity-create-option-action-list-modal');
// Reference & Entity
this.confirmActionModalEntityReferences = page.locator('umb-confirm-action-modal-entity-references,umb-confirm-bulk-action-modal-entity-references');
this.referenceHeadline = page.locator('umb-confirm-action-modal-entity-references,umb-confirm-bulk-action-modal-entity-references').locator('#reference-headline').first();
this.entityItemRef = page.locator('umb-confirm-action-modal-entity-references,umb-confirm-bulk-action-modal-entity-references').locator('uui-ref-list').first().getByTestId('entity-item-ref');
this.entityItem = page.locator('umb-entity-item-ref');
// Workspace & Action
this.workspaceAction = page.locator('umb-workspace-action');
this.workspaceActionMenuBtn = page.getByTestId('workspace:action-menu-button');
this.entityAction = page.locator('umb-entity-action-list umb-entity-action');
this.openEntityAction = page.locator('#action-modal[open]').locator(page.locator('umb-entity-action-list umb-entity-action'));
// Pagination
this.firstPaginationBtn = page.locator('umb-collection-pagination').getByLabel('First');
this.nextPaginationBtn = page.locator('umb-collection-pagination').getByLabel('Next');
// Editor
this.monacoEditor = page.locator('.monaco-editor');
// Loader
this.uiLoader = page.locator('uui-loader');
}
// Helper Methods
getMenuItemByLabel(name) {
return this.page.locator(`uui-menu-item[label="${name}"]`);
}
// Actions Menu Methods
async clickActionsMenuForNameInSectionSidebar(name) {
await this.sectionSidebar.locator('[label="' + name + '"]').hover();
await this.click(this.sectionSidebar.locator('[label="' + name + '"] >> [label="Open actions menu"]').first());
}
async clickActionsMenuForName(name) {
const menuItem = this.getMenuItemByLabel(name);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.medium);
const menuItemFirstLocator = menuItem.locator('#menu-item').first();
const actionModalLocator = menuItem.locator('#action-modal').first();
await this.hover(menuItemFirstLocator, { force: true });
await this.click(actionModalLocator, { force: true });
}
async isActionsMenuForNameVisible(name, isVisible = true) {
const menuItem = this.getMenuItemByLabel(name);
await this.click(menuItem);
await this.isVisible(menuItem.locator('#action-modal').first(), isVisible);
}
// Caret Button Methods
async clickCaretButtonForName(name) {
await this.isCaretButtonWithNameVisible(name);
await this.click(this.getMenuItemByLabel(name).locator('#caret-button').first());
}
async isCaretButtonWithNameVisible(name, isVisible = true) {
const caretButton = this.getMenuItemByLabel(name).locator('#caret-button').first();
await this.isVisible(caretButton, isVisible);
}
async clickCaretButton() {
await this.click(this.caretBtn);
}
async openCaretButtonForName(name, isInModal = false) {
let menuItem;
if (isInModal) {
menuItem = this.sidebarModal.locator(`uui-menu-item[label="${name}"]`);
}
else {
menuItem = this.getMenuItemByLabel(name);
}
await this.waitForVisible(menuItem, ConstantHelper_1.ConstantHelper.timeout.long);
const isCaretButtonOpen = await menuItem.getAttribute('show-children');
if (isCaretButtonOpen === null) {
await this.clickCaretButtonForName(name);
}
}
// Tree Methods
async reloadTree(treeName) {
await this.isVisible(this.page.getByLabel(treeName, { exact: true }));
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
await this.clickActionsMenuForName(treeName);
await this.clickReloadChildrenActionMenuOption();
await this.openCaretButtonForName(treeName);
}
async isTreeItemVisible(name, isVisible = true) {
await this.isVisible(this.treeItem.locator('[label="' + name + '"]'), isVisible);
}
async doesTreeItemHaveTheCorrectIcon(name, icon) {
return await this.isVisible(this.treeItem.filter({ hasText: name }).locator('umb-icon').locator('[name="' + icon + '"]'));
}
// Core Button Click Methods
async clickReloadButton() {
await this.click(this.reloadBtn);
}
async clickReloadChildrenButton() {
await this.click(this.reloadChildrenBtn, { force: true });
}
async clickSaveButton() {
await this.click(this.saveBtn);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
}
async clickChooseButton() {
await this.click(this.chooseBtn);
}
async clickChooseContainerButton() {
await this.click(this.containerChooseBtn);
}
async clickSubmitButton() {
await this.click(this.submitBtn);
}
async clickConfirmButton() {
await this.click(this.confirmBtn);
}
async clickCreateButton() {
await this.click(this.createBtn);
}
async clickAddButton() {
await this.click(this.addBtn);
}
async clickUpdateButton() {
await this.click(this.updateBtn);
}
async clickChangeButton() {
await this.click(this.changeBtn);
}
async clickDeleteButton() {
await this.click(this.deleteBtn);
}
async clickDeleteExactButton() {
await this.click(this.deleteExactBtn);
}
async clickRemoveExactButton() {
await this.click(this.removeExactBtn);
}
async clickInsertButton() {
await this.click(this.insertBtn);
}
async clickRenameButton() {
await this.click(this.renameBtn);
}
async clickRestoreButton() {
await this.click(this.restoreBtn);
}
async clickDisableButton() {
await this.click(this.disableBtn);
}
async clickEnableButton() {
await this.click(this.enableBtn);
}
async clickActionButton() {
await this.click(this.actionBtn);
}
async clickNextButton() {
await this.click(this.nextBtn);
}
async clickBreadcrumbButton() {
await this.click(this.breadcrumbBtn);
}
async clickLeftArrowButton() {
await this.click(this.leftArrowBtn);
}
// Confirmation Button Methods
async clickConfirmToDeleteButton() {
await this.click(this.confirmToDeleteBtn);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
}
async clickConfirmCreateFolderButton() {
await this.click(this.confirmCreateFolderBtn);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
}
async clickConfirmRemoveButton() {
await this.click(this.confirmToRemoveBtn);
}
async clickConfirmToSubmitButton() {
await this.click(this.confirmToSubmitBtn);
}
async clickConfirmDisableButton() {
await this.click(this.confirmDisableBtn);
}
async clickConfirmEnableButton() {
await this.click(this.confirmEnableBtn);
}
async clickConfirmRenameButton() {
await this.click(this.confirmRenameBtn);
}
async clickConfirmTrashButton() {
await this.click(this.confirmTrashBtn);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
}
async clickDeleteAndConfirmButton() {
await this.clickDeleteActionMenuOption();
await this.clickConfirmToDeleteButton();
}
// Folder Methods
async clickCreateFolderButton() {
await this.click(this.createFolderBtn);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
}
async enterFolderName(folderName) {
await this.enterText(this.folderNameTxt, folderName, { verify: true });
}
async createFolder(folderName) {
await this.clickCreateActionMenuOption();
await this.clickNewFolderThreeDotsButton();
await this.enterFolderName(folderName);
await this.clickConfirmCreateFolderButton();
}
async deleteFolder() {
await this.clickDeleteActionMenuOption();
await this.clickConfirmToDeleteButton();
}
async clickFolderButton() {
await this.click(this.folderBtn);
}
async clickNewFolderThreeDotsButton() {
await this.click(this.newFolderThreeDotsBtn);
}
async clickRenameFolderThreeDotsButton() {
await this.click(this.renameFolderThreeDotsBtn);
}
async clickRenameFolderButton() {
await this.clickRenameButton();
}
async clickUpdateFolderButton() {
await this.click(this.updateFolderBtn);
}
// Three Dots Menu Methods
async clickCreateThreeDotsButton() {
await this.click(this.createThreeDotsBtn);
}
async clickFilterChooseButton() {
await this.click(this.filterChooseBtn);
}
// Success State Methods
async isSuccessStateVisibleForSaveButton(isVisible = true) {
const regex = new RegExp(`^workspace-action:.*Save$`);
const saveButtonLocator = this.page.getByTestId(regex);
const saveBtn = this.workspaceAction.filter({ has: saveButtonLocator });
await this.isVisible(saveBtn.locator(this.successState), isVisible, ConstantHelper_1.ConstantHelper.timeout.long);
}
async isSuccessButtonWithTextVisible(text) {
return await this.isVisible(this.successState.filter({ hasText: text }));
}
async isSuccessStateIconVisible() {
await this.isVisible(this.successStateIcon);
}
async isFailedStateButtonVisible() {
await this.isVisible(this.failedStateButton);
}
// Notification Methods
async isSuccessNotificationVisible(isVisible = true) {
return await this.isVisible(this.successNotification.first(), isVisible, ConstantHelper_1.ConstantHelper.timeout.long);
}
async doesSuccessNotificationsHaveCount(count) {
await this.hasCount(this.successNotification, count);
}
async doesSuccessNotificationHaveText(text, isVisible = true, deleteNotification = false, timeout = 5000) {
const response = await this.isVisible(this.successNotification.filter({ hasText: text }), isVisible, timeout);
if (deleteNotification) {
await this.click(this.successNotification.filter({ hasText: text }).getByLabel('close'), { force: true });
}
return response;
}
async isErrorNotificationVisible(isVisible = true) {
return await this.isVisible(this.errorNotification.first(), isVisible);
}
async doesErrorNotificationHaveText(text, isVisible = true, deleteNotification = false) {
const response = await this.isVisible(this.errorNotification.filter({ hasText: text }), isVisible);
if (deleteNotification) {
await this.click(this.errorNotification.filter({ hasText: text }).locator('svg'));
}
return response;
}
// Modal Methods
async clickChooseModalButton() {
await this.click(this.chooseModalBtn);
}
async clickCreateModalButton() {
await this.click(this.createModalBtn);
}
async clickModalMenuItemWithName(name) {
await this.click(this.openedModal.locator(`uui-menu-item[label="${name}"]`), { timeout: ConstantHelper_1.ConstantHelper.timeout.long });
}
async isModalMenuItemWithNameDisabled(name) {
await this.hasAttribute(this.sidebarModal.locator(`uui-menu-item[label="${name}"]`), 'disabled', '');
}
async isModalMenuItemWithNameVisible(name, isVisible = true) {
await this.isVisible(this.sidebarModal.locator(`uui-menu-item[label="${name}"]`), isVisible);
}
// Container Methods
async clickContainerSaveAndPublishButton() {
await this.click(this.containerSaveAndPublishBtn);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
}
// Navigation Methods
async goToSection(sectionName, checkSections = true, skipReload = false) {
if (checkSections) {
for (let section in ConstantHelper_1.ConstantHelper.sections) {
await this.isVisible(this.sectionLinks.getByRole('tab', { name: ConstantHelper_1.ConstantHelper.sections[section] }), true, ConstantHelper_1.ConstantHelper.timeout.navigation);
}
}
const alreadySelected = await this.sectionLinks.locator('[active]').getByText(sectionName).isVisible();
if (alreadySelected && !skipReload) {
await this.page.reload();
}
else {
await this.click(this.backOfficeHeader.getByRole('tab', { name: sectionName }));
}
}
async goToSettingsTreeItem(settingsTreeItemName) {
await this.goToSection(ConstantHelper_1.ConstantHelper.sections.settings);
await this.click(this.page.getByLabel(settingsTreeItemName, { exact: true }));
}
async isSectionWithNameVisible(sectionName, isVisible = true) {
await this.isVisible(this.page.getByRole('tab', { name: sectionName }), isVisible);
}
async isBackOfficeMainVisible(isVisible = true) {
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.timeout.medium);
await this.isVisible(this.backOfficeMain, isVisible);
}
// Link & Button Click by Name Methods
async clickExactLinkWithName(name, toForce = false) {
const exactLinkWithNameLocator = this.page.getByRole('link', { name: name, exact: true });
await this.click(exactLinkWithNameLocator, { force: toForce });
}
async clickLinkWithName(name, isExact = false) {
await this.click(this.page.getByRole('link', { name: name, exact: isExact }));
}
async clickLabelWithName(name, isExact = true, toForce = false) {
await this.click(this.page.getByLabel(name, { exact: isExact }), { force: toForce });
}
async clickButtonWithName(name, isExact = false) {
const exactButtonWithNameLocator = this.page.getByRole('button', { name: name, exact: isExact });
await this.click(exactButtonWithNameLocator, { force: true });
}
async clickTextButtonWithName(name) {
await this.click(this.page.getByText(name, { exact: true }));
}
async isButtonWithNameVisible(name) {
await this.isVisible(this.page.getByRole('button', { name: name }));
}
async getButtonWithName(name) {
await this.waitForVisible(this.page.getByRole('button', { name: name }));
return this.page.getByRole('button', { name: name });
}
// Remove Button Methods
async clickRemoveButtonForName(name) {
const removeButtonWithNameLocator = this.page.locator('[name="' + name + '"] [label="Remove"]');
await this.click(removeButtonWithNameLocator);
}
async clickTrashIconButtonForName(name) {
const trashIconButtonWithNameLocator = this.page.locator('[name="' + name + '"] [name="icon-trash"]');
await this.click(trashIconButtonWithNameLocator);
}
async clickRemoveWithName(name) {
const removeLabelWithNameLocator = this.page.locator('[label="Remove ' + name + '"]');
await this.click(removeLabelWithNameLocator);
}
// Alias & Icon Methods
async enterAliasName(aliasName) {
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
await this.click(this.aliasLockBtn, { force: true });
await this.enterText(this.aliasNameTxt, aliasName);
}
async updateIcon(iconName) {
await this.click(this.iconBtn, { force: true });
await this.searchForTypeToFilterValue(iconName);
await this.clickLabelWithName(iconName, true, true);
await this.clickSubmitButton();
}
// Property Editor Methods
async clickSelectPropertyEditorButton() {
await this.click(this.selectPropertyEditorBtn);
}
async enterAPropertyName(name) {
await this.enterText(this.propertyNameTxt, name, { clearFirst: false });
}
async clickEditorSettingsButton(index = 0) {
await this.click(this.editorSettingsBtn.nth(index));
}
async addPropertyEditor(propertyEditorName, index = 0) {
await this.click(this.addPropertyBtn.nth(index));
await this.enterAPropertyName(propertyEditorName);
await this.hasValue(this.propertyNameTxt, propertyEditorName);
await this.clickSelectPropertyEditorButton();
await this.searchForTypeToFilterValue(propertyEditorName);
await this.click(this.page.getByText(propertyEditorName, { exact: true }));
await this.clickSubmitButton();
}
async updatePropertyEditor(propertyEditorName) {
await this.clickEditorSettingsButton();
await this.clickChangeButton();
await this.searchForTypeToFilterValue(propertyEditorName);
await this.click(this.page.getByText(propertyEditorName, { exact: true }));
await this.enterAPropertyName(propertyEditorName);
await this.clickSubmitButton();
}
async deletePropertyEditor(propertyEditorName) {
await this.page.locator('uui-button').filter({ hasText: propertyEditorName }).getByLabel('Editor settings').hover();
await this.click(this.deleteBtn);
}
async deletePropertyEditorWithName(name) {
const propertyEditor = this.page.locator('umb-content-type-design-editor-property', { hasText: name });
await this.hoverAndClick(propertyEditor, propertyEditor.getByLabel('Delete'), { force: true });
await this.clickConfirmToDeleteButton();
}
async enterPropertyEditorDescription(description) {
await this.enterText(this.enterPropertyEditorDescriptionTxt, description);
}
async isPropertyEditorUiWithNameReadOnly(name) {
const propertyEditorUiLocator = this.page.locator('umb-property-editor-ui-' + name);
await this.hasAttribute(propertyEditorUiLocator, 'readonly', '');
}
async isPropertyEditorUiWithNameVisible(name, isVisible = true) {
const propertyEditorUiLocator = this.page.locator('umb-property-editor-ui-' + name);
await this.isVisible(propertyEditorUiLocator, isVisible);
}
async doesPropertyHaveInvalidBadge(propertyName) {
await this.isVisible(this.page.locator('umb-property-layout').filter({ hasText: propertyName }).locator('#invalid-badge uui-badge'));
}
// Group Methods
async clickAddGroupButton() {
await this.click(this.addGroupBtn);
}
async enterGroupName(groupName, index = 0) {
const groupNameTxt = this.groupLabel.nth(index);
await this.enterText(groupNameTxt, groupName);
}
async isGroupVisible(groupName, isVisible = true) {
await this.isVisible(this.groupLabel.filter({ hasText: groupName }), isVisible);
}
async doesGroupHaveValue(value) {
await this.waitForVisible(this.groupLabel);
return await this.hasValue(this.groupLabel, value);
}
async deleteGroup(groupName) {
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.medium);
const groups = this.page.locator('umb-content-type-design-editor-group').all();
for (const group of await groups) {
if (await group.getByLabel('Group', { exact: true }).inputValue() === groupName) {
const headerActionsDeleteLocator = group.locator('[slot="header-actions"]').getByLabel('Delete');
await this.click(headerActionsDeleteLocator, { force: true });
return;
}
}
}
async reorderTwoGroups(firstGroupName, secondGroupName) {
const firstGroup = this.page.getByTestId('group:' + firstGroupName);
const secondGroup = this.page.getByTestId('group:' + secondGroupName);
const firstGroupValue = await firstGroup.getByLabel('Group').inputValue();
const secondGroupValue = await secondGroup.getByLabel('Group').inputValue();
const dragToLocator = firstGroup.locator('[slot="header"]').first();
const dragFromLocator = secondGroup.locator('[slot="header"]').first();
await this.dragAndDrop(dragFromLocator, dragToLocator, 0, 0, 20);
return { firstGroupValue, secondGroupValue };
}
// Tab Methods
async clickAddTabButton() {
await this.click(this.addTabBtn);
}
async enterTabName(tabName) {
await this.waitForVisible(this.unnamedTabTxt);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.debounce);
await this.enterText(this.unnamedTabTxt, tabName);
await this.click(this.page.getByRole('tab', { name: 'Design' }));
await this.click(this.page.getByTestId('tab:' + tabName));
}
async clickRemoveTabWithName(name) {
const tab = this.page.locator('uui-tab').filter({ hasText: name });
await this.hoverAndClick(tab, tab.locator('[label="Remove"]'));
}
async clickStructureTab() {
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.medium);
await this.click(this.structureTabBtn);
}
getTabLocatorWithName(name) {
return this.page.getByRole('tab', { name: name });
}
// Validation Methods
async clickMandatoryToggle() {
await this.click(this.mandatoryToggle);
}
async selectValidationOption(option) {
await this.selectByValue(this.validation, option);
}
async enterRegEx(regEx) {
await this.enterText(this.regexTxt, regEx, { clearFirst: false });
}
async enterRegExMessage(regExMessage) {
await this.enterText(this.regexMessageTxt, regExMessage, { clearFirst: false });
}
async isValidationMessageVisible(message, isVisible = true) {
await this.isVisible(this.validationMessage.filter({ hasText: message }), isVisible);
}
// Composition & Structure Methods
async clickCompositionsButton() {
await this.click(this.compositionsBtn);
}
async clickAllowAtRootButton() {
await this.click(this.allowAtRootBtn);
}
async clickAllowedChildNodesButton() {
await this.click(this.allowedChildNodesModal.locator(this.chooseBtn));
}
async clickAddCollectionButton() {
await this.click(this.addCollectionBtn);
}
// Reorder Methods
async clickIAmDoneReorderingButton() {
await this.click(this.iAmDoneReorderingBtn);
}
async clickReorderButton() {
await this.click(this.reorderBtn);
}
async clickLabelAboveButton() {
await this.click(this.labelAboveBtn);
}
// Query Builder Methods
async clickQueryBuilderButton() {
await this.click(this.queryBuilderBtn);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
}
async addQueryBuilderWithOrderByStatement(propertyAlias, isAscending) {
await this.click(this.queryBuilderBtn, { timeout: ConstantHelper_1.ConstantHelper.timeout.long });
await this.click(this.orderByPropertyAliasBtn);
await this.waitAndSelectQueryBuilderDropDownList(propertyAlias);
await this.click(this.orderByPropertyAliasBtn);
if (!isAscending) {
await this.click(this.ascendingBtn);
}
}
async addQueryBuilderWithWhereStatement(propertyAlias, operator, constrainValue) {
await this.click(this.queryBuilderBtn, { timeout: ConstantHelper_1.ConstantHelper.timeout.long });
await this.click(this.wherePropertyAliasBtn);
await this.waitAndSelectQueryBuilderDropDownList(propertyAlias);
await this.click(this.whereOperatorBtn);
await this.waitAndSelectQueryBuilderDropDownList(operator);
await this.enterText(this.whereConstrainValueTxt, constrainValue);
await this.pressKey(this.whereConstrainValueTxt, 'Enter');
}
async waitAndSelectQueryBuilderDropDownList(option) {
const ddlOption = this.page.locator('[open]').locator('uui-combobox-list-option').filter({ hasText: option }).first();
await this.click(ddlOption, { timeout: ConstantHelper_1.ConstantHelper.timeout.long });
}
async chooseRootContentInQueryBuilder(contentName) {
await this.click(this.chooseRootContentBtn);
await this.clickModalMenuItemWithName(contentName);
await this.clickChooseButton();
}
async isQueryBuilderCodeShown(code) {
await this.click(this.queryBuilderShowCode);
await this.containsText(this.queryBuilderShowCode, code, ConstantHelper_1.ConstantHelper.timeout.long);
}
async doesReturnedItemsHaveCount(itemCount) {
await this.containsText(this.returnedItemsCount, itemCount.toString() + ' published items returned');
}
async doesQueryResultHaveContentName(contentName) {
await this.containsText(this.queryResults, contentName);
}
// Insert Methods
async insertDictionaryItem(dictionaryName) {
await this.clickInsertButton();
await this.click(this.insertDictionaryItemBtn);
await this.click(this.page.getByLabel(dictionaryName));
await this.click(this.chooseBtn);
}
async insertSystemFieldValue(fieldValue) {
await this.clickInsertButton();
await this.click(this.insertValueBtn);
await this.click(this.chooseFieldDropDown);
await this.click(this.systemFieldsOption);
await this.click(this.chooseFieldValueDropDown);
await this.click(this.page.getByText(fieldValue));
await this.clickSubmitButton();
}
async insertPartialView(partialViewName) {
await this.clickInsertButton();
await this.click(this.insertPartialViewBtn);
await this.click(this.page.getByLabel(partialViewName));
await this.clickChooseButton();
}
// Rename Methods
async rename(newName) {
await this.clickRenameActionMenuOption();
await this.click(this.newNameTxt);
await this.enterText(this.newNameTxt, newName);
await this.click(this.renameModalBtn);
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short);
}
// Search & Filter Methods
async searchForTypeToFilterValue(searchValue) {
await this.enterText(this.typeToFilterSearchTxt, searchValue, { clearFirst: false });
}
// Description Methods
async enterDescription(description) {
await this.enterText(this.enterDescriptionTxt, description);
}
async doesDescriptionHaveValue(value, index = 0) {
return await this.hasValue(this.descriptionBtn.nth(index), value);
}
// Drag and Drop Methods
async dragAndDrop(dragFromSelector, dragToSelector, verticalOffset = 0, horizontalOffset = 0, steps = 5) {
await this.waitForVisible(dragFromSelector);
await this.waitForVisible(dragToSelector);
const targetLocation = await dragToSelector.boundingBox();
const elementCenterX = targetLocation.x + targetLocation.width / 2;
const elementCenterY = targetLocation.y + targetLocation.height / 2;
await this.hover(dragFromSelector);
await this.page.mouse.move(10, 10);
await this.hover(dragFromSelector);
await this.page.mouse.down();
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.debounce);
await this.page.mouse.move(elementCenterX + horizontalOffset, elementCenterY + verticalOffset, { steps: steps });
await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.debounce);
await this.page.mouse.up();
}
// Create Link Methods
async clickCreateLink() {
await this.click(this.createLink);
}
// Recycle Bin Methods
async clickRecycleBinButton() {
await this.click(this.recycleBinBtn);
}
async reloadRecycleBin(containsItems = true) {
await this.waitForVisible(this.recycleBinMenuItem);
if (!containsItems) {
await this.clickReloadChildrenActionMenuOption();
await this.isVisible(this.recycleBinMenuItemCaretBtn, false);
return;
}
await this.clickActionsMenuForName('Recycle Bin');
await this.clickReloadChildrenActionMenuOption();
await this.openCaretButtonForName('Recycle Bin');
}
async isItemVisibleInRecycleBin(item, isVisible = true, isReload = true) {
if (isReload) {
await this.reloadRecycleBin(isVisible);
}
return await this.isVisible(this.page.locator('[label="Recycle Bin"] [label="' + item + '"]'), isVisible);
}
// View Methods
async changeToGridView() {
await this.click(this.viewBundleBtn);
await this.click(this.gridBtn);
}
async changeToListView() {
await this.click(this.viewBundleBtn);
await this.click(this.listBtn);
}
async isViewBundleButtonVisible(isVisible = true) {
return this.isVisible(this.viewBundleBtn, isVisible);
}
// Media Methods
async clickMediaWithName(name) {
await this.click(this.mediaCardItems.filter({ hasText: name }));
}
async selectMediaWithName(mediaName, isForce = false) {
const mediaLocator = this.mediaCardItems.filter({ hasText: mediaName });
await this.waitForVisible(mediaLocator);
// Using direct click with position option (not supported by BasePage.click)
await mediaLocator.click({ position: { x: 0.5, y: 0.5 }, force: isForce });
}
async selectMediaWithTestId(mediaKey) {
const locator = this.page.getByTestId('media:' + mediaKey);
await this.waitForVisible(locator);
// Using direct click with position option (not supported by BasePage.click)
await locator.click({ position: { x: 0.5, y: 0.5 } });
}
async clickMediaPickerModalSubmitButton() {
await this.click(this.mediaPickerModalSubmitBtn);
}
async clickMediaCaptionAltTextModalSubmitButton() {
await this.click(this.mediaCaptionAltTextModalSubmitBtn);
}
async clickChooseMediaStartNodeButton() {
await this.click(this.chooseMediaInputBtn);
}
async isMediaCardItemWithNameDisabled(itemName) {
await this.hasAttribute(this.mediaCardItems.filter({ hasText: itemName }), 'class', 'not-allowed');
}
async isMediaCardItemWithNameVisible(itemName, isVisible = true) {
await this.isVisible(this.mediaCardItems.filter({ hasText: itemName }), isVisible);
}
async doesMediaHaveThumbnail(mediaId, thumbnailIconName, thumbnailImage) {
const mediaThumbnailLocator = this.page.getByTestId('media:' + mediaId);
if (thumbnailIconName === 'image') {
const regexImageSrc = new RegExp(`^${thumbnailImage}.*`);
await this.hasAttribute(mediaThumbnailLocator.locator('umb-imaging-thumbnail img'), 'src', regexImageSrc.toString());
}
else {
await this.hasAttribute(mediaThumbnailLocator.locator('umb-imaging-thumbnail umb-icon'), 'name', thumbnailIconName);
}
}
async isInputDropzoneVisible(isVisible = true) {
await this.isVisible(this.inputDropzone, isVisible);
}
async isImageCropperFieldVisible(isVisible = true) {
await this.isVisible(this.imageCropperField, isVisible);
}
async isInputUploadFieldVisible(isVisible = true) {
await this.isVisible(this.inputUploadField, isVisible);
}
// Upload Methods
async clickToUploadButton() {
await this.click(this.clickToUploadBtn);
}
async uploadFile(filePath) {
const [fileChooser] = await Promise.all([
this.page.waitForEvent('filechooser'),
await this.clickToUploadButton(),
]);
await fileChooser.setFiles(filePath);
}
// Embedded Media Methods
async enterEmbeddedURL(value) {
await this.enterText(this.embeddedURLTxt, value);
}
async clickEmbeddedRetrieveButton() {
await this.click(this.embeddedRetrieveBtn);
}
async clickEmbeddedMediaModalConfirmButton() {
await this.click(this.embeddedMediaModalConfirmBtn);
}
async waitForEmbeddedPreviewVisible() {
await this.waitForVisible(this.embeddedPreview);
}
// Document Methods
async clickChooseContentStartNodeButton() {
await this.click(this.chooseDocumentInputBtn);
}
// User Methods
async clickCurrentUserAvatarButton() {
await this.click(this.cur