@bigbinary/neeto-playwright-commons 1.8.7 → 1.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +78 -2
- package/index.cjs.js.map +1 -1
- package/index.d.ts +49 -3
- package/index.js +77 -3
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.cjs.js
CHANGED
|
@@ -229,11 +229,12 @@ class CustomCommands {
|
|
|
229
229
|
(await this.page.getByTestId(COMMON_SELECTORS.toastCloseButton).click());
|
|
230
230
|
await test.expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toBeHidden();
|
|
231
231
|
};
|
|
232
|
-
this.reloadAndWait = async (requestCount) => {
|
|
232
|
+
this.reloadAndWait = async (requestCount, customPageContext) => {
|
|
233
|
+
const pageContext = customPageContext !== null && customPageContext !== void 0 ? customPageContext : this.page;
|
|
233
234
|
const reloadRequests = this.interceptMultipleResponses({
|
|
234
235
|
times: requestCount,
|
|
235
236
|
});
|
|
236
|
-
await
|
|
237
|
+
await pageContext.reload();
|
|
237
238
|
await reloadRequests;
|
|
238
239
|
};
|
|
239
240
|
this.apiRequest = async ({ url, failOnStatusCode = true, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
|
|
@@ -7189,6 +7190,7 @@ const ROUTES = {
|
|
|
7189
7190
|
profile: "/profile",
|
|
7190
7191
|
myProfile: "/my/profile",
|
|
7191
7192
|
authSettings: "/settings",
|
|
7193
|
+
webhooks: "/webhooks",
|
|
7192
7194
|
login: `${BASE_URL}/login`,
|
|
7193
7195
|
signup: `${BASE_URL}/signups`,
|
|
7194
7196
|
subdomainAvailability: `${BASE_URL}/subdomain_availability`,
|
|
@@ -7209,6 +7211,9 @@ const API_ROUTES = {
|
|
|
7209
7211
|
show: (id) => `/team_members/teams/${id}`,
|
|
7210
7212
|
},
|
|
7211
7213
|
};
|
|
7214
|
+
const THIRD_PARTY_ROUTES = {
|
|
7215
|
+
webhooks: { site: "https://webhook.site/" },
|
|
7216
|
+
};
|
|
7212
7217
|
|
|
7213
7218
|
const CHAT_WIDGET_TEXTS = {
|
|
7214
7219
|
newConversation: "New Conversation",
|
|
@@ -7653,6 +7658,72 @@ class HelpAndProfilePage {
|
|
|
7653
7658
|
}
|
|
7654
7659
|
}
|
|
7655
7660
|
|
|
7661
|
+
const WEBHOOK_SELECTORS = {
|
|
7662
|
+
addNewWebhook: "add-new-webhook-button",
|
|
7663
|
+
endpointInputField: "endpoint-input-field",
|
|
7664
|
+
deliveryResponseCode: "delivery-response-code",
|
|
7665
|
+
deliveryRequestPayload: "delivery-request-payload",
|
|
7666
|
+
};
|
|
7667
|
+
|
|
7668
|
+
class WebhooksPage {
|
|
7669
|
+
constructor({ page, request, neetoPlaywrightUtilities, context, }) {
|
|
7670
|
+
this.getWebhookURL = async () => {
|
|
7671
|
+
const webhookSitePage = await this.context.newPage();
|
|
7672
|
+
await webhookSitePage.goto(THIRD_PARTY_ROUTES.webhooks.site);
|
|
7673
|
+
await webhookSitePage.waitForURL(/.*#!\/\w+/);
|
|
7674
|
+
const webhookToken = webhookSitePage.url().split("#!/")[1];
|
|
7675
|
+
const webhookSiteURL = `${THIRD_PARTY_ROUTES.webhooks.site}${webhookToken}`;
|
|
7676
|
+
await webhookSitePage.close();
|
|
7677
|
+
return { webhookSiteURL, webhookToken };
|
|
7678
|
+
};
|
|
7679
|
+
this.addWebhook = async ({ webhookSiteURL }) => {
|
|
7680
|
+
await this.page.getByTestId(WEBHOOK_SELECTORS.addNewWebhook).click();
|
|
7681
|
+
await this.page
|
|
7682
|
+
.getByTestId(WEBHOOK_SELECTORS.endpointInputField)
|
|
7683
|
+
.fill(webhookSiteURL);
|
|
7684
|
+
const addWebhook = this.neetoPlaywrightUtilities.interceptMultipleResponses({ responseUrl: ROUTES.webhooks, times: 2 });
|
|
7685
|
+
await this.page.getByTestId(COMMON_SELECTORS.saveChangesButton).click();
|
|
7686
|
+
await addWebhook;
|
|
7687
|
+
await test.expect(this.page.getByRole("row", { name: webhookSiteURL })).toBeVisible();
|
|
7688
|
+
};
|
|
7689
|
+
this.verifyLatestWebhookResponse = async ({ callback = () => { }, webhookToken, ...otherParams }) => {
|
|
7690
|
+
let response;
|
|
7691
|
+
await test.expect(async () => {
|
|
7692
|
+
response = await this.request.get(`https://webhook.site/token/${webhookToken}/request/latest`);
|
|
7693
|
+
test.expect(response.status()).toBe(200);
|
|
7694
|
+
if (response.status() === 200) {
|
|
7695
|
+
const { content } = await response.json();
|
|
7696
|
+
const parsedResponse = JSON.parse(content).webhook;
|
|
7697
|
+
callback({ parsedResponse, ...otherParams });
|
|
7698
|
+
}
|
|
7699
|
+
}).toPass({ timeout: 10000 });
|
|
7700
|
+
};
|
|
7701
|
+
this.verifyWebhookDeliveries = async ({ callback = () => { }, ...otherParams }) => {
|
|
7702
|
+
await test.expect(this.page.getByTestId(WEBHOOK_SELECTORS.deliveryResponseCode)).toHaveText("200");
|
|
7703
|
+
const requestPayload = (await this.page
|
|
7704
|
+
.getByTestId(WEBHOOK_SELECTORS.deliveryRequestPayload)
|
|
7705
|
+
.textContent());
|
|
7706
|
+
const parsedResponse = JSON.parse(requestPayload).webhook;
|
|
7707
|
+
callback({ parsedResponse, ...otherParams });
|
|
7708
|
+
};
|
|
7709
|
+
this.verifyWebhookDeliveryByEvent = async ({ event, callbackToVerifyDeliveries, ...fieldsToBeVerified }) => {
|
|
7710
|
+
await this.page
|
|
7711
|
+
.getByRole("row", { name: event })
|
|
7712
|
+
.getByRole("button")
|
|
7713
|
+
.click();
|
|
7714
|
+
await this.verifyWebhookDeliveries({
|
|
7715
|
+
callback: callbackToVerifyDeliveries,
|
|
7716
|
+
...fieldsToBeVerified,
|
|
7717
|
+
});
|
|
7718
|
+
};
|
|
7719
|
+
this.page = page;
|
|
7720
|
+
this.request = request;
|
|
7721
|
+
this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
|
|
7722
|
+
this.context = context;
|
|
7723
|
+
this.t = playwrightI18nextFixture.getI18nInstance().t;
|
|
7724
|
+
}
|
|
7725
|
+
}
|
|
7726
|
+
|
|
7656
7727
|
const SIGNUP_SELECTORS = {
|
|
7657
7728
|
emailTextField: "signup-email-text-field",
|
|
7658
7729
|
firstNameTextField: "signup-profile-first-name-text-field",
|
|
@@ -7914,6 +7985,9 @@ const ROLES_SELECTORS = {
|
|
|
7914
7985
|
headerColumn: "ntm-roles-table-header",
|
|
7915
7986
|
dropDownIcon: "ntm-roles-table-header-role-dropdown-button",
|
|
7916
7987
|
tableHeaderRoleTitle: "ntm-roles-table-header-role-title",
|
|
7988
|
+
permissionCheckbox: "ntm-roles-permission-checkbox",
|
|
7989
|
+
editRoleButton: "ntm-roles-table-edit-role-button",
|
|
7990
|
+
deleteRoleButton: " ntm-roles-table-delete-role-button",
|
|
7917
7991
|
};
|
|
7918
7992
|
|
|
7919
7993
|
const TAGS_SELECTORS = {
|
|
@@ -8599,7 +8673,9 @@ exports.ROUTES = ROUTES;
|
|
|
8599
8673
|
exports.SIGNUP_SELECTORS = SIGNUP_SELECTORS;
|
|
8600
8674
|
exports.STORAGE_STATE = STORAGE_STATE;
|
|
8601
8675
|
exports.TAGS_SELECTORS = TAGS_SELECTORS;
|
|
8676
|
+
exports.THIRD_PARTY_ROUTES = THIRD_PARTY_ROUTES;
|
|
8602
8677
|
exports.USER_AGENTS = USER_AGENTS;
|
|
8678
|
+
exports.WebhooksPage = WebhooksPage;
|
|
8603
8679
|
exports.clearCredentials = clearCredentials;
|
|
8604
8680
|
exports.commands = commands;
|
|
8605
8681
|
exports.definePlaywrightConfig = definePlaywrightConfig;
|