@umbraco/playwright-testhelpers
Version:
Test helpers for making playwright tests for Umbraco solutions
82 lines • 3.71 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebhookUiHelper = void 0;
const UiBaseLocators_1 = require("./UiBaseLocators");
const ConstantHelper_1 = require("./ConstantHelper");
class WebhookUiHelper extends UiBaseLocators_1.UiBaseLocators {
webhookCreateBtn;
webhookNameTxt;
urlTxt;
chooseEventBtn;
chooseContentTypeBtn;
enabledToggle;
addHeadersBtn;
headerNameTxt;
headerValueTxt;
deleteWebhookEntityAction;
headerRemoveBtn;
constructor(page) {
super(page);
this.webhookCreateBtn = page.getByTestId('collection-action:Umb.CollectionAction.Webhook.Create');
this.webhookNameTxt = page.locator('#name #input');
this.urlTxt = page.locator('umb-property-layout[label="URL"] #input');
this.chooseEventBtn = page.locator('umb-property-layout[label="Events"]').getByLabel('Choose');
this.chooseContentTypeBtn = page.locator('umb-property-layout[label="Content Type"]').getByLabel('Choose');
this.enabledToggle = page.locator('umb-property-layout[label="Enabled"] #toggle');
this.addHeadersBtn = page.locator('umb-property-layout[label="Headers"] #add');
this.headerNameTxt = page.locator('umb-input-webhook-headers').locator('[list="nameList"]');
this.headerValueTxt = page.locator('umb-input-webhook-headers').locator('[list="valueList"]');
this.deleteWebhookEntityAction = page.getByTestId('entity-action:Umb.EntityAction.Webhook.Delete');
this.headerRemoveBtn = page.locator('umb-input-webhook-headers').locator('[label="Remove"]');
}
async goToWebhooks() {
await this.goToSection(ConstantHelper_1.ConstantHelper.sections.settings);
await this.goToSettingsTreeItem('Webhooks');
}
async goToWebhookWithName(name) {
await this.goToWebhooks();
await this.clickTextButtonWithName(name);
}
async clickWebhookCreateButton() {
await this.click(this.webhookCreateBtn);
}
async enterWebhookName(name) {
await this.enterText(this.webhookNameTxt, name);
}
async enterUrl(url) {
await this.enterText(this.urlTxt, url);
}
async clickChooseEventButton() {
await this.click(this.chooseEventBtn);
}
async clickChooseContentTypeButton() {
await this.click(this.chooseContentTypeBtn);
}
async clickEnabledToggleButton() {
await this.click(this.enabledToggle);
}
async clickAddHeadersButton() {
await this.click(this.addHeadersBtn);
}
async enterHeaderName(name) {
await this.enterText(this.headerNameTxt, name);
}
async enterHeaderValue(value) {
await this.enterText(this.headerValueTxt, value);
}
async clickDeleteWebhookWithName(name) {
const deleteLocator = this.page.locator('uui-table-row').filter({ has: this.page.getByText(name, { exact: true }) }).locator(this.deleteWebhookEntityAction);
await this.click(deleteLocator);
}
async clickHeaderRemoveButton() {
await this.click(this.headerRemoveBtn);
}
async clickSaveButtonAndWaitForWebhookToBeCreated() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.webhook, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.created);
}
async clickSaveButtonAndWaitForWebhookToBeUpdated() {
return await this.waitForResponseAfterExecutingPromise(ConstantHelper_1.ConstantHelper.apiEndpoints.webhook, this.clickSaveButton(), ConstantHelper_1.ConstantHelper.statusCodes.ok);
}
}
exports.WebhookUiHelper = WebhookUiHelper;
//# sourceMappingURL=WebhookUiHelper.js.map