@bigbinary/neeto-playwright-commons 1.8.7 → 1.8.9
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 +89 -13
- package/index.cjs.js.map +1 -1
- package/index.d.ts +51 -4
- package/index.js +88 -14
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.cjs.js
CHANGED
|
@@ -187,7 +187,7 @@ const COMMON_SELECTORS = {
|
|
|
187
187
|
};
|
|
188
188
|
|
|
189
189
|
class CustomCommands {
|
|
190
|
-
constructor(page, request) {
|
|
190
|
+
constructor(page, request, baseURL = process.env.BASE_URL) {
|
|
191
191
|
this.interceptMultipleResponses = ({ responseUrl = "", times = 1, baseUrl, customPageContext, timeout = 35000, } = {}) => {
|
|
192
192
|
const pageContext = customPageContext !== null && customPageContext !== void 0 ? customPageContext : this.page;
|
|
193
193
|
return Promise.all([...new Array(times)].map(() => pageContext.waitForResponse((response) => {
|
|
@@ -195,9 +195,7 @@ class CustomCommands {
|
|
|
195
195
|
if (response.request().resourceType() === "xhr" &&
|
|
196
196
|
response.status() === 200 &&
|
|
197
197
|
response.url().includes(responseUrl) &&
|
|
198
|
-
response
|
|
199
|
-
.url()
|
|
200
|
-
.startsWith((_a = baseUrl !== null && baseUrl !== void 0 ? baseUrl : process.env.BASE_URL) !== null && _a !== void 0 ? _a : "") &&
|
|
198
|
+
response.url().startsWith((_a = baseUrl !== null && baseUrl !== void 0 ? baseUrl : this.baseURL) !== null && _a !== void 0 ? _a : "") &&
|
|
201
199
|
!this.responses.includes((_b = response.headers()) === null || _b === void 0 ? void 0 : _b["x-request-id"])) {
|
|
202
200
|
this.responses.push((_c = response.headers()) === null || _c === void 0 ? void 0 : _c["x-request-id"]);
|
|
203
201
|
return true;
|
|
@@ -229,11 +227,13 @@ class CustomCommands {
|
|
|
229
227
|
(await this.page.getByTestId(COMMON_SELECTORS.toastCloseButton).click());
|
|
230
228
|
await test.expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toBeHidden();
|
|
231
229
|
};
|
|
232
|
-
this.reloadAndWait = async (requestCount) => {
|
|
230
|
+
this.reloadAndWait = async (requestCount, customPageContext, interceptMultipleResponsesProps = {}) => {
|
|
231
|
+
const pageContext = customPageContext !== null && customPageContext !== void 0 ? customPageContext : this.page;
|
|
233
232
|
const reloadRequests = this.interceptMultipleResponses({
|
|
234
233
|
times: requestCount,
|
|
234
|
+
...interceptMultipleResponsesProps,
|
|
235
235
|
});
|
|
236
|
-
await
|
|
236
|
+
await pageContext.reload();
|
|
237
237
|
await reloadRequests;
|
|
238
238
|
};
|
|
239
239
|
this.apiRequest = async ({ url, failOnStatusCode = true, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
|
|
@@ -269,6 +269,7 @@ class CustomCommands {
|
|
|
269
269
|
this.page = page;
|
|
270
270
|
this.responses = [];
|
|
271
271
|
this.request = request;
|
|
272
|
+
this.baseURL = baseURL;
|
|
272
273
|
}
|
|
273
274
|
}
|
|
274
275
|
|
|
@@ -295,8 +296,8 @@ class MailosaurUtils {
|
|
|
295
296
|
}
|
|
296
297
|
|
|
297
298
|
const commands = {
|
|
298
|
-
neetoPlaywrightUtilities: async ({ page, request }, use) => {
|
|
299
|
-
const commands = new CustomCommands(page, request);
|
|
299
|
+
neetoPlaywrightUtilities: async ({ page, request, baseURL }, use) => {
|
|
300
|
+
const commands = new CustomCommands(page, request, baseURL);
|
|
300
301
|
await use(commands);
|
|
301
302
|
},
|
|
302
303
|
mailosaur: async ({}, use) => {
|
|
@@ -323,11 +324,11 @@ const commands = {
|
|
|
323
324
|
|
|
324
325
|
const generateStagingData = (product = "invoice") => {
|
|
325
326
|
var _a;
|
|
326
|
-
const timestamp = `${dayjs__default["default"]().format("
|
|
327
|
+
const timestamp = `${dayjs__default["default"]().format("MMDDHHmmssSSS")}${(_a = process.env.JOB_COMPLETION_INDEX) !== null && _a !== void 0 ? _a : ""}`;
|
|
327
328
|
const firstName = "André";
|
|
328
329
|
const lastName = "O'Reilly";
|
|
329
330
|
const otpBypassKey = process.env.OTP_BYPASS_KEY;
|
|
330
|
-
const stagingOrganization = `
|
|
331
|
+
const stagingOrganization = `cpt-${product}-${timestamp}`;
|
|
331
332
|
return {
|
|
332
333
|
firstName,
|
|
333
334
|
lastName,
|
|
@@ -339,7 +340,7 @@ const generateStagingData = (product = "invoice") => {
|
|
|
339
340
|
businessName: stagingOrganization,
|
|
340
341
|
subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
|
|
341
342
|
email: IS_STAGING_ENV
|
|
342
|
-
? `
|
|
343
|
+
? `cpt${otpBypassKey}+${product}+${timestamp}@bigbinary.com`
|
|
343
344
|
: CREDENTIALS.email,
|
|
344
345
|
};
|
|
345
346
|
};
|
|
@@ -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",
|
|
@@ -7460,7 +7465,7 @@ class HelpAndProfilePage {
|
|
|
7460
7465
|
.replaceAll(" ", "then")
|
|
7461
7466
|
.replaceAll("+", "");
|
|
7462
7467
|
return osPlatform === "mac"
|
|
7463
|
-
? formattedShortcut.replace(/ctrl/g, "⌘")
|
|
7468
|
+
? formattedShortcut.replace(/ctrl/g, "⌘").replace(/alt/g, "opt")
|
|
7464
7469
|
: formattedShortcut;
|
|
7465
7470
|
};
|
|
7466
7471
|
this.openAndVerifyKeyboardShortcutsPane = async (productShortcuts, osPlatform = "windows") => {
|
|
@@ -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",
|
|
@@ -7669,7 +7740,7 @@ const SIGNUP_SELECTORS = {
|
|
|
7669
7740
|
};
|
|
7670
7741
|
|
|
7671
7742
|
const extractSubdomainFromError = (errorString) => {
|
|
7672
|
-
const regex = /
|
|
7743
|
+
const regex = /cpt[a-zA-Z0-9-]+/g;
|
|
7673
7744
|
const matches = errorString.match(regex);
|
|
7674
7745
|
return matches[1];
|
|
7675
7746
|
};
|
|
@@ -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;
|