UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

1,080 lines 50.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UiBaseLocators = void 0; const ConstantHelper_1 = require("./ConstantHelper"); const BasePage_1 = require("./BasePage"); class UiBaseLocators extends BasePage_1.BasePage { saveBtn; chooseBtn; submitBtn; createFolderBtn; breadcrumbBtn; confirmToDeleteBtn; deleteExactBtn; confirmCreateFolderBtn; insertBtn; modalCaretBtn; queryBuilderBtn; queryBuilderOrderedBy; queryBuilderCreateDate; folderNameTxt; textAreaInputArea; wherePropertyAliasBtn; whereOperatorBtn; whereConstrainValueTxt; orderByPropertyAliasBtn; ascendingBtn; queryBuilderShowCode; createThreeDotsBtn; newFolderThreeDotsBtn; renameThreeDotsBtn; newNameTxt; renameModalBtn; createBtn; successState; chooseModalBtn; addBtn; renameFolderThreeDotsBtn; renameFolderBtn; updateFolderBtn; filterChooseBtn; updateBtn; changeBtn; propertyNameTxt; selectPropertyEditorBtn; addGroupBtn; iAmDoneReorderingBtn; reorderBtn; compositionsBtn; addTabBtn; descriptionBtn; enterDescriptionTxt; mandatoryToggle; validation; regexTxt; regexMessageTxt; structureTabBtn; allowAtRootBtn; addPropertyBtn; typeToFilterSearchTxt; editorSettingsBtn; labelAboveBtn; unnamedTabTxt; deleteThreeDotsBtn; removeExactBtn; confirmBtn; disableBtn; confirmDisableBtn; enableBtn; confirmEnableBtn; iconBtn; aliasLockBtn; aliasNameTxt; deleteFolderThreeDotsBtn; createLink; insertValueBtn; insertPartialViewBtn; insertDictionaryItemBtn; chooseFieldDropDown; systemFieldsOption; chooseFieldValueDropDown; renameBtn; returnedItemsCount; chooseRootContentBtn; queryResults; reloadBtn; confirmToRemoveBtn; confirmToSubmitBtn; typeGroups; allowedChildNodesModal; addCollectionBtn; errorNotification; confirmRenameBtn; successNotification; leftArrowBtn; clickToUploadBtn; backOfficeHeader; failedStateButton; sidebarModal; enterAName; mediaCardItems; enterPropertyEditorDescriptionTxt; breadcrumbsTemplateModal; containerChooseBtn; documentTypeNode; groupLabel; containerSaveAndPublishBtn; confirmTrashBtn; recycleBinBtn; recycleBinMenuItemCaretBtn; recycleBinMenuItem; gridBtn; listBtn; viewBundleBtn; chooseDocumentInputBtn; chooseMediaInputBtn; container; createDocumentBlueprintBtn; actionBtn; mediaPickerModalSubmitBtn; deleteBtn; createModalBtn; mediaCaptionAltTextModalSubmitBtn; embeddedMediaModal; embeddedURLTxt; embeddedRetrieveBtn; embeddedMediaModalConfirmBtn; embeddedPreview; sectionSidebar; actionsMenuContainer; menuItem; property; currentUserAvatarBtn; newPasswordTxt; confirmPasswordTxt; currentPasswordTxt; createOptionActionListModal; createActionButtonCollection; createActionBtn; collectionTreeItemTableRow; folderBtn; reloadChildrenBtn; confirmActionModalEntityReferences; referenceHeadline; entityItemRef; validationMessage; successStateIcon; workspaceAction; entityAction; openEntityAction; caretBtn; workspaceActionMenuBtn; monacoEditor; createNewDocumentBlueprintBtn; openedModal; constructor(page) { super(page); this.saveBtn = page.getByLabel('Save', { exact: true }); this.submitBtn = page.getByLabel('Submit'); this.deleteExactBtn = page.getByRole('button', { name: 'Delete', exact: true }); this.confirmToDeleteBtn = page.locator('#confirm').getByLabel('Delete'); this.confirmCreateFolderBtn = page.locator('#confirm').getByLabel('Create Folder'); this.breadcrumbBtn = page.getByLabel('Breadcrumb'); this.createFolderBtn = page.getByLabel('Create folder'); this.insertBtn = page.locator('uui-box uui-button').filter({ hasText: 'Insert' }); this.sidebarModal = page.locator('uui-modal-sidebar'); this.modalCaretBtn = this.sidebarModal.locator('#caret-button'); this.enterAName = page.getByLabel('Enter a name...', { exact: true }); 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.folderNameTxt = page.getByLabel('Enter a folder name'); this.textAreaInputArea = page.locator('textarea.ime-text-area'); 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.queryBuilderShowCode = page.locator('umb-code-block'); this.createThreeDotsBtn = page.getByText('Create…', { exact: true }); this.chooseBtn = page.getByLabel('Choose', { exact: true }); this.containerChooseBtn = page.locator('#container').getByLabel('Choose'); this.containerSaveAndPublishBtn = page.locator('#container').getByLabel('Save and Publish'); this.newFolderThreeDotsBtn = page.getByLabel('New Folder…'); this.renameThreeDotsBtn = page.getByLabel('Rename…', { exact: true }); this.newNameTxt = page.getByRole('textbox', { name: 'Enter new name...' }); this.renameModalBtn = page.locator('umb-rename-modal').getByLabel('Rename'); this.createBtn = page.getByRole('button', { name: /^Create(…)?$/ }); this.actionsMenuContainer = page.locator('uui-scroll-container'); this.successState = page.locator('[state="success"]'); this.chooseModalBtn = this.sidebarModal.locator('[look="primary"]').getByLabel('Choose'); this.addBtn = page.getByRole('button', { name: 'Add', exact: true }); this.renameFolderThreeDotsBtn = page.getByRole('button', { name: 'Rename folder…' }); this.renameFolderBtn = page.getByLabel('Rename folder'); this.confirmRenameBtn = page.locator('#confirm').getByLabel('Rename'); this.updateFolderBtn = page.getByLabel('Update folder'); this.filterChooseBtn = page.locator('button').filter({ hasText: 'Choose' }); this.updateBtn = page.getByLabel('Update'); this.changeBtn = page.getByLabel('Change'); this.propertyNameTxt = page.getByTestId('input:entity-name').locator('#input').first(); this.selectPropertyEditorBtn = page.getByLabel('Select Property Editor'); this.addGroupBtn = page.getByLabel('Add group', { exact: true }); this.iAmDoneReorderingBtn = page.getByLabel('I am done reordering'); this.reorderBtn = page.getByLabel('Reorder'); this.compositionsBtn = page.getByLabel('Compositions'); this.addTabBtn = page.getByLabel('Add tab'); this.descriptionBtn = page.getByLabel('Description'); this.enterDescriptionTxt = page.getByLabel('Enter a description...'); 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.structureTabBtn = page.locator('uui-tab').filter({ hasText: 'Structure' }).locator('svg'); this.allowAtRootBtn = page.locator('label').filter({ hasText: 'Allow at root' }); this.addPropertyBtn = page.getByLabel('Add property', { exact: true }); this.typeToFilterSearchTxt = page.locator('[type="search"] #input'); this.editorSettingsBtn = page.getByLabel('Editor settings'); this.labelAboveBtn = page.locator('button').filter({ hasText: 'Label above' }); // tab: means that the tab is unnamed this.unnamedTabTxt = page.getByTestId('tab:').getByTestId('tab:name-input').locator('#input'); this.deleteThreeDotsBtn = page.getByLabel('Delete…'); this.removeExactBtn = page.getByLabel('Remove', { exact: true }); this.confirmBtn = page.getByLabel('Confirm'); this.disableBtn = page.getByLabel('Disable', { exact: true }); this.confirmDisableBtn = page.locator('#confirm').getByLabel('Disable'); this.confirmToSubmitBtn = page.locator('#confirm').getByLabel('Submit'); this.enableBtn = page.getByLabel('Enable'); this.confirmEnableBtn = page.locator('#confirm').getByLabel('Enable'); this.iconBtn = page.getByLabel('icon'); this.aliasLockBtn = page.locator('#name #lock'); this.aliasNameTxt = page.locator('#name').getByLabel('alias'); this.deleteFolderThreeDotsBtn = page.locator('#action-modal').getByLabel('Delete Folder...'); this.createLink = page.getByRole('link', { name: 'Create', exact: true }); 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.renameBtn = page.getByRole('button', { name: /^Rename(…)?$/ }); this.returnedItemsCount = page.locator('#results-count'); this.chooseRootContentBtn = page.getByLabel('Choose root document'); this.queryResults = page.locator('.query-results'); this.reloadBtn = page.getByRole('button', { name: 'Reload', exact: true }); this.confirmToRemoveBtn = page.locator('#confirm').getByLabel('Remove'); this.typeGroups = page.locator('umb-content-type-design-editor-group'); this.allowedChildNodesModal = page.locator('umb-tree-picker-modal'); this.addCollectionBtn = page.locator('umb-input-content-type-collection-configuration #create-button'); this.errorNotification = page.locator('uui-toast-notification[open][color="danger"]'); this.successNotification = page.locator('uui-toast-notification[open][color="positive"]'); this.leftArrowBtn = page.locator('[name="icon-arrow-left"] svg'); this.clickToUploadBtn = page.locator('#splitViews').getByRole('button', { name: 'Click to upload' }); this.backOfficeHeader = page.locator('umb-backoffice-header'); this.failedStateButton = page.locator('uui-button[state="failed"]'); this.mediaCardItems = page.locator('uui-card-media'); this.enterPropertyEditorDescriptionTxt = this.sidebarModal.getByLabel('Enter a description...'); this.breadcrumbsTemplateModal = this.sidebarModal.locator('umb-template-workspace-editor uui-breadcrumbs'); this.documentTypeNode = page.locator('uui-ref-node-document-type'); this.groupLabel = page.getByLabel('Group', { exact: true }); this.confirmTrashBtn = page.locator('#confirm').getByLabel('Trash'); this.recycleBinBtn = page.getByLabel('Recycle Bin', { exact: true }); this.recycleBinMenuItem = page.locator('uui-menu-item[label="Recycle Bin"]'); this.recycleBinMenuItemCaretBtn = this.recycleBinMenuItem.locator('#caret-button'); this.gridBtn = page.getByLabel('Grid'); this.listBtn = page.getByLabel('List'); this.viewBundleBtn = page.locator('umb-collection-view-bundle uui-button svg'); this.createDocumentBlueprintBtn = page.getByLabel(/^Create Document Blueprint(…)?$/); this.createNewDocumentBlueprintBtn = page.getByRole('button', { name: 'New Document Blueprint for...' }); this.chooseDocumentInputBtn = page.locator('umb-input-document').getByLabel('Choose'); this.chooseMediaInputBtn = page.locator('umb-input-media').getByLabel('Choose'); this.container = page.locator('#container'); this.actionBtn = page.getByTestId('workspace:action-menu-button'); this.mediaPickerModalSubmitBtn = page.locator('umb-media-picker-modal').getByLabel('Submit'); this.deleteBtn = page.getByRole('button', { name: /^Delete(…)?$/ }); this.createModalBtn = this.sidebarModal.getByLabel('Create', { exact: true }); this.mediaCaptionAltTextModalSubmitBtn = page.locator('umb-media-caption-alt-text-modal').getByLabel('Submit'); this.embeddedMediaModal = page.locator('umb-embedded-media-modal'); this.embeddedURLTxt = this.embeddedMediaModal.locator('[label="URL"] #input'); this.embeddedRetrieveBtn = this.embeddedMediaModal.locator('[label="Retrieve"]'); this.embeddedMediaModalConfirmBtn = this.embeddedMediaModal.getByLabel('Confirm'); this.embeddedPreview = this.embeddedMediaModal.locator('[label="Preview"]'); this.sectionSidebar = page.locator('umb-section-sidebar'); this.menuItem = page.locator('uui-menu-item'); this.property = page.locator('umb-property'); 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"]'); this.createOptionActionListModal = page.locator('umb-entity-create-option-action-list-modal'); this.createActionButtonCollection = page.locator('umb-collection-create-action-button'); this.createActionBtn = this.createActionButtonCollection.locator('[label="Create"]'); this.collectionTreeItemTableRow = page.locator('umb-collection-workspace-view umb-table uui-table-row'); this.folderBtn = this.createOptionActionListModal.locator('[name="Folder"]'); this.reloadChildrenBtn = page.getByRole('button', { name: 'Reload children' }); this.confirmActionModalEntityReferences = page.locator('umb-confirm-action-modal-entity-references,umb-confirm-bulk-action-modal-entity-references'); this.referenceHeadline = this.confirmActionModalEntityReferences.locator('#reference-headline').first(); this.entityItemRef = this.confirmActionModalEntityReferences.locator('uui-ref-list').first().getByTestId('entity-item-ref'); this.validationMessage = page.locator('umb-form-validation-message').locator('#messages'); this.successStateIcon = this.successState.locator('#state'); this.workspaceAction = page.locator('umb-workspace-action'); this.caretBtn = page.locator('#caret-button'); // Entity Action this.entityAction = page.locator('umb-entity-action-list umb-entity-action'); this.openEntityAction = page.locator('#action-modal[open]').locator(this.entityAction); // Workspace Entity Action this.workspaceActionMenuBtn = page.getByTestId('workspace:action-menu-button'); this.monacoEditor = page.locator('.monaco-editor'); this.openedModal = page.locator('uui-modal-container[backdrop]'); } async clickActionsMenuForNameInSectionSidebar(name) { await this.hover(this.sectionSidebar.locator('[label="' + name + '"]')); await this.click(this.sectionSidebar.locator('[label="' + name + '"] >> [label="Open actions menu"]').first()); } async clickActionsMenuForName(name) { const menuItemLocator = this.page.locator('uui-menu-item[label="' + name + '"]').locator('#menu-item').first(); await this.waitForVisible(menuItemLocator); await menuItemLocator.hover({ force: true }); await this.page.locator('uui-menu-item[label="' + name + '"] #action-modal').first().click({ force: true }); } async isActionsMenuForNameVisible(name, isVisible = true) { await this.click(this.page.locator('uui-menu-item[label="' + name + '"]')); await this.isVisible(this.page.locator('uui-menu-item[label="' + name + '"] #action-modal').first(), isVisible); } async clickCaretButtonForName(name) { await this.isCaretButtonWithNameVisible(name); await this.click(this.page.locator('uui-menu-item[label="' + name + '"]').locator('#caret-button').first()); } async isCaretButtonWithNameVisible(name, isVisible = true) { await this.isVisible(this.page.locator('uui-menu-item[label="' + name + '"]').locator('#caret-button').first(), isVisible); } async clickCaretButton() { await this.click(this.page.locator('#caret-button')); } async openCaretButtonForName(name) { const menuItem = this.page.locator('uui-menu-item[label="' + name + '"]'); const isCaretButtonOpen = await menuItem.getAttribute('show-children'); if (isCaretButtonOpen === null) { await this.clickCaretButtonForName(name); } } async reloadTree(treeName) { // Waits until the tree item is visible await this.waitForVisible(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 clickReloadButton() { await this.click(this.reloadBtn); } async clickReloadChildrenButton() { await this.click(this.reloadChildrenBtn, { force: true }); } 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 clickSaveButton() { await this.click(this.saveBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async waitForNetworkToBeIdle() { await this.waitForPageLoad(); } async clickChooseButton() { await this.click(this.chooseBtn); } async clickChooseContainerButton() { await this.click(this.containerChooseBtn); } async clickFilterChooseButton() { await this.click(this.filterChooseBtn); } async clickRenameFolderThreeDotsButton() { await this.click(this.renameFolderThreeDotsBtn); } async clickRenameFolderButton() { await this.clickRenameButton(); } async clickConfirmRenameButton() { await this.click(this.confirmRenameBtn); } async clickUpdateFolderButton() { await this.click(this.updateFolderBtn); } async clickUpdateButton() { await this.click(this.updateBtn); } async clickSubmitButton() { await this.click(this.submitBtn); } async clickConfirmToSubmitButton() { await this.click(this.confirmToSubmitBtn); } async clickChangeButton() { await this.click(this.changeBtn); } async clickExactLinkWithName(name, toForce = false) { const exactLinkWithNameLocator = this.page.getByRole('link', { name: name, exact: true }); await this.click(exactLinkWithNameLocator, { force: toForce }); } async enterAliasName(aliasName) { // Unlocks alias await this.click(this.aliasLockBtn); await this.enterText(this.aliasNameTxt, aliasName); } async updateIcon(iconName) { // Force click is needed await this.click(this.iconBtn, { force: true }); await this.searchForTypeToFilterValue(iconName); await this.clickLabelWithName(iconName, true, true); await this.clickSubmitButton(); } async clickTextButtonWithName(name) { await this.click(this.page.getByText(name, { exact: true })); } async clickSelectPropertyEditorButton() { await this.click(this.selectPropertyEditorBtn); } async clickCreateFolderButton() { await this.click(this.createFolderBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async enterAPropertyName(name) { await this.enterText(this.propertyNameTxt, name, { clearFirst: false }); } async clickConfirmButton() { await this.click(this.confirmBtn); } async clickBreadcrumbButton() { await this.click(this.breadcrumbBtn); } async clickInsertButton() { await this.click(this.insertBtn); } 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 clickRemoveExactButton() { await this.click(this.removeExactBtn); } 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); } async clickDisableButton() { await this.click(this.disableBtn); } async clickConfirmDisableButton() { await this.click(this.confirmDisableBtn); } async clickConfirmRemoveButton() { await this.click(this.confirmToRemoveBtn); } async clickEnableButton() { await this.click(this.enableBtn); } async clickConfirmEnableButton() { await this.click(this.confirmEnableBtn); } async insertDictionaryItem(dictionaryName) { await this.clickInsertButton(); await this.click(this.insertDictionaryItemBtn); await this.click(this.page.getByLabel(dictionaryName)); await this.click(this.chooseBtn); } async addQueryBuilderWithOrderByStatement(propertyAlias, isAscending) { await this.click(this.queryBuilderBtn, { timeout: ConstantHelper_1.ConstantHelper.timeout.long }); await this.click(this.orderByPropertyAliasBtn); // Wait and choose property alias option await this.waitAndSelectQueryBuilderDropDownList(propertyAlias); await this.click(this.orderByPropertyAliasBtn); // Click to ascending button if isAscending is false if (!isAscending) { await this.click(this.ascendingBtn); } } async addQueryBuilderWithWhereStatement(propertyAlias, operator, constrainValue) { await this.click(this.queryBuilderBtn, { timeout: ConstantHelper_1.ConstantHelper.timeout.long }); // Wait and choose property alias await this.click(this.wherePropertyAliasBtn); await this.waitAndSelectQueryBuilderDropDownList(propertyAlias); // Wait and choose operator await this.click(this.whereOperatorBtn); await this.waitAndSelectQueryBuilderDropDownList(operator); // Wait and choose constrain value and press Enter 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 createFolder(folderName) { await this.clickCreateActionMenuOption(); await this.clickNewFolderThreeDotsButton(); await this.enterFolderName(folderName); await this.clickConfirmCreateFolderButton(); } async deletePropertyEditor(propertyEditorName) { // We need to hover over the property to be able to see the delete button await this.hover(this.page.locator('uui-button').filter({ hasText: propertyEditorName }).getByLabel('Editor settings')); await this.click(this.deleteBtn); } async enterFolderName(folderName) { await this.enterText(this.folderNameTxt, folderName, { verify: true }); } async isTextWithExactNameVisible(name, isVisible = true) { return this.isVisible(this.page.getByText(name, { exact: true }), isVisible); } async isQueryBuilderCodeShown(code) { await this.click(this.queryBuilderShowCode); await this.containsText(this.queryBuilderShowCode, code, ConstantHelper_1.ConstantHelper.timeout.long); } async deleteFolder() { await this.clickDeleteActionMenuOption(); await this.clickConfirmToDeleteButton(); } async clickDeleteExactButton() { await this.click(this.deleteExactBtn); } async isTreeItemVisible(name, isVisible = true) { await this.isVisible(this.page.locator('umb-tree-item').locator('[label="' + name + '"]'), isVisible); } async doesTreeItemHaveTheCorrectIcon(name, icon) { return await this.isVisible(this.page.locator('umb-tree-item').filter({ hasText: name }).locator('umb-icon').locator('[name="' + icon + '"]')); } async goToSection(sectionName, checkSections = true) { if (checkSections) { for (let section in ConstantHelper_1.ConstantHelper.sections) { await this.isVisible(this.backOfficeHeader.getByRole('tab', { name: ConstantHelper_1.ConstantHelper.sections[section] }), true, ConstantHelper_1.ConstantHelper.timeout.navigation); } } 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 clickDataElement(elementName, options = null) { await this.page.click(`[data-element="${elementName}"]`, options); } async getDataElement(elementName) { return this.page.locator(`[data-element="${elementName}"]`); } async isButtonWithNameVisible(name) { await this.isVisible(this.page.getByRole('button', { name: name })); } 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 }); // Force click is needed await this.click(exactButtonWithNameLocator, { force: true }); } async isSuccessNotificationVisible(isVisible = true) { return await this.isVisible(this.successNotification.first(), isVisible, ConstantHelper_1.ConstantHelper.timeout.long); } async doesSuccessNotificationsHaveCount(count) { return await this.hasCount(this.successNotification, count); } async isErrorNotificationVisible(isVisible = true) { return await this.isVisible(this.errorNotification.first(), isVisible); } async isTextWithMessageVisible(message, isVisible = true) { return await this.isVisible(this.page.getByText(message), isVisible); } async clickCreateThreeDotsButton() { await this.click(this.createThreeDotsBtn); } async clickCreateButton() { await this.click(this.createBtn); } async clickAddButton() { await this.click(this.addBtn); } ; async clickNewFolderThreeDotsButton() { await this.click(this.newFolderThreeDotsBtn); } async clickEditorSettingsButton(index = 0) { await this.click(this.editorSettingsBtn.nth(index)); } async enterDescription(description) { await this.enterText(this.enterDescriptionTxt, description); } async doesDescriptionHaveValue(value, index = 0) { return await this.hasValue(this.descriptionBtn.nth(index), value); } async clickStructureTab() { await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.medium); await this.click(this.structureTabBtn); } async clickAllowAtRootButton() { await this.click(this.allowAtRootBtn); } async clickIAmDoneReorderingButton() { await this.click(this.iAmDoneReorderingBtn); } async clickReorderButton() { await this.click(this.reorderBtn); } async clickLabelAboveButton() { await this.click(this.labelAboveBtn); } 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 clickCompositionsButton() { await this.click(this.compositionsBtn); } async clickAddTabButton() { await this.click(this.addTabBtn); } async enterTabName(tabName) { await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.debounce); await this.enterText(this.unnamedTabTxt, tabName); await this.isVisible(this.page.getByTestId('tab:' + tabName)); } async searchForTypeToFilterValue(searchValue) { await this.enterText(this.typeToFilterSearchTxt, searchValue, { clearFirst: false }); } 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 enterPropertyEditorDescription(description) { await this.enterText(this.enterPropertyEditorDescriptionTxt, description); } async clickAddGroupButton() { await this.click(this.addGroupBtn); } async clickChooseModalButton() { await this.click(this.chooseModalBtn); } 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) { return await this.hasValue(this.groupLabel, value); } 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); } async isSuccessButtonWithTextVisible(text) { return await this.isVisible(this.successState.filter({ hasText: text })); } 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 dragFromSelector.hover(); await this.page.mouse.move(10, 10); await dragFromSelector.hover(); 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(); } async getButtonWithName(name) { await this.waitForVisible(this.page.getByRole('button', { name: name })); return this.page.getByRole('button', { name: name }); } async clickCreateLink() { await this.click(this.createLink); } 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(); } async deletePropertyEditorWithName(name) { // We need to hover over the Property Editor to make the delete button visible const propertyEditor = this.page.locator('umb-content-type-design-editor-property', { hasText: name }); await this.hover(propertyEditor); // Force click is needed await this.click(propertyEditor.getByLabel('Delete'), { force: true }); await this.clickConfirmToDeleteButton(); } async clickRenameButton() { await this.click(this.renameBtn); } async clickDeleteAndConfirmButton() { await this.clickDeleteActionMenuOption(); await this.clickConfirmToDeleteButton(); } async clickDeleteButton() { await this.click(this.deleteBtn); } async clickQueryBuilderButton() { await this.click(this.queryBuilderBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async chooseRootContentInQueryBuilder(contentName) { await this.click(this.chooseRootContentBtn); await this.clickModalMenuItemWithName(contentName); await this.clickChooseButton(); } 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('[name="icon-grip"]').first(); const dragFromLocator = secondGroup.locator('[name="icon-grip"]').first(); await this.dragAndDrop(dragFromLocator, dragToLocator, 0, 0, 10); return { firstGroupValue, secondGroupValue }; } async clickAllowedChildNodesButton() { await this.click(this.allowedChildNodesModal.locator(this.chooseBtn)); } async clickAddCollectionButton() { await this.click(this.addCollectionBtn); } async doesReturnedItemsHaveCount(itemCount) { await this.containsText(this.returnedItemsCount, itemCount.toString() + ' published items returned'); } async doesQueryResultHaveContentName(contentName) { await this.containsText(this.queryResults, contentName); } 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'); // Force click is needed await this.click(headerActionsDeleteLocator, { force: true }); return; } } } async clickRemoveTabWithName(name) { const tabLocator = this.page.locator('uui-tab').filter({ hasText: name }); await this.hover(tabLocator); const removeTabWithNameLocator = tabLocator.locator('[label="Remove"]'); await this.click(removeTabWithNameLocator); } async clickLeftArrowButton() { await this.click(this.leftArrowBtn); } 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); } getTabLocatorWithName(name) { return this.page.getByRole('tab', { name: name }); } getTextLocatorWithName(name) { return this.page.getByText(name, { exact: true }); } getLocatorWithDataMark(dataMark) { return this.page.getByTestId(dataMark); } ; async isFailedStateButtonVisible() { await this.isVisible(this.failedStateButton); } async clickContainerSaveAndPublishButton() { await this.click(this.containerSaveAndPublishBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async clickConfirmTrashButton() { await this.click(this.confirmTrashBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async reloadRecycleBin(containsItems = true) { await this.waitForVisible(this.recycleBinMenuItem); // If the Recycle Bin does not contain any items, the caret button should not be visible and we should not try to click it 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 clickRecycleBinButton() { await this.click(this.recycleBinBtn); } 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); } 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); } async doesSuccessNotificationHaveText(text, isVisible = true, deleteNotification = false) { await this.isVisible(this.successNotification.filter({ hasText: text }), isVisible); if (deleteNotification) { await this.click(this.successNotification.filter({ hasText: text }).getByLabel('close'), { force: true }); } } async doesErrorNotificationHaveText(text, isVisible = true, deleteNotification = false) { await this.isVisible(this.errorNotification.filter({ hasText: text }), isVisible); if (deleteNotification) { await this.click(this.errorNotification.filter({ hasText: text }).locator('svg')); } } async isSectionWithNameVisible(sectionName, isVisible = true) { await this.isVisible(this.page.getByRole('tab', { name: sectionName }), isVisible); } async clickMediaWithName(name) { await this.click(this.mediaCardItems.filter({ hasText: name })); } async clickChooseContentStartNodeButton() { await this.click(this.chooseDocumentInputBtn); } async clickChooseMediaStartNodeButton() { await this.click(this.chooseMediaInputBtn); } async clickActionButton() { await this.click(this.actionBtn); } async clickReferenceNodeLinkWithName(name) { await this.click(this.page.locator('[name="' + name + '"] a#open-part')); } async clickLinkWithName(name, isExact = false) { await this.click(this.page.getByRole('link', { name: name, exact: isExact })); } async clickMediaPickerModalSubmitButton() { await this.click(this.mediaPickerModalSubmitBtn); } async selectMediaWithName(mediaName) { const mediaLocator = this.mediaCardItems.filter({ hasText: mediaName }); await this.waitForVisible(mediaLocator); await mediaLocator.click({ position: { x: 0.5, y: 0.5 } }); } async selectMediaWithTestId(mediaKey) { const locator = this.page.getByTestId('media:' + mediaKey); await this.waitForVisible(locator); await locator.click({ position: { x: 0.5, y: 0.5 } }); } async clickCreateModalButton() { await this.click(this.createModalBtn); } async clickMediaCaptionAltTextModalSubmitButton() { await this.click(this.mediaCaptionAltTextModalSubmitBtn); } // Embed Modal 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); } async isSubmitButtonDisabled() { await this.waitForVisible(this.submitBtn); await this.hasAttribute(this.submitBtn, 'disabled', ''); } async doesMediaHaveThumbnail(mediaId, thumbnailIconName, thumbnailImage) { const mediaThumbnailLocator = this.page.getByTestId('media:' + mediaId); if (thumbnailIconName === 'image') { const regexImageSrc = new RegExp(`^${thumbnailImage}.*`); await this.waitForAttribute(mediaThumbnailLocator.locator('umb-imaging-thumbnail img'), 'src', regexImageSrc); } else { await this.hasAttribute(mediaThumbnailLocator.locator('umb-imaging-thumbnail umb-icon'), 'name', thumbnailIconName); } } async clickCurrentUserAvatarButton() { await this.click(this.currentUserAvatarBtn); } async clickCreateActionButton() { await this.click(this.createActionBtn); } async clickCreateActionWithOptionName(optionName) { await this.clickCreateActionButton(); const createOptionLocator = this.createActionButtonCollection.locator('[label="' + optionName + '"]'); await this.click(createOptionLocator); } async doesCollectionTreeItemTableRowHaveName(name) { await this.waitForVisible(this.collectionTreeItemTableRow.first()); await this.isVisible(this.collectionTreeItemTableRow.locator('[label="' + name + '"]')); } async doesCollectionTreeItemTableRowHaveIcon(name, icon) { await this.waitForVisible(this.collectionTreeItemTableRow.first()); await this.isVisible(this.collectionTreeItemTableRow.filter({ hasText: name }).locator('umb-icon').locator('[name="' + icon + '"]')); } async clickFolderButton() { await this.click(this.folderBtn); } async doesReferenceHeadlineHaveText(text) { await this.containsText(this.referenceHeadline, text); } async isReferenceHeadlineVisible(isVisible) { await this.isVisible(this.referenceHeadline, isVisible); } async doesReferenceItemsHaveCount(count) { await this.hasCount(this.entityItemRef, count); } async isReferenceItemNameVisible(itemName) { await this.isVisible(this.entityItemRef.locator('uui-ref-node[name="' + itemName + '"]')); } async doesReferencesContainText(text) { await this.containsText(this.confirmActionModalEntityReferences, text); } async isValidationMessageVisible(message, isVisible = true) { await this.isVisible(this.validationMessage.filter({ hasText: message }), isVisible); } async isSuccessStateIconVisible() { await this.isVisible(this.successStateIcon); } 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); } // Entity Action async clickEntityActionWithName(name) { const regex = new RegExp(`^entity-action:.*${name}$`); await this.openEntityAction.getByTestId(regex).filter({ has: this.page.locator(':visible') }).click(); } async clickCreateActionMenuOption() { await this.clickEntityActionWithName('Create'); } async clickTrashActionMenuOption() { await this.clickEntityActionWithName('Trash'); } async clickMoveToActionMenuOption() { await this.clickEntityActionWithName('MoveTo'); } async clickCreateBlueprintActionMenuOption() { await this.clickEntityActionWithName('CreateBlueprint'); } async clickDuplicateToActionMenuOption() { await this.clickEntityActionWithName('DuplicateTo'); } async clickPublishActionMenuOption() { await this.clickEntityActionWithName('Publish'); } async clickUnpublishActionMenuOption() { await this.clickEntityActionWithName('Unpublish'); } async clickRollbackActionMenuOption() { await this.clickEntityActionWithName('Rollback'); } async clickCultureAndHostnamesActionMenuOption() { await this.clickEntityActionWithName('CultureAndHostnames'); } async clickPublicAccessActionMenuOption() { await this.clickEntityActionWithName('PublicAccess'); } async clickSortChildrenActionMenuOption() { await this.clickEntityActionWithName('SortChildrenOf'); } async clickNotificationsActionMenuOption() { await this.clickEntityActionWithName('Notifications'); } async clickReloadChildrenActionMenuOption() { await this.clickEntityActionWithName('ReloadChildrenOf'); } async clickDeleteActionMenuOption() { await this.clickEntityActionWithName('Delete'); } async clickRestoreActionMenuOption() { await this.clickEntityActionWithName('Restore'); } async clickRenameActionMenuOption() { await this.clickEntityActionWithName('Rename'); } async clickCreateOptionsActionMenuOption() { await this.clickEntityActionWithName('CreateOptions'); } async clickExportActionMenuOption() { await this.clickEntityActionWithName('Export'); } async clickImportActionMenuOption() { await this.clickEntityActionWithName('Import'); } async clickUpdateActionMenuOption() { await this.clickEntityActionWithName('Update'); } async clickModalMenuItemWithName(name) { await this.click(this.openedModal.locator('uui-menu-item[label="' + name + '"]')); } async isModalMenuItemWithNameDisabled(name) { await this.hasAttribute(this.sidebarModal.locator('uui-menu-item[label="' + name + '"]'), 'disabled', ''); } async doesPropertyHaveInvalidBadge(propertyName) { await this.isVisible(this.page.locator('umb-property-layout').filter({ hasText: propertyName }).locator('#invalid-badge uui-badge')); } async isModalMenuItemWithNameVisible(name, isVisible = true) { await this.isVisible(this.sidebarModal.locator('uui-menu-item[label="' + name + '"]'), isVisible); } async clickEntityItemByName(itemName) { await this.click(this.page.locator('uui-ref-node,umb-ref-item[name="' + itemName + '"]')); } 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 clickWorkspaceActio