UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

97 lines 5.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PartialViewUiHelper = void 0; const UiBaseLocators_1 = require("./UiBaseLocators"); const ConstantHelper_1 = require("./ConstantHelper"); class PartialViewUiHelper extends UiBaseLocators_1.UiBaseLocators { newEmptyPartialViewBtn; newPartialViewFromSnippetBtn; partialViewTree; partialViewUiLoader; newFolderThreeDots; partialViewCreateModal; constructor(page) { super(page); this.partialViewCreateModal = page.locator('umb-partial-view-create-options-modal'); this.newEmptyPartialViewBtn = this.partialViewCreateModal.locator('uui-menu-item', { hasText: 'Empty partial view' }); this.newPartialViewFromSnippetBtn = this.partialViewCreateModal.locator('uui-menu-item', { hasText: 'Partial view from snippet' }); this.partialViewTree = page.locator('umb-tree[alias="Umb.Tree.PartialView"]'); this.partialViewUiLoader = page.locator('uui-loader'); this.newFolderThreeDots = this.partialViewCreateModal.locator('uui-menu-item', { hasText: 'Folder' }); } async clickActionsMenuForPartialView(name) { await this.clickActionsMenuForName(name); } async clickActionsMenuAtRoot() { await this.clickActionsMenuForPartialView('Partial Views'); } async clickRootFolderCaretButton() { await this.openCaretButtonForName('Partial Views'); } async clickSaveButtonAndWaitForPartialViewToBeCreated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.partialView, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async clickSaveButtonAndWaitForPartialViewToBeUpdated() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.partialView, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickNewEmptyPartialViewButton() { await this.click(this.newEmptyPartialViewBtn); } async clickNewPartialViewFromSnippetButton() { await this.click(this.newPartialViewFromSnippetBtn); } async enterPartialViewName(partialViewName) { await this.enterText(this.enterAName, partialViewName); await this.hasValue(this.enterAName, partialViewName); } async enterPartialViewContent(partialViewContent) { // The waits in this method is currently needed as the test will fail with expects await this.waitUntilPartialViewLoaderIsNoLongerVisible(); await this.enterMonacoEditorValue(partialViewContent); // We need this wait, to be sure that the partial view content is loaded. await this.page.waitForTimeout(ConstantHelper_1.ConstantHelper.wait.short); } async openPartialViewAtRoot(partialViewName) { await this.reloadPartialViewTree(); await this.click(this.page.locator(`uui-menu-item[label="${partialViewName}"]`)); await this.waitForVisible(this.enterAName); } async createPartialViewFolder(folderName) { await this.clickCreateOptionsActionMenuOption(); await this.click(this.newFolderThreeDots); await this.enterFolderName(folderName); await this.clickConfirmCreateFolderButton(); } async reloadPartialViewTree() { await this.reloadTree('Partial Views'); } async waitUntilPartialViewLoaderIsNoLongerVisible() { await this.isVisible(this.partialViewUiLoader, false); } async isPartialViewRootTreeItemVisible(partialView, isVisible = true, toReload = true) { if (toReload) { await this.reloadPartialViewTree(); } return await this.isVisible(this.partialViewTree.getByText(partialView, { exact: true }), isVisible); } async clickConfirmToDeleteButtonAndWaitForPartialViewToBeDeleted() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.partialView, this.clickConfirmToDeleteButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async clickDeleteAndConfirmButtonAndWaitForPartialViewToBeDeleted() { return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.partialView, this.clickDeleteAndConfirmButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok); } async createPartialViewFolderAndWaitForPartialViewToBeCreated(folderName) { await this.clickCreateOptionsActionMenuOption(); await this.click(this.newFolderThreeDots); await this.enterFolderName(folderName); return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.partialViewFolder, this.clickConfirmCreateFolderButton(), ConstantHelper_1.ConstantHelper.statusCodes.created); } async renameAndWaitForPartialViewToBeRenamed(newName) { await this.clickRenameActionMenuOption(); await this.waitForVisible(this.newNameTxt); await this.enterText(this.newNameTxt, newName); return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.partialView, this.click(this.renameModalBtn), ConstantHelper_1.ConstantHelper.statusCodes.ok); } } exports.PartialViewUiHelper = PartialViewUiHelper; //# sourceMappingURL=PartialViewUiHelper.js.map