UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

1,026 lines 84.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LibraryUiHelper = void 0; const test_1 = require("@playwright/test"); const UiBaseLocators_1 = require("./UiBaseLocators"); const ConstantHelper_1 = require("./ConstantHelper"); class LibraryUiHelper extends UiBaseLocators_1.UiBaseLocators { elementNameTxt; saveAndPublishBtn; publishBtn; unpublishBtn; actionMenuForElementBtn; textstringTxt; infoTab; linkElement; historyItems; generalItem; elementState; createdDate; editElementTypeBtn; addTemplateBtn; id; cultureAndHostnamesBtn; cultureLanguageDropdownBox; addNewHostnameBtn; hostnameTxt; hostnameLanguageDropdownBox; deleteHostnameBtn; reloadChildrenThreeDotsBtn; elementTree; richTextAreaTxt; textAreaTxt; plusIconBtn; enterTagTxt; menuItemTree; hostnameComboBox; confirmToUnpublishBtn; saveModalBtn; dropdown; setADateTxt; chooseMediaPickerBtn; chooseMemberPickerBtn; numericTxt; resetFocalPointBtn; addMultiURLPickerBtn; linkTxt; anchorQuerystringTxt; linkTitleTxt; tagItems; removeFilesBtn; toggleBtn; toggleInput; elementTypeWorkspace; addMultipleTextStringBtn; multipleTextStringValueTxt; sliderInput; tabItems; elementWorkspace; selectAVariantBtn; variantAddModeBtn; saveAndCloseBtn; enterNameInContainerTxt; elementCollectionView; nameBtn; elementCollectionViewTableRow; publishSelectedListItems; unpublishSelectedListItems; duplicateToSelectedListItems; moveToSelectedListItems; trashSelectedListItems; modalElement; trashBtn; elementElementCollectionView; elementGridView; elementFolderCollectionView; elementTreeItem; elementLanguageSelect; elementLanguageSelectPopover; elementReadOnly; elementWorkspaceEditor; exactTrashBtn; emptyRecycleBinBtn; confirmEmptyRecycleBinBtn; duplicateToBtn; moveToBtn; duplicateBtn; elementTreeRefreshBtn; sortChildrenBtn; rollbackBtn; rollbackContainerBtn; publicAccessBtn; uuiCheckbox; sortBtn; containerSaveBtn; groupBasedProtectionBtn; chooseMemberGroupBtn; selectLoginPageElement; selectErrorPageElement; rollbackItem; actionsMenu; linkToElementBtn; linkToMediaBtn; linkToManualBtn; umbElementCollection; elementTableColumnName; addBlockElementBtn; formValidationMessage; blockName; addBlockSettingsTabBtn; editBlockEntryBtn; copyBlockEntryBtn; deleteBlockEntryBtn; blockGridEntry; blockListEntry; tipTapPropertyEditor; tipTapEditor; uploadedSvgThumbnail; linkPickerModal; pasteFromClipboardBtn; pasteBtn; closeBtn; workspaceEditTab; workspaceEditProperties; exactCopyBtn; openActionsMenu; replaceExactBtn; clipboardEntryPicker; blockWorkspaceEditTab; insertBlockBtn; blockWorkspace; saveElementBtn; splitView; tiptapInput; rteBlockInline; modalCreateBtn; modalUpdateBtn; rteBlock; workspaceActionMenu; workspaceActionMenuItem; viewMoreOptionsBtn; schedulePublishBtn; schedulePublishModalBtn; elementScheduleModal; publishAtFormLayout; unpublishAtFormLayout; publishAtValidationMessage; unpublishAtValidationMessage; lastPublished; publishAt; blockGridAreasContainer; blockGridBlock; blockGridEntries; inlineCreateBtn; removeAt; selectAllCheckbox; confirmToPublishBtn; tiptapStatusbarWordCount; tiptapStatusbarElementPath; publishWithDescendantsBtn; elementPublishWithDescendantsModal; includeUnpublishedDescendantsToggle; publishWithDescendantsModalBtn; elementVariantLanguagePicker; elementVariantLanguageItem; styleSelectBtn; cascadingMenuContainer; modalFormValidationMessage; treePickerSearchTxt; mediaPickerSearchTxt; memberPickerSearchTxt; elementCreateOptionsModal; refListBlock; propertyActionMenu; elementCollectionViewCustomRows; collectionMenu; entityPickerTree; hostNameItem; languageToggle; elementVariantDropdown; blockProperty; linkPickerAddBtn; linkPickerCloseBtn; linkPickerTargetToggle; confirmToResetBtn; saveModal; expandSegmentBtn; elementBtn; elementFolderBtn; entityActionsBundle; referencesWorkspaceInfoApp; noReferencesText; referencesItemsInInfoTab; constructor(page) { super(page); this.saveElementBtn = page.getByTestId('workspace-action:Umb.WorkspaceAction.Element.Save'); this.saveAndPublishBtn = page.getByTestId('workspace-action:Umb.WorkspaceAction.Element.SaveAndPublish'); this.closeBtn = page.getByRole('button', { name: 'Close', exact: true }); this.linkPickerModal = page.locator('umb-link-picker-modal'); this.elementNameTxt = page.locator('#name-input input'); this.publishBtn = page.getByLabel(/^Publish(…)?$/); this.unpublishBtn = page.getByLabel(/^Unpublish(…)?$/); this.actionMenuForElementBtn = page.locator('#header').getByTestId('open-dropdown'); this.textstringTxt = page.locator('umb-property-editor-ui-text-box #input'); this.reloadChildrenThreeDotsBtn = page.getByRole('button', { name: 'Reload children…' }); this.elementTree = page.locator('umb-tree[alias="Umb.Tree.Element"]'); this.richTextAreaTxt = page.frameLocator('iframe[title="Rich Text Area"]').locator('#tinymce'); this.textAreaTxt = page.locator('umb-property-editor-ui-textarea textarea'); this.plusIconBtn = page.locator('#icon-add svg'); this.enterTagTxt = page.getByPlaceholder('Enter tag'); this.menuItemTree = page.locator('umb-menu-item-tree-default'); this.confirmToUnpublishBtn = this.backofficeModalContainer.getByLabel('Unpublish'); this.dropdown = page.locator('select#native'); this.splitView = page.locator('#splitViews'); this.setADateTxt = page.getByLabel('Set a date…'); this.chooseMediaPickerBtn = page.locator('umb-property-editor-ui-media-picker #btn-add'); this.chooseMemberPickerBtn = page.locator('umb-property-editor-ui-member-picker #btn-add'); this.numericTxt = page.locator('umb-property-editor-ui-number input'); this.addMultiURLPickerBtn = page.locator('umb-property-editor-ui-multi-url-picker #btn-add'); this.linkTxt = page.getByTestId('input:url').locator('#input'); this.anchorQuerystringTxt = page.getByLabel('#value or ?key=value'); this.linkTitleTxt = this.linkPickerModal.getByLabel('Title'); this.tagItems = page.locator('uui-tag'); this.removeFilesBtn = page.locator('umb-input-upload-field [label="Clear file(s)"]'); this.toggleBtn = page.locator('umb-property-editor-ui-toggle #toggle'); this.toggleInput = page.locator('umb-property-editor-ui-toggle span'); this.elementTypeWorkspace = this.sidebarModal.locator('umb-element-type-workspace-editor'); this.addMultipleTextStringBtn = page.locator('umb-input-multiple-text-string').getByLabel('Add'); this.multipleTextStringValueTxt = page.locator('umb-input-multiple-text-string').getByLabel('Value'); this.sliderInput = page.locator('umb-property-editor-ui-slider #input'); this.tabItems = page.locator('uui-tab'); this.elementWorkspace = page.locator('umb-element-workspace-editor'); this.selectAVariantBtn = page.getByRole('button', { name: 'Open version selector' }); this.variantAddModeBtn = page.locator('.switch-button.add-mode').locator('.variant-name'); this.saveAndCloseBtn = page.getByLabel('Save and close'); this.elementTreeItem = page.locator('umb-default-tree-item'); this.elementLanguageSelect = page.locator('umb-app-language-select'); this.elementLanguageSelectPopover = page.locator('umb-popover-layout'); this.elementReadOnly = this.elementWorkspace.locator('#name-input').getByText('Read-only'); // Info tab this.infoTab = page.getByTestId('workspace:view-link:Umb.WorkspaceView.Element.Info'); this.linkElement = page.locator('umb-element-links-workspace-info-app'); this.historyItems = page.locator('umb-history-item'); this.generalItem = page.locator('.general-item'); this.elementState = this.generalItem.locator('uui-tag'); this.createdDate = this.generalItem.filter({ hasText: 'Created' }).locator('umb-localize-date'); this.editElementTypeBtn = this.generalItem.filter({ hasText: 'Element Type' }).locator('#button'); this.addTemplateBtn = this.generalItem.filter({ hasText: 'Template' }).locator('#button'); this.id = this.generalItem.filter({ hasText: 'Id' }).locator('span'); this.elementCreateOptionsModal = page.locator('umb-element-create-options-modal'); // Culture and Hostname this.cultureAndHostnamesBtn = page.getByLabel(/^Culture and Hostnames(…)?$/); this.hostNameItem = page.locator('.hostname-item'); this.cultureLanguageDropdownBox = this.page.locator('[label="Culture"]').getByLabel('combobox-input'); this.hostnameTxt = page.getByLabel('Hostname', { exact: true }); this.hostnameLanguageDropdownBox = this.hostNameItem.locator('[label="Culture"]').getByLabel('combobox-input'); this.deleteHostnameBtn = this.hostNameItem.locator('[name="icon-trash"] svg'); this.hostnameComboBox = this.hostNameItem.locator('[label="Culture"]').locator('uui-combobox-list-option'); this.saveModal = page.locator('umb-element-save-modal'); this.saveModalBtn = this.saveModal.getByLabel('Save', { exact: true }); this.resetFocalPointBtn = page.getByLabel('Reset focal point'); this.addNewHostnameBtn = page.locator('umb-property-layout[label="Hostnames"]').locator('[label="Add new hostname"]'); // List View this.enterNameInContainerTxt = this.container.getByTestId('input:entity-name').locator('#input'); this.elementCollectionView = page.locator('umb-collection-workspace-view'); this.nameBtn = page.getByRole('button', { name: 'Name', exact: true }); this.elementCollectionViewTableRow = this.elementCollectionView.locator('uui-table-row'); this.publishSelectedListItems = page.locator('umb-entity-bulk-action').getByText('Publish', { exact: true }); this.unpublishSelectedListItems = page.locator('umb-entity-bulk-action').getByText('Unpublish', { exact: true }); this.duplicateToSelectedListItems = page.locator('umb-entity-bulk-action').getByText('Duplicate to', { exact: true }); this.moveToSelectedListItems = page.locator('umb-entity-bulk-action').getByText('Move to', { exact: true }); this.trashSelectedListItems = page.locator('umb-entity-bulk-action').getByText('Trash', { exact: true }); this.modalElement = page.locator('umb-tree-picker-modal'); this.trashBtn = page.getByLabel(/^Trash(…)?$/); this.exactTrashBtn = page.getByRole('button', { name: 'Trash', exact: true }); this.elementElementCollectionView = page.locator('umb-element-table-collection-view'); this.elementGridView = page.locator('umb-element-grid-collection-view'); this.elementFolderCollectionView = page.locator('umb-element-folder-workspace-view-collection'); this.elementWorkspaceEditor = page.locator('umb-workspace-editor'); this.emptyRecycleBinBtn = page.getByTestId('entity-action:Umb.EntityAction.Element.RecycleBin.Empty').locator('#button'); this.confirmEmptyRecycleBinBtn = page.locator('#confirm').getByLabel('Empty recycle bin', { exact: true }); this.duplicateToBtn = page.getByRole('button', { name: 'Duplicate to' }); this.moveToBtn = page.getByRole('button', { name: 'Move to' }); this.duplicateBtn = page.getByLabel('Duplicate', { exact: true }); this.elementTreeRefreshBtn = page.locator('#header').getByLabel('#actions_refreshNode'); this.sortChildrenBtn = page.getByRole('button', { name: 'Sort children' }); this.rollbackBtn = page.getByRole('button', { name: 'Rollback…' }); this.rollbackContainerBtn = this.container.getByLabel('Rollback'); this.publicAccessBtn = page.getByRole('button', { name: 'Public Access' }); this.uuiCheckbox = page.locator('uui-checkbox'); this.sortBtn = page.getByLabel('Sort', { exact: true }); this.containerSaveBtn = this.container.getByLabel('Save'); this.groupBasedProtectionBtn = page.locator('span').filter({ hasText: 'Group based protection' }); this.chooseMemberGroupBtn = page.locator('umb-input-member-group').getByLabel('Choose'); this.selectLoginPageElement = page.locator('.select-item').filter({ hasText: 'Login Page' }).locator('umb-input-element').locator('#button'); this.selectErrorPageElement = page.locator('.select-item').filter({ hasText: 'Error Page' }).locator('umb-input-element').locator('#button'); this.rollbackItem = page.locator('.rollback-item'); this.actionsMenu = page.locator('uui-scroll-container'); this.linkToElementBtn = this.linkPickerModal.getByTestId('action:element').locator('#button'); this.linkToMediaBtn = this.linkPickerModal.getByTestId('action:media').locator('#button'); this.linkToManualBtn = this.linkPickerModal.getByTestId('action:external').locator('#button'); this.umbElementCollection = page.locator('umb-element-collection'); this.elementTableColumnName = this.elementCollectionView.locator('umb-element-table-column-name'); //Block Grid - Block List this.addBlockElementBtn = page.locator('uui-button-group > uui-button').first().filter({ has: page.locator('a#button') }); this.formValidationMessage = page.locator('#splitViews umb-form-validation-message #messages'); this.blockName = page.locator('#editor [slot="name"]'); this.addBlockSettingsTabBtn = page.locator('umb-body-layout').getByRole('tab', { name: 'Settings' }); this.editBlockEntryBtn = page.locator('[label="edit"] svg'); this.copyBlockEntryBtn = page.getByLabel('Copy to clipboard'); this.exactCopyBtn = page.getByRole('button', { name: 'Copy', exact: true }); this.deleteBlockEntryBtn = page.locator('[label="delete"] svg'); this.blockGridEntry = page.locator('umb-block-grid-entry'); this.blockGridBlock = page.locator('umb-block-grid-block'); this.blockListEntry = page.locator('umb-block-list-entry'); this.pasteFromClipboardBtn = page.getByLabel('Paste from clipboard'); this.pasteBtn = page.getByRole('button', { name: 'Paste', exact: true }); this.workspaceEditTab = page.locator('umb-element-workspace-view-edit-tab'); this.blockWorkspaceEditTab = page.locator('umb-block-workspace-view-edit-tab'); this.workspaceEditProperties = page.locator('umb-element-workspace-view-edit-properties'); this.openActionsMenu = page.locator('#action-menu'); this.replaceExactBtn = page.getByRole('button', { name: 'Replace', exact: true }); this.clipboardEntryPicker = page.locator('umb-clipboard-entry-picker'); this.blockGridAreasContainer = page.locator('umb-block-grid-areas-container'); this.blockGridEntries = page.locator('umb-block-grid-entries'); this.inlineCreateBtn = page.locator('uui-button-inline-create'); this.refListBlock = page.locator('umb-ref-list-block'); // TipTap this.tipTapPropertyEditor = page.locator('umb-property-editor-ui-tiptap'); this.tipTapEditor = this.tipTapPropertyEditor.locator('#editor .tiptap'); this.uploadedSvgThumbnail = page.locator('umb-input-upload-field-svg img'); this.insertBlockBtn = page.getByTestId('action:tiptap-toolbar:Umb.Tiptap.Toolbar.BlockPicker'); this.blockWorkspace = page.locator('umb-block-workspace-editor'); this.tiptapInput = page.locator('umb-input-tiptap'); this.rteBlockInline = page.locator('umb-rte-block-inline'); this.modalCreateBtn = this.backofficeModalContainer.getByLabel('Create', { exact: true }); this.modalUpdateBtn = this.backofficeModalContainer.getByLabel('Update', { exact: true }); this.rteBlock = page.locator('umb-rte-block'); this.tiptapStatusbarWordCount = page.locator('umb-tiptap-statusbar-word-count'); this.tiptapStatusbarElementPath = page.locator('umb-tiptap-statusbar-element-path'); // Scheduled Publishing this.workspaceActionMenu = page.locator('umb-workspace-action-menu'); this.workspaceActionMenuItem = page.locator('umb-workspace-action-menu-item'); this.viewMoreOptionsBtn = this.workspaceActionMenu.locator('#popover-trigger'); this.schedulePublishBtn = this.workspaceActionMenuItem.getByLabel('Schedule publish', { exact: true }); this.elementScheduleModal = page.locator('umb-element-schedule-modal'); this.schedulePublishModalBtn = this.elementScheduleModal.getByLabel('Schedule publish', { exact: true }); this.publishAtFormLayout = this.elementScheduleModal.locator('uui-form-layout-item').first(); this.unpublishAtFormLayout = this.elementScheduleModal.locator('uui-form-layout-item').last(); this.publishAtValidationMessage = this.publishAtFormLayout.locator('#messages'); this.unpublishAtValidationMessage = this.unpublishAtFormLayout.locator('#messages'); this.lastPublished = this.generalItem.filter({ hasText: 'Last published' }).locator('umb-localize-date'); this.publishAt = this.generalItem.filter({ hasText: 'Publish at' }).locator('umb-localize-date'); this.removeAt = this.generalItem.filter({ hasText: 'Remove at' }).locator('umb-localize-date'); this.selectAllCheckbox = page.locator('[label="Select all"]'); this.confirmToPublishBtn = this.backofficeModalContainer.getByLabel('Publish'); // Publish with descendants this.elementPublishWithDescendantsModal = page.locator('umb-element-publish-with-descendants-modal'); this.publishWithDescendantsBtn = this.workspaceActionMenuItem.getByLabel('Publish with descendants', { exact: true }); this.includeUnpublishedDescendantsToggle = this.elementPublishWithDescendantsModal.locator('#includeUnpublishedDescendants'); this.publishWithDescendantsModalBtn = this.elementPublishWithDescendantsModal.getByLabel('Publish with descendants', { exact: true }); this.elementVariantLanguagePicker = page.locator('umb-element-variant-language-picker'); this.elementVariantLanguageItem = this.elementVariantLanguagePicker.locator('uui-menu-item'); // Tiptap - Style Select this.styleSelectBtn = page.locator('uui-button[label="Style Select"]'); this.cascadingMenuContainer = page.locator('umb-cascading-menu-popover uui-scroll-container'); this.modalFormValidationMessage = this.sidebarModal.locator('umb-form-validation-message #messages'); this.treePickerSearchTxt = this.page.locator('umb-tree-picker-modal #input'); this.mediaPickerSearchTxt = this.page.locator('umb-media-picker-modal #search #input'); this.memberPickerSearchTxt = this.page.locator('umb-member-picker-modal #input'); // Property Actions this.propertyActionMenu = page.locator('#property-action-popover umb-popover-layout'); // List view custom this.elementCollectionViewCustomRows = page.locator('table tbody tr'); // Entity Data Picker this.collectionMenu = page.locator('umb-collection-menu'); this.entityPickerTree = page.locator('umb-tree[alias="Umb.Tree.EntityDataPicker"]'); this.languageToggle = page.getByTestId('input:entity-name').locator('#toggle'); this.elementVariantDropdown = page.locator('umb-workspace-split-view-variant-selector uui-popover-container #dropdown'); this.blockProperty = page.locator('umb-block-workspace-view-edit-property'); // Multi URL Picker this.linkPickerAddBtn = this.linkPickerModal.getByRole('button', { name: 'Add', exact: true }); this.linkPickerCloseBtn = this.linkPickerModal.getByRole('button', { name: 'Close', exact: true }); this.linkPickerTargetToggle = this.linkPickerModal.locator('[label="Opens the link in a new window or tab"]').locator('#toggle'); this.confirmToResetBtn = page.locator('#confirm').getByLabel('Reset', { exact: true }); // Segment this.expandSegmentBtn = page.locator('.expand-area uui-button'); // Element this.elementBtn = this.createOptionActionListModal.locator('[name="Element"]'); this.elementFolderBtn = this.createOptionActionListModal.locator('[name="Folder..."]'); this.entityActionsBundle = page.locator('umb-entity-actions-bundle'); // References this.referencesWorkspaceInfoApp = page.locator('umb-entity-references-workspace-info-app'); this.noReferencesText = this.referencesWorkspaceInfoApp.locator('umb-localize[key="references_itemHasNoReferences"]'); this.referencesItemsInInfoTab = this.referencesWorkspaceInfoApp.locator('uui-ref-list umb-entity-item-ref'); } async enterElementName(name) { await this.enterText(this.elementNameTxt, name, { verify: true }); } async clickSaveAndPublishButton() { await this.click(this.saveAndPublishBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async isSuccessStateVisibleForSaveAndPublishButton(isVisible = true) { const saveAndPublishBtn = this.workspaceAction.filter({ has: this.saveAndPublishBtn }); await this.isVisible(saveAndPublishBtn.locator(this.successState), isVisible, ConstantHelper_1.ConstantHelper.timeout.long); } async clickPublishButton() { await this.click(this.publishBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async clickUnpublishButton() { await this.click(this.unpublishBtn); } async clickReloadChildrenThreeDotsButton() { await this.click(this.reloadChildrenThreeDotsBtn); } async clickActionsMenuAtRoot() { await this.click(this.actionMenuForElementBtn, { force: true }); } async goToElementWithName(elementName) { const elementWithNameLocator = this.menuItemTree.getByText(elementName, { exact: true }); await this.click(elementWithNameLocator, { timeout: ConstantHelper_1.ConstantHelper.timeout.long }); } async clickActionsMenuForElement(name) { await this.clickActionsMenuForName(name); } async openElementCaretButtonForName(name) { const menuItem = this.menuItemTree.filter({ hasText: name }).last(); const isCaretButtonOpen = await menuItem.getAttribute('show-children'); if (isCaretButtonOpen === null) { await this.clickCaretButtonForElementName(name); } } async clickCaretButtonForElementName(name) { await this.click(this.menuItemTree.filter({ hasText: name }).last().locator('#caret-button').last()); } async waitForModalVisible() { await this.openedModal.waitFor({ state: 'attached' }); } async waitForModalHidden() { await this.openedModal.waitFor({ state: 'hidden' }); } async clickSaveButtonForElement() { await this.click(this.saveElementBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async enterTextstring(text) { await this.enterText(this.textstringTxt, text); } async isTextstringPropertyVisible(isVisible = true) { if (isVisible) { await (0, test_1.expect)(this.textstringTxt).toBeVisible(); } else { await (0, test_1.expect)(this.textstringTxt).not.toBeVisible(); } } async doesElementTreeHaveName(elementName) { await this.containsText(this.elementTree, elementName); } async enterRichTextArea(value) { await this.waitForVisible(this.richTextAreaTxt); await this.richTextAreaTxt.fill(value); } async enterTextArea(value) { await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.minimal); await this.enterText(this.textAreaTxt, value); } async clickConfirmToUnpublishButton() { await this.click(this.confirmToUnpublishBtn); } // Info Tab async clickInfoTab() { await this.click(this.infoTab); } async doesElementHaveLink(link) { await this.containsText(this.linkElement, link); } async doesHistoryHaveText(text) { await this.hasText(this.historyItems, text); } async doesElementStateHaveText(text) { await this.hasText(this.elementState, text); } async doesCreatedDateHaveText(text) { await this.hasText(this.createdDate, text); } async doesIdHaveText(text) { await this.hasText(this.id, text); } async clickEditElementTypeButton() { await this.click(this.editElementTypeBtn); } async clickAddTemplateButton() { await this.click(this.addTemplateBtn); } async clickSaveButtonAndWaitForElementToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickSaveButtonForElement(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickSaveModalButtonAndWaitForElementToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickSaveModalButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickSaveModalButtonAndWaitForElementToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickSaveModalButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickSaveAndPublishButtonAndWaitForElementToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickSaveAndPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickConfirmToPublishButtonAndWaitForElementToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickConfirmToPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickSaveButtonAndWaitForElementToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickSaveButtonForElement(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickSaveAndPublishButtonAndWaitForElementToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickSaveAndPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickSaveAndPublishButtonAndWaitForElementToBePublished() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickSaveAndPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickContainerSaveButton() { await this.click(this.containerSaveBtn); } async clickContainerSaveButtonAndWaitForElementToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickContainerSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickContainerSaveAndPublishButtonAndWaitForElementToBePublished() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.element, this.clickContainerSaveAndPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickElementTypeByName(elementTypeName) { await this.click(this.page.locator(`uui-ref-node-element-type[name="${elementTypeName}"]`)); } async clickTemplateByName(templateName) { await this.click(this.page.locator(`uui-ref-node[name="${templateName}"]`)); } async isElementTypeModalVisible(elementTypeName) { await this.isVisible(this.elementTypeWorkspace.filter({ hasText: elementTypeName })); } async isTemplateModalVisible(templateName) { await this.isVisible(this.breadcrumbsTemplateModal.getByText(templateName)); } async clickEditTemplateByName(templateName) { await this.click(this.page.locator(`uui-ref-node[name="${templateName}"]`).getByLabel('Choose')); } async changeTemplate(oldTemplate, newTemplate) { await this.clickEditTemplateByName(oldTemplate); await this.click(this.sidebarModal.getByLabel(newTemplate)); await this.clickChooseModalButton(); } async isTemplateNameDisabled(templateName) { await this.isVisible(this.sidebarModal.getByLabel(templateName)); await this.isDisabled(this.sidebarModal.getByLabel(templateName)); } // Culture and Hostnames async clickCultureAndHostnamesButton() { await this.click(this.cultureAndHostnamesBtn); } async clickAddNewHostnameButton() { await this.click(this.addNewHostnameBtn); } async selectCultureLanguageOption(option) { await this.click(this.cultureLanguageDropdownBox); await this.click(this.page.getByText(option, { exact: true })); } async selectHostnameLanguageOption(option, index = 0) { await this.click(this.hostnameLanguageDropdownBox.nth(index)); await this.click(this.hostnameComboBox.getByText(option).nth(index)); } async enterDomain(value, index = 0) { await this.enterText(this.hostnameTxt.nth(index), value, { verify: true }); } async clickDeleteHostnameButton() { await this.click(this.deleteHostnameBtn.first()); } async clickSaveModalButton() { await this.click(this.saveModalBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async chooseElementType(elementTypeName) { await this.click(this.documentTypeNode.filter({ hasText: elementTypeName })); } // Approved Color async clickApprovedColorByValue(value) { await this.click(this.page.locator(`uui-color-swatch[value="#${value}"] #swatch`)); } // Checkbox list async chooseCheckboxListOption(optionValue) { await this.click(this.page.locator(`uui-checkbox[value="${optionValue}"] svg`)); } // Element Picker async addElementPicker(elementName) { await this.clickChooseButton(); await this.click(this.sidebarModal.getByText(elementName)); await this.click(this.chooseModalBtn); } async isOpenButtonVisibleInElementPicker(elementPickerName, isVisible = true) { return await this.isVisible(this.page.getByLabel('Open ' + elementPickerName), isVisible); } async clickElementPickerOpenButton(elementPickerName) { await this.click(this.page.getByLabel('Open ' + elementPickerName)); } async isNodeOpenForElementPicker(elementPickerName) { return await this.isVisible(this.openedModal.getByText(elementPickerName)); } async isElementNameVisible(elementName, isVisible = true) { return await this.isVisible(this.sidebarModal.getByText(elementName), isVisible); } async isElementInTreeVisible(name, isVisible = true) { await this.isVisible(this.elementTreeItem.getByLabel(name, { exact: true }).first(), isVisible); } async isChildElementInTreeVisible(parentName, childName, isVisible = true) { await this.isVisible(this.elementTreeItem.locator('[label="' + parentName + '"]').locator('uui-menu-item[label="' + childName + '"]'), isVisible); } async removeElementPicker(elementPickerName) { const elementPickerLocator = this.entityItem.filter({ has: this.page.locator(`[name="${elementPickerName}"]`) }); await this.hoverAndClick(elementPickerLocator, elementPickerLocator.getByLabel('Remove')); await this.clickConfirmRemoveButton(); } // Dropdown async chooseDropdownOption(optionValues) { await this.selectMultiple(this.dropdown, optionValues); } // Date Picker async enterADate(date) { await this.setADateTxt.fill(date); } // Media Picker async clickChooseMediaPickerButton() { await this.click(this.chooseMediaPickerBtn); } async clickChooseButtonAndSelectMediaWithName(mediaName) { await this.clickChooseMediaPickerButton(); await this.selectMediaWithName(mediaName); } async clickChooseButtonAndSelectMediaWithKey(mediaKey) { await this.clickChooseMediaPickerButton(); await this.selectMediaWithTestId(mediaKey); } async removeMediaPickerByName(mediaPickerName) { await this.click(this.page.locator(`[name="${mediaPickerName}"] [label="Remove"] svg`)); await this.clickConfirmRemoveButton(); } async isMediaNameVisible(mediaName, isVisible = true) { return await this.isVisible(this.mediaCardItems.filter({ hasText: mediaName }), isVisible); } async clickResetFocalPointButton() { await this.click(this.resetFocalPointBtn); } async setFocalPoint(widthPercentage = 50, heightPercentage = 50) { await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.medium); const element = await this.page.locator('#image').boundingBox(); if (!element) { throw new Error('Element not found'); } const centerX = element.x + element.width / 2; const centerY = element.y + element.height / 2; const x = element.x + (element.width * widthPercentage) / 100; const y = element.y + (element.height * heightPercentage) / 100; await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.minimal); await this.page.mouse.move(centerX, centerY, { steps: 5 }); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.minimal); await this.page.mouse.down(); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.minimal); await this.page.mouse.move(x, y); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.minimal); await this.page.mouse.up(); } // Member Picker async clickChooseMemberPickerButton() { await this.click(this.chooseMemberPickerBtn); } async selectMemberByName(memberName) { await this.click(this.sidebarModal.getByText(memberName, { exact: true })); } async removeMemberPickerByName(memberName) { const mediaPickerLocator = this.entityItem.filter({ has: this.page.locator(`[name="${memberName}"]`) }); await this.hoverAndClick(mediaPickerLocator, mediaPickerLocator.getByLabel('Remove')); await this.clickConfirmRemoveButton(); } // Numeric async enterNumeric(number) { await this.enterText(this.numericTxt, number.toString()); } // Radiobox async chooseRadioboxOption(optionValue) { await this.click(this.page.locator(`uui-radio[value="${optionValue}"] #button`)); } // Tags async clickPlusIconButton() { await this.click(this.plusIconBtn); } async enterTag(tagName) { await this.enterText(this.enterTagTxt, tagName); await this.pressKey(this.enterTagTxt, 'Enter'); } async removeTagByName(tagName) { await this.click(this.tagItems.filter({ hasText: tagName }).locator('svg')); } // Multi URL Picker async clickAddMultiURLPickerButton() { await this.click(this.addMultiURLPickerBtn); } async selectLinkByName(linkName) { await this.click(this.sidebarModal.getByText(linkName, { exact: true })); } async enterLink(value, toPress = false) { if (toPress) { await this.enterText(this.linkTxt, ''); await this.pressKey(this.linkTxt, value); } else { await this.enterText(this.linkTxt, value); } } async enterAnchorOrQuerystring(value, toPress = false) { if (toPress) { await this.enterText(this.anchorQuerystringTxt, ''); await this.pressKey(this.anchorQuerystringTxt, value); } else { await this.enterText(this.anchorQuerystringTxt, value); } } async enterLinkTitle(value, toPress = false) { if (toPress) { await this.enterText(this.linkTitleTxt, ''); await this.pressKey(this.linkTitleTxt, value); } else { await this.enterText(this.linkTitleTxt, value); } } async removeUrlPickerByName(linkName) { await this.click(this.page.locator(`[name="${linkName}"]`).getByLabel('Remove')); await this.clickConfirmRemoveButton(); } async clickEditUrlPickerButtonByName(linkName) { await this.click(this.page.locator(`[name="${linkName}"]`).getByLabel('Edit')); } // Upload async clickRemoveFilesButton() { await this.click(this.removeFilesBtn); } // True/false async clickToggleButton() { await this.click(this.toggleBtn, { force: true }); } async doesToggleHaveLabel(label) { await this.hasText(this.toggleInput, label); } // Multiple Text String async clickAddMultipleTextStringButton() { await this.click(this.addMultipleTextStringBtn); } async enterMultipleTextStringValue(value) { await this.enterText(this.multipleTextStringValueTxt, value); } async addMultipleTextStringItem(value) { await this.clickAddMultipleTextStringButton(); await this.enterMultipleTextStringValue(value); } // Code Editor async enterCodeEditorValue(value) { await this.enterMonacoEditorValue(value); } // Markdown Editor async enterMarkdownEditorValue(value) { await this.enterMonacoEditorValue(value); } // Slider async changeSliderValue(value) { await this.sliderInput.fill(value); } async isElementTypeNameVisible(elementName, isVisible = true) { return await this.isVisible(this.sidebarModal.getByText(elementName), isVisible); } async doesModalHaveText(text) { await this.containsText(this.openedModal, text); } // Collection tab async isTabNameVisible(tabName) { return await this.isVisible(this.tabItems.filter({ hasText: tabName })); } async clickTabWithName(tabName) { const tabLocator = this.tabItems.filter({ hasText: tabName }); await this.click(tabLocator); } async doesElementHaveName(name) { await this.hasValue(this.enterAName, name); } async doesElementTableColumnNameValuesMatch(expectedValues) { await this.waitForVisible(this.elementElementCollectionView); return expectedValues.forEach((text, index) => { (0, test_1.expect)(this.elementTableColumnName.nth(index).getByLabel(text)).toBeVisible(); }); } async clickSelectVariantButton() { await this.click(this.selectAVariantBtn); } async clickExpendSegmentButton(elementName) { await this.page.locator('.variant.culture-variant').filter({ hasText: elementName }).locator(this.expandSegmentBtn).click(); } async clickVariantAddModeButtonForLanguageName(language) { await this.click(this.variantAddModeBtn.getByText(language)); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async clickSaveAndCloseButton() { await this.click(this.saveAndCloseBtn); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } // List View async clickCreateElementWithName(name) { await this.click(this.page.getByLabel(`Create ${name}`)); await this.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async enterNameInContainer(name) { await this.enterText(this.enterNameInContainerTxt, name); } async goToElementInElementCollectionViewWithName(elementName) { await this.click(this.elementCollectionView.getByLabel(elementName)); } async doesElementCollectionViewHaveNoItemsInList() { await this.isVisible(this.elementCollectionView.filter({ hasText: 'There are no items to show in the list.' })); } async doesElementListHaveNoItemsInList() { await this.isVisible(this.umbElementCollection.filter({ hasText: 'No items' })); } async clickNameButtonInElementCollectionView() { await this.click(this.nameBtn); } async doesFirstItemInElementCollectionViewHaveName(name) { await (0, test_1.expect)(this.elementCollectionViewTableRow.first()).toContainText(name); } async doesElementCollectionViewContainCount(count) { await this.hasCount(this.elementCollectionViewTableRow, count); } async selectElementWithNameInElementCollectionView(name) { await this.click(this.elementCollectionViewTableRow.filter({ hasText: name })); } async clickPublishSelectedListItems() { await this.click(this.publishSelectedListItems); } async clickUnpublishSelectedListItems() { await this.click(this.unpublishSelectedListItems); } async clickDuplicateToSelectedListItems() { // Force click is needed await this.click(this.duplicateToSelectedListItems, { force: true }); } async clickMoveToSelectedListItems() { // Force click is needed await this.click(this.moveToSelectedListItems, { force: true }); } async clickTrashSelectedListItems() { await this.click(this.trashSelectedListItems); } async selectElementWithNameAtRoot(name) { await this.openCaretButtonForName('Element'); await this.click(this.modalElement.getByLabel(name)); await this.clickChooseButton(); } async clickTrashButton() { await this.click(this.trashBtn); } async clickExactTrashButton() { await this.click(this.exactTrashBtn); } async isElementElementCollectionViewVisible(isVisible = true) { await this.isVisible(this.elementElementCollectionView, isVisible); } async isElementFolderCollectionViewVisible(isVisible = true) { await this.isVisible(this.elementFolderCollectionView, isVisible, ConstantHelper_1.ConstantHelper.timeout.long); } async isElementGridViewVisible(isVisible = true) { await this.isVisible(this.elementGridView, isVisible); } async changeElementSectionLanguage(newLanguageName) { await this.click(this.elementLanguageSelect); // Force click is needed await this.click(this.elementLanguageSelectPopover.getByText(newLanguageName), { force: true }); } async doesElementSectionHaveLanguageSelected(languageName) { await this.hasText(this.elementLanguageSelect, languageName); } async isElementReadOnly(isVisible = true) { await this.isVisible(this.elementReadOnly, isVisible); } async isElementNameInputEditable(isEditable = true) { await this.waitForVisible(this.elementNameTxt); await (0, test_1.expect)(this.elementNameTxt).toBeEditable({ editable: isEditable }); } async isActionsMenuForRecycleBinVisible(isVisible = true) { await this.isActionsMenuForNameVisible('Recycle Bin', isVisible); } async isActionsMenuForRootVisible(isVisible = true) { await this.isActionsMenuForNameVisible('Element', isVisible); } async clickEmptyRecycleBinButton() { await this.hoverAndClick(this.recycleBinMenuItem, this.emptyRecycleBinBtn, { force: true }); } async clickConfirmEmptyRecycleBinButton() { await this.click(this.confirmEmptyRecycleBinBtn); } async isElementPropertyEditable(propertyName, isEditable = true) { const propertyLocator = this.elementWorkspace.locator(this.property).filter({ hasText: propertyName }).locator('#input'); await this.waitForVisible(propertyLocator); await (0, test_1.expect)(propertyLocator).toBeEditable({ editable: isEditable }); } async doesElementPropertyHaveValue(propertyName, value) { const propertyLocator = this.elementWorkspace.locator(this.property).filter({ hasText: propertyName }).locator('#input'); await this.hasValue(propertyLocator, value); } async clickContentTab() { await this.click(this.splitView.getByRole('tab', { name: 'Content' })); } async isElementTreeEmpty() { await this.hasCount(this.elementTreeItem, 0); } async doesElementWorkspaceContainName(name) { await (0, test_1.expect)(this.elementWorkspaceEditor.locator('#input')).toHaveValue(name); } async doesElementWorkspaceHaveText(text) { await this.containsText(this.elementWorkspace, text); } async clickDuplicateToButton() { await this.click(this.duplicateToBtn); } async clickDuplicateButton() { await this.click(this.duplicateBtn); } async clickMoveToButton() { await this.click(this.moveToBtn); } async moveToElementWithName(parentNames, moveTo) { for (const elementName of parentNames) { await this.click(this.container.getByLabel(`Expand child items for ${elementName}`)); } await this.click(this.container.getByLabel(moveTo)); await this.clickChooseContainerButton(); } async isCaretButtonVisibleForElementName(elementName, isVisible = true) { await this.isVisible(this.page.locator(`[label="${elementName}"]`).getByLabel('Expand child items for '), isVisible); } async reloadElementTree() { // Force click is needed await this.click(this.elementTreeRefreshBtn, { force: true }); } async clickSortChildrenButton() { await this.click(this.sortChildrenBtn); } async clickRollbackButton() { await this.click(this.rollbackBtn); } async clickRollbackContainerButton() { await this.click(this.rollbackContainerBtn); } async clickLatestRollBackItem() { await this.click(this.rollbackItem.last()); } async clickPublicAccessButton() { await this.click(this.publicAccessBtn); } async addGroupBasedPublicAccess(memberGroupName, elementName) { await this.click(this.groupBasedProtectionBtn); await this.clickNextButton(); await this.click(this.chooseMemberGroupBtn); await this.click(this.page.getByLabel(memberGroupName)); await this.clickChooseModalButton(); await this.click(this.selectLoginPageElement); await this.click(this.container.getByLabel(elementName, { exact: true })); await this.clickChooseModalButton(); await this.click(this.selectErrorPageElement); await this.click(this.container.getByLabel(elementName, { exact: true })); await this.clickChooseModalButton(); await this.click(this.containerSaveBtn); } async sortChildrenDragAndDrop(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); // If we do not have this, the drag and drop will not work await this.hover(dragToSelector); await this.page.mouse.up(); } async clickSortButton() { await this.click(this.sortBtn); } async doesIndexElementInTreeContainName(parentName, childName, index) { await (0, test_1.expect)(this.elementTreeItem.locator(`[label="${parentName}"]`).locator('umb-tree-item').nth(index).locator('#label')).toHaveText(childName); } async selectMemberGroup(memberGroupName) { await this.click(this.uuiCheckbox.getByLabel(memberGroupName)); } async isPermissionInActionsMenuVisible(permissionName, isVisible = true) { await this.isVisible(this.actionsMenu.getByRole('button', { name: permissionName, exact: true }), isVisible); } async clickElementLinkButton() { await this.click(this.linkToElementBtn); } async clickMediaLinkButton() { await this.click(this.linkToMediaBtn); } async clickManualLinkButton() { await this.click(this.linkToManualBtn); } // Block Grid - Block List async clickAddBlockElementButton() { await this.click(this.addBlockElementBtn); } async clickAddBlockWithNameButton(name) { await this.click(this.page.getByLabel(`Add ${name}`)); } async clickCreateInModal(headline, options) { const