@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
75 lines • 4.13 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MediaTypeUiHelper = void 0;
const UiBaseLocators_1 = require("./UiBaseLocators");
const ConstantHelper_1 = require("./ConstantHelper");
class MediaTypeUiHelper extends UiBaseLocators_1.UiBaseLocators {
newMediaTypeThreeDotsBtn;
mediaEditPropertyWorkspace;
mediaTypeBtn;
mediaTypesMenu;
mediaTypeTreeRoot;
constructor(page) {
super(page);
this.newMediaTypeThreeDotsBtn = page.getByLabel('New Media Type…');
this.mediaEditPropertyWorkspace = page.locator('umb-media-type-workspace-view-edit-property');
this.mediaTypeBtn = this.createOptionActionListModal.locator('[name="Media Type"]');
this.mediaTypesMenu = page.locator('#menu-item').getByRole('link', { name: 'Media Types' });
this.mediaTypeTreeRoot = page.locator('[alias="Umb.TreeItem.MediaType"]').locator('uui-menu-item[label="Media Types"]');
}
async clickActionsMenuForMediaType(name) {
await this.clickActionsMenuForName(name);
}
async clickActionsMenuAtRoot() {
await this.clickActionsMenuForMediaType("Media Types");
}
async clickRootFolderCaretButton() {
await this.openCaretButtonForName("Media Types");
}
async clickNewMediaTypeButton() {
await this.click(this.newMediaTypeThreeDotsBtn);
}
async isMediaTypeTreeItemVisible(name, isVisible = true) {
const hasShowChildren = await this.mediaTypeTreeRoot.getAttribute('show-children') !== null;
if (!hasShowChildren) {
await this.click(this.mediaTypeTreeRoot.locator(this.caretBtn).first());
}
await this.isTreeItemVisible(name, isVisible);
}
async goToMediaType(mediaTypeName) {
await this.clickRootFolderCaretButton();
await this.clickLabelWithName(mediaTypeName);
}
async enterMediaTypeName(name) {
await this.enterText(this.enterAName, name);
}
async enterDescriptionForPropertyEditorWithName(propertyEditorName, description) {
await this.mediaEditPropertyWorkspace.filter({ hasText: propertyEditorName }).getByLabel('description').fill(description);
}
async clickMediaTypeButton() {
await this.click(this.mediaTypeBtn);
}
async clickMediaTypesMenu() {
await this.click(this.mediaTypesMenu);
}
async clickSaveButtonAndWaitForMediaTypeToBeCreated() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.mediaType, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.created);
}
async clickSaveButtonAndWaitForMediaTypeToBeUpdated() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.mediaType, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok);
}
async clickConfirmToDeleteButtonAndWaitForMediaTypeToBeDeleted() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.mediaType, this.clickConfirmToDeleteButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok);
}
async clickDeleteAndConfirmButtonAndWaitForMediaTypeToBeDeleted() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.mediaType, this.clickDeleteAndConfirmButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok);
}
async clickConfirmCreateFolderButtonAndWaitForMediaTypeToBeCreated() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.mediaTypeFolder, this.clickConfirmCreateFolderButton(), ConstantHelper_1.ConstantHelper.statusCodes.created);
}
async clickConfirmRenameButtonAndWaitForMediaTypeToBeRenamed() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.mediaTypeFolder, this.clickConfirmRenameButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok);
}
}
exports.MediaTypeUiHelper = MediaTypeUiHelper;
//# sourceMappingURL=MediaTypeUiHelper.js.map