UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

1,032 lines 82.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ContentUiHelper = void 0; const test_1 = require("@playwright/test"); const UiBaseLocators_1 = require("./UiBaseLocators"); const ConstantHelper_1 = require("./ConstantHelper"); class ContentUiHelper extends UiBaseLocators_1.UiBaseLocators { contentNameTxt; saveAndPublishBtn; publishBtn; unpublishBtn; actionMenuForContentBtn; textstringTxt; infoTab; linkContent; historyItems; generalItem; documentState; createdDate; editDocumentTypeBtn; addTemplateBtn; id; cultureAndHostnamesBtn; cultureLanguageDropdownBox; addNewHostnameBtn; hostnameTxt; hostnameLanguageDropdownBox; deleteHostnameBtn; reloadChildrenThreeDotsBtn; contentTree; richTextAreaTxt; textAreaTxt; plusIconBtn; enterTagTxt; menuItemTree; hostnameComboBox; confirmToUnpublishBtn; saveModalBtn; dropdown; setADateTxt; chooseMediaPickerBtn; chooseMemberPickerBtn; numericTxt; resetFocalPointBtn; addMultiURLPickerBtn; linkTxt; anchorQuerystringTxt; linkTitleTxt; tagItems; removeFilesBtn; toggleBtn; toggleInput; documentTypeWorkspace; addMultipleTextStringBtn; multipleTextStringValueTxt; sliderInput; tabItems; documentWorkspace; searchTxt; selectAVariantBtn; variantAddModeBtn; saveAndCloseBtn; enterNameInContainerTxt; listView; nameBtn; listViewTableRow; publishSelectedListItems; unpublishSelectedListItems; duplicateToSelectedListItems; moveToSelectedListItems; trashSelectedListItems; modalContent; trashBtn; documentListView; documentGridView; documentTreeItem; documentLanguageSelect; documentLanguageSelectPopover; documentReadOnly; documentWorkspaceEditor; documentBlueprintModal; documentBlueprintModalEnterNameTxt; documentBlueprintSaveBtn; documentNotificationsModal; documentNotificationsSaveBtn; exactTrashBtn; emptyRecycleBinBtn; confirmEmptyRecycleBinBtn; duplicateToBtn; moveToBtn; duplicateBtn; contentTreeRefreshBtn; sortChildrenBtn; rollbackBtn; rollbackContainerBtn; publicAccessBtn; uuiCheckbox; sortBtn; containerSaveBtn; groupBasedProtectionBtn; chooseMemberGroupBtn; selectLoginPageDocument; selectErrorPageDocument; rollbackItem; actionsMenu; linkToDocumentBtn; linkToMediaBtn; linkToManualBtn; umbDocumentCollection; documentTableColumnName; 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; saveContentBtn; splitView; tiptapInput; rteBlockInline; backofficeModalContainer; modalCreateBtn; modalUpdateBtn; rteBlock; workspaceActionMenu; workspaceActionMenuItem; viewMoreOptionsBtn; schedulePublishBtn; schedulePublishModalBtn; documentScheduleModal; publishAtFormLayout; unpublishAtFormLayout; publishAtValidationMessage; unpublishAtValidationMessage; lastPublished; publishAt; blockGridAreasContainer; blockGridBlock; blockGridEntries; inlineCreateBtn; removeAt; selectAllCheckbox; confirmToPublishBtn; tiptapStatusbarWordCount; tiptapStatusbarElementPath; publishWithDescendantsBtn; documentPublishWithDescendantsModal; includeUnpublishedDescendantsToggle; publishWithDescendantsModalBtn; documentVariantLanguagePicker; documentVariantLanguageItem; styleSelectBtn; cascadingMenuContainer; modalFormValidationMessage; treePickerSearchTxt; mediaPickerSearchTxt; memberPickerSearchTxt; documentCreateOptionsModal; refListBlock; propertyActionMenu; listViewCustomRows; collectionMenu; entityPickerTree; hostNameItem; languageToggle; contentVariantDropdown; blockProperty; linkPickerAddBtn; linkPickerCloseBtn; linkPickerTargetToggle; confirmToResetBtn; saveModal; expandSegmentBtn; constructor(page) { super(page); this.saveContentBtn = page.getByTestId('workspace-action:Umb.WorkspaceAction.Document.Save'); this.saveAndPublishBtn = page.getByTestId('workspace-action:Umb.WorkspaceAction.Document.SaveAndPublish'); this.closeBtn = page.getByRole('button', { name: 'Close', exact: true }); this.linkPickerModal = page.locator('umb-link-picker-modal'); this.contentNameTxt = page.locator('#name-input input'); this.publishBtn = page.getByLabel(/^Publish(…)?$/); this.unpublishBtn = page.getByLabel(/^Unpublish(…)?$/); this.actionMenuForContentBtn = 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.contentTree = page.locator('umb-tree[alias="Umb.Tree.Document"]'); 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 = page.locator('umb-document-unpublish-modal').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.documentTypeWorkspace = this.sidebarModal.locator('umb-document-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.documentWorkspace = page.locator('umb-document-workspace-editor'); this.searchTxt = this.documentWorkspace.getByLabel('Search', { exact: true }); 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.documentTreeItem = page.locator('umb-document-tree-item'); this.documentLanguageSelect = page.locator('umb-app-language-select'); this.documentLanguageSelectPopover = page.locator('umb-popover-layout'); this.documentReadOnly = this.documentWorkspace.locator('#name-input').getByText('Read-only'); // Info tab this.infoTab = page.getByTestId('workspace:view-link:Umb.WorkspaceView.Document.Info'); this.linkContent = page.locator('umb-document-links-workspace-info-app'); this.historyItems = page.locator('umb-history-item'); this.generalItem = page.locator('.general-item'); this.documentState = this.generalItem.locator('uui-tag'); this.createdDate = this.generalItem.filter({ hasText: 'Created' }).locator('umb-localize-date'); this.editDocumentTypeBtn = this.generalItem.filter({ hasText: 'Document Type' }).locator('#button'); this.addTemplateBtn = this.generalItem.filter({ hasText: 'Template' }).locator('#button'); this.id = this.generalItem.filter({ hasText: 'Id' }).locator('span'); this.documentCreateOptionsModal = page.locator('umb-document-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-document-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.listView = page.locator('umb-document-table-collection-view'); this.nameBtn = page.getByRole('button', { name: 'Name', exact: true }); this.listViewTableRow = this.listView.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.modalContent = page.locator('umb-tree-picker-modal'); this.trashBtn = page.getByLabel(/^Trash(…)?$/); this.exactTrashBtn = page.getByRole('button', { name: 'Trash', exact: true }); this.documentListView = page.locator('umb-document-table-collection-view'); this.documentGridView = page.locator('umb-document-grid-collection-view'); this.documentWorkspaceEditor = page.locator('umb-workspace-editor'); this.documentBlueprintModal = page.locator('umb-create-blueprint-modal'); this.documentBlueprintModalEnterNameTxt = this.documentBlueprintModal.locator('input'); this.documentBlueprintSaveBtn = this.documentBlueprintModal.getByLabel('Save'); this.documentNotificationsModal = page.locator('umb-document-notifications-modal'); this.documentNotificationsSaveBtn = this.documentNotificationsModal.getByLabel('Save', { exact: true }); this.emptyRecycleBinBtn = page.getByTestId('entity-action:Umb.EntityAction.Document.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.contentTreeRefreshBtn = 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.selectLoginPageDocument = page.locator('.select-item').filter({ hasText: 'Login Page' }).locator('umb-input-document'); this.selectErrorPageDocument = page.locator('.select-item').filter({ hasText: 'Error Page' }).locator('umb-input-document'); this.rollbackItem = page.locator('.rollback-item'); this.actionsMenu = page.locator('uui-scroll-container'); this.linkToDocumentBtn = this.linkPickerModal.getByTestId('action:document').locator('#button'); this.linkToMediaBtn = this.linkPickerModal.getByTestId('action:media').locator('#button'); this.linkToManualBtn = this.linkPickerModal.getByTestId('action:external').locator('#button'); this.umbDocumentCollection = page.locator('umb-document-collection'); this.documentTableColumnName = this.listView.locator('umb-document-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-content-workspace-view-edit-tab'); this.blockWorkspaceEditTab = page.locator('umb-block-workspace-view-edit-tab'); this.workspaceEditProperties = page.locator('umb-content-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.backofficeModalContainer = page.locator('umb-backoffice-modal-container'); 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.documentScheduleModal = page.locator('umb-document-schedule-modal'); this.schedulePublishModalBtn = this.documentScheduleModal.getByLabel('Schedule publish', { exact: true }); this.publishAtFormLayout = this.documentScheduleModal.locator('uui-form-layout-item').first(); this.unpublishAtFormLayout = this.documentScheduleModal.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 = this.documentScheduleModal.locator('[label="Select all"]'); this.confirmToPublishBtn = page.locator('umb-document-publish-modal').getByLabel('Publish'); // Publish with descendants this.documentPublishWithDescendantsModal = page.locator('umb-document-publish-with-descendants-modal'); this.publishWithDescendantsBtn = this.workspaceActionMenuItem.getByLabel('Publish with descendants', { exact: true }); this.includeUnpublishedDescendantsToggle = this.documentPublishWithDescendantsModal.locator('#includeUnpublishedDescendants'); this.publishWithDescendantsModalBtn = this.documentPublishWithDescendantsModal.getByLabel('Publish with descendants', { exact: true }); this.documentVariantLanguagePicker = page.locator('umb-document-variant-language-picker'); this.documentVariantLanguageItem = this.documentVariantLanguagePicker.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.listViewCustomRows = 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.contentVariantDropdown = page.locator('umb-document-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'); } async enterContentName(name) { await this.enterText(this.contentNameTxt, 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.actionMenuForContentBtn, { force: true }); } async goToContentWithName(contentName) { const contentWithNameLocator = this.menuItemTree.getByText(contentName, { exact: true }); await this.click(contentWithNameLocator, { timeout: ConstantHelper_1.ConstantHelper.timeout.long }); } async clickActionsMenuForContent(name) { await this.clickActionsMenuForName(name); } async openContentCaretButtonForName(name) { const menuItem = this.menuItemTree.filter({ hasText: name }).last(); const isCaretButtonOpen = await menuItem.getAttribute('show-children'); if (isCaretButtonOpen === null) { await this.clickCaretButtonForContentName(name); } } async clickCaretButtonForContentName(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 clickSaveButtonForContent() { await this.click(this.saveContentBtn); 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 doesContentTreeHaveName(contentName) { await this.containsText(this.contentTree, contentName); } 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); } async clickCreateDocumentBlueprintButton() { await this.click(this.createDocumentBlueprintBtn); } // Info Tab async clickInfoTab() { await this.click(this.infoTab); } async doesDocumentHaveLink(link) { await this.containsText(this.linkContent, link); } async doesHistoryHaveText(text) { await this.hasText(this.historyItems, text); } async doesDocumentStateHaveText(text) { await this.hasText(this.documentState, text); } async doesCreatedDateHaveText(text) { await this.hasText(this.createdDate, text); } async doesIdHaveText(text) { await this.hasText(this.id, text); } async clickEditDocumentTypeButton() { await this.click(this.editDocumentTypeBtn); } async clickAddTemplateButton() { await this.click(this.addTemplateBtn); } async clickSaveButtonAndWaitForContentToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickSaveButtonForContent(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickSaveModalButtonAndWaitForContentToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickSaveModalButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickSaveModalButtonAndWaitForContentToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickSaveModalButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickSaveAndPublishButtonAndWaitForContentToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickSaveAndPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickConfirmToPublishButtonAndWaitForContentToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickConfirmToPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickSaveButtonAndWaitForContentToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickSaveButtonForContent(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickSaveAndPublishButtonAndWaitForContentToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickSaveAndPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickSaveAndPublishButtonAndWaitForContentToBePublished() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickSaveAndPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickContainerSaveButton() { await this.click(this.containerSaveBtn); } async clickContainerSaveButtonAndWaitForContentToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickContainerSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickContainerSaveAndPublishButtonAndWaitForContentToBePublished() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.document, this.clickContainerSaveAndPublishButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickDocumentTypeByName(documentTypeName) { await this.click(this.page.locator(`uui-ref-node-document-type[name="${documentTypeName}"]`)); } async clickTemplateByName(templateName) { await this.click(this.page.locator(`uui-ref-node[name="${templateName}"]`)); } async isDocumentTypeModalVisible(documentTypeName) { await this.isVisible(this.documentTypeWorkspace.filter({ hasText: documentTypeName })); } 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 chooseDocumentType(documentTypeName) { await this.click(this.documentTypeNode.filter({ hasText: documentTypeName })); } // 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`)); } // Content Picker async addContentPicker(contentName) { await this.clickChooseButton(); await this.click(this.sidebarModal.getByText(contentName)); await this.click(this.chooseModalBtn); } async isOpenButtonVisibleInContentPicker(contentPickerName, isVisible = true) { return await this.isVisible(this.page.getByLabel('Open ' + contentPickerName), isVisible); } async clickContentPickerOpenButton(contentPickerName) { await this.click(this.page.getByLabel('Open ' + contentPickerName)); } async isNodeOpenForContentPicker(contentPickerName) { return await this.isVisible(this.openedModal.getByText(contentPickerName)); } async isContentNameVisible(contentName, isVisible = true) { return await this.isVisible(this.sidebarModal.getByText(contentName), isVisible); } async isContentInTreeVisible(name, isVisible = true) { await this.isVisible(this.documentTreeItem.getByLabel(name, { exact: true }).first(), isVisible); } async isChildContentInTreeVisible(parentName, childName, isVisible = true) { await this.isVisible(this.documentTreeItem.locator('[label="' + parentName + '"]').locator('uui-menu-item[label="' + childName + '"]'), isVisible); } async removeContentPicker(contentPickerName) { const contentPickerLocator = this.entityItem.filter({ has: this.page.locator(`[name="${contentPickerName}"]`) }); await this.hoverAndClick(contentPickerLocator, contentPickerLocator.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 isDocumentTypeNameVisible(contentName, isVisible = true) { return await this.isVisible(this.sidebarModal.getByText(contentName), 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 doesDocumentHaveName(name) { await this.hasValue(this.enterAName, name); } async doesDocumentTableColumnNameValuesMatch(expectedValues) { await this.waitForVisible(this.documentListView); return expectedValues.forEach((text, index) => { (0, test_1.expect)(this.documentTableColumnName.nth(index)).toHaveText(text); }); } async searchByKeywordInCollection(keyword) { await this.enterText(this.searchTxt, keyword); await this.pressKey(this.searchTxt, 'Enter'); await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async clickSelectVariantButton() { await this.click(this.selectAVariantBtn); } async clickExpendSegmentButton(contentName) { await this.page.locator('.variant.culture-variant').filter({ hasText: contentName }).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 clickCreateContentWithName(name) { await this.click(this.page.getByLabel(`Create ${name}`)); } async enterNameInContainer(name) { await this.enterText(this.enterNameInContainerTxt, name); } async goToContentInListViewWithName(contentName) { await this.click(this.listView.getByLabel(contentName)); } async doesListViewHaveNoItemsInList() { await this.isVisible(this.listView.filter({ hasText: 'There are no items to show in the list.' })); } async doesContentListHaveNoItemsInList() { await this.isVisible(this.umbDocumentCollection.filter({ hasText: 'No items' })); } async clickNameButtonInListView() { await this.click(this.nameBtn); } async doesFirstItemInListViewHaveName(name) { await (0, test_1.expect)(this.listViewTableRow.first()).toContainText(name); } async doesListViewContainCount(count) { await this.hasCount(this.listViewTableRow, count); } async selectContentWithNameInListView(name) { await this.click(this.listViewTableRow.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 selectDocumentWithNameAtRoot(name) { await this.openCaretButtonForName('Content'); await this.click(this.modalContent.getByLabel(name)); await this.clickChooseButton(); } async clickTrashButton() { await this.click(this.trashBtn); } async clickExactTrashButton() { await this.click(this.exactTrashBtn); } async isDocumentListViewVisible(isVisible = true) { await this.isVisible(this.documentListView, isVisible); } async isDocumentGridViewVisible(isVisible = true) { await this.isVisible(this.documentGridView, isVisible); } async changeDocumentSectionLanguage(newLanguageName) { await this.click(this.documentLanguageSelect); // Force click is needed await this.click(this.documentLanguageSelectPopover.getByText(newLanguageName), { force: true }); } async doesDocumentSectionHaveLanguageSelected(languageName) { await this.hasText(this.documentLanguageSelect, languageName); } async isDocumentReadOnly(isVisible = true) { await this.isVisible(this.documentReadOnly, isVisible); } async isDocumentNameInputEditable(isEditable = true) { await this.waitForVisible(this.contentNameTxt); await (0, test_1.expect)(this.contentNameTxt).toBeEditable({ editable: isEditable }); } async isActionsMenuForRecycleBinVisible(isVisible = true) { await this.isActionsMenuForNameVisible('Recycle Bin', isVisible); } async isActionsMenuForRootVisible(isVisible = true) { await this.isActionsMenuForNameVisible('Content', isVisible); } async clickEmptyRecycleBinButton() { await this.hover(this.recycleBinMenuItem); // Force click is needed await this.click(this.emptyRecycleBinBtn, { force: true }); } async clickConfirmEmptyRecycleBinButton() { await this.click(this.confirmEmptyRecycleBinBtn); } async isDocumentPropertyEditable(propertyName, isEditable = true) { const propertyLocator = this.documentWorkspace.locator(this.property).filter({ hasText: propertyName }).locator('#input'); await this.waitForVisible(propertyLocator); await (0, test_1.expect)(propertyLocator).toBeEditable({ editable: isEditable }); } async doesDocumentPropertyHaveValue(propertyName, value) { const propertyLocator = this.documentWorkspace.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 isDocumentTreeEmpty() { await this.hasCount(this.documentTreeItem, 0); } async doesDocumentWorkspaceContainName(name) { await (0, test_1.expect)(this.documentWorkspaceEditor.locator('#input')).toHaveValue(name); } async doesDocumentWorkspaceHaveText(text) { await this.containsText(this.documentWorkspace, text); } async enterDocumentBlueprintName(name) { await this.enterText(this.documentBlueprintModalEnterNameTxt, name); } async clickSaveDocumentBlueprintButton() { await this.click(this.documentBlueprintSaveBtn); } async clickDuplicateToButton() { await this.click(this.duplicateToBtn); } async clickDuplicateButton() { await this.click(this.duplicateBtn); } async clickMoveToButton() { await this.click(this.moveToBtn); } async moveToContentWithName(parentNames, moveTo) { for (const contentName of parentNames) { await this.click(this.container.getByLabel(`Expand child items for ${contentName}`)); } await this.click(this.container.getByLabel(moveTo)); await this.clickChooseContainerButton(); } async isCaretButtonVisibleForContentName(contentName, isVisible = true) { await this.isVisible(this.page.locator(`[label="${contentName}"]`).getByLabel('Expand child items for '), isVisible); } async reloadContentTree() { // Force click is needed await this.click(this.contentTreeRefreshBtn, { 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, documentName) { 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.selectLoginPageDocument); await this.click(this.container.getByLabel(documentName, { exact: true })); await this.clickChooseModalButton(); await this.click(this.selectErrorPageDocument); await this.click(this.container.getByLabel(documentName, { 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 doesIndexDocumentInTreeContainName(parentName, childName, index) { await (0, test_1.expect)(this.documentTreeItem.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 clickDocumentLinkButton() { await this.click(this.linkToDocumentBtn); } 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(na