@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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _playwright_test from '@playwright/test';
2
- import { Page, APIRequestContext, Response, APIResponse, Fixtures, PlaywrightWorkerArgs, PlaywrightWorkerOptions, PlaywrightTestArgs, PlaywrightTestOptions, Locator, FrameLocator } from '@playwright/test';
2
+ import { Page, APIRequestContext, Response, APIResponse, Fixtures, PlaywrightWorkerArgs, PlaywrightWorkerOptions, PlaywrightTestArgs, PlaywrightTestOptions, Locator, FrameLocator, BrowserContext } from '@playwright/test';
3
3
  import MailosaurClient from 'mailosaur';
4
4
  import { I18nPlaywrightFixture } from 'playwright-i18next-fixture';
5
5
  import { TFunction } from 'i18next';
@@ -43,12 +43,13 @@ declare class CustomCommands {
43
43
  page: Page;
44
44
  responses: string[];
45
45
  request: APIRequestContext;
46
- constructor(page: Page, request: APIRequestContext);
46
+ baseURL: string | undefined;
47
+ constructor(page: Page, request: APIRequestContext, baseURL?: string | undefined);
47
48
  interceptMultipleResponses: ({ responseUrl, times, baseUrl, customPageContext, timeout, }?: Partial<InterceptMultipleResponsesParams>) => Promise<Response[]>;
48
49
  private recursiveMethod;
49
50
  executeRecursively: ExecuteRecursively;
50
51
  verifySuccessToast: ({ message, closeAfterVerification, }?: Partial<VerifySuccessToastParams>) => Promise<void>;
51
- reloadAndWait: (requestCount: number) => Promise<void>;
52
+ reloadAndWait: (requestCount: number, customPageContext?: Page, interceptMultipleResponsesProps?: Partial<Omit<InterceptMultipleResponsesParams, "times">>) => Promise<void>;
52
53
  apiRequest: ApiRequest;
53
54
  verifyFieldValue: VerifyFieldValue;
54
55
  }
@@ -140,6 +141,43 @@ declare class HelpAndProfilePage {
140
141
  verifyLogoutV2: () => Promise<void>;
141
142
  }
142
143
 
144
+ interface WebhooksPageParams {
145
+ page: Page;
146
+ request: APIRequestContext;
147
+ neetoPlaywrightUtilities: CustomCommands;
148
+ context: BrowserContext;
149
+ }
150
+ type CallbackFunction = (args: Record<string, unknown>) => void;
151
+ interface VerifyWebhookResponseParams extends Record<string, unknown> {
152
+ callback?: CallbackFunction;
153
+ webhookToken: string;
154
+ }
155
+ interface VerifyWebhookDeliveriesParams extends Record<string, unknown> {
156
+ callback: CallbackFunction;
157
+ }
158
+ interface VerifyWebhookDeliveryByEventParams extends Record<string, unknown> {
159
+ event: string;
160
+ callbackToVerifyDeliveries: (args: Record<string, unknown>) => void;
161
+ }
162
+ declare class WebhooksPage {
163
+ page: Page;
164
+ request: APIRequestContext;
165
+ context: BrowserContext;
166
+ neetoPlaywrightUtilities: CustomCommands;
167
+ t: TFunction;
168
+ constructor({ page, request, neetoPlaywrightUtilities, context, }: WebhooksPageParams);
169
+ getWebhookURL: () => Promise<{
170
+ webhookSiteURL: string;
171
+ webhookToken: string;
172
+ }>;
173
+ addWebhook: ({ webhookSiteURL }: {
174
+ webhookSiteURL: string;
175
+ }) => Promise<void>;
176
+ verifyLatestWebhookResponse: ({ callback, webhookToken, ...otherParams }: VerifyWebhookResponseParams) => Promise<void>;
177
+ verifyWebhookDeliveries: ({ callback, ...otherParams }: VerifyWebhookDeliveriesParams) => Promise<void>;
178
+ verifyWebhookDeliveryByEvent: ({ event, callbackToVerifyDeliveries, ...fieldsToBeVerified }: VerifyWebhookDeliveryByEventParams) => Promise<void>;
179
+ }
180
+
143
181
  interface CreateOrganizationProps {
144
182
  email: string;
145
183
  businessName: string;
@@ -188,6 +226,7 @@ declare const ROUTES: {
188
226
  profile: string;
189
227
  myProfile: string;
190
228
  authSettings: string;
229
+ webhooks: string;
191
230
  login: string;
192
231
  signup: string;
193
232
  subdomainAvailability: string;
@@ -208,6 +247,11 @@ declare const API_ROUTES: {
208
247
  show: (id: string) => string;
209
248
  };
210
249
  };
250
+ declare const THIRD_PARTY_ROUTES: {
251
+ webhooks: {
252
+ site: string;
253
+ };
254
+ };
211
255
 
212
256
  declare const COMMON_SELECTORS: {
213
257
  spinner: string;
@@ -378,6 +422,9 @@ declare const ROLES_SELECTORS: {
378
422
  headerColumn: string;
379
423
  dropDownIcon: string;
380
424
  tableHeaderRoleTitle: string;
425
+ permissionCheckbox: string;
426
+ editRoleButton: string;
427
+ deleteRoleButton: string;
381
428
  };
382
429
 
383
430
  declare const SIGNUP_SELECTORS: {
@@ -526,4 +573,4 @@ interface Overrides {
526
573
  }
527
574
  declare const definePlaywrightConfig: (overrides: Overrides) => _playwright_test.PlaywrightTestConfig<{}, {}>;
528
575
 
529
- export { API_ROUTES, BASE_URL, CHANGELOG_WIDGET_SELECTORS, CHAT_WIDGET_SELECTORS, COMMON_SELECTORS, CREDENTIALS, CustomCommands, type CustomFixture, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, HELP_CENTER_SELECTORS, HelpAndProfilePage, IS_STAGING_ENV, KEYBOARD_SHORTCUTS_SELECTORS, LOGIN_SELECTORS, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MERGE_TAGS_SELECTORS, MailosaurUtils, NEETO_AUTH_BASE_URL, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, OTP_EMAIL_PATTERN, OrganizationPage, PROFILE_SECTION_SELECTORS, PROJECT_TRANSLATIONS_PATH, ROLES_SELECTORS, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, TAGS_SELECTORS, USER_AGENTS, clearCredentials, commands, definePlaywrightConfig, extractSubdomainFromError, generateStagingData, getGlobalUserState, hyphenize, i18nFixture, initializeCredentials, joinHyphenCase, joinString, login, loginWithoutSSO, memberUtils, readFileSyncIfExists, removeCredentialFile, shouldSkipSetupAndTeardown, skipTest, updateCredentials, writeDataToFile };
576
+ export { API_ROUTES, BASE_URL, CHANGELOG_WIDGET_SELECTORS, CHAT_WIDGET_SELECTORS, COMMON_SELECTORS, CREDENTIALS, CustomCommands, type CustomFixture, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, HELP_CENTER_SELECTORS, HelpAndProfilePage, IS_STAGING_ENV, KEYBOARD_SHORTCUTS_SELECTORS, LOGIN_SELECTORS, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MERGE_TAGS_SELECTORS, MailosaurUtils, NEETO_AUTH_BASE_URL, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, OTP_EMAIL_PATTERN, OrganizationPage, PROFILE_SECTION_SELECTORS, PROJECT_TRANSLATIONS_PATH, ROLES_SELECTORS, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, TAGS_SELECTORS, THIRD_PARTY_ROUTES, USER_AGENTS, WebhooksPage, clearCredentials, commands, definePlaywrightConfig, extractSubdomainFromError, generateStagingData, getGlobalUserState, hyphenize, i18nFixture, initializeCredentials, joinHyphenCase, joinString, login, loginWithoutSSO, memberUtils, readFileSyncIfExists, removeCredentialFile, shouldSkipSetupAndTeardown, skipTest, updateCredentials, writeDataToFile };
package/index.js CHANGED
@@ -152,7 +152,7 @@ const COMMON_SELECTORS = {
152
152
  };
153
153
 
154
154
  class CustomCommands {
155
- constructor(page, request) {
155
+ constructor(page, request, baseURL = process.env.BASE_URL) {
156
156
  this.interceptMultipleResponses = ({ responseUrl = "", times = 1, baseUrl, customPageContext, timeout = 35000, } = {}) => {
157
157
  const pageContext = customPageContext !== null && customPageContext !== void 0 ? customPageContext : this.page;
158
158
  return Promise.all([...new Array(times)].map(() => pageContext.waitForResponse((response) => {
@@ -160,9 +160,7 @@ class CustomCommands {
160
160
  if (response.request().resourceType() === "xhr" &&
161
161
  response.status() === 200 &&
162
162
  response.url().includes(responseUrl) &&
163
- response
164
- .url()
165
- .startsWith((_a = baseUrl !== null && baseUrl !== void 0 ? baseUrl : process.env.BASE_URL) !== null && _a !== void 0 ? _a : "") &&
163
+ response.url().startsWith((_a = baseUrl !== null && baseUrl !== void 0 ? baseUrl : this.baseURL) !== null && _a !== void 0 ? _a : "") &&
166
164
  !this.responses.includes((_b = response.headers()) === null || _b === void 0 ? void 0 : _b["x-request-id"])) {
167
165
  this.responses.push((_c = response.headers()) === null || _c === void 0 ? void 0 : _c["x-request-id"]);
168
166
  return true;
@@ -194,11 +192,13 @@ class CustomCommands {
194
192
  (await this.page.getByTestId(COMMON_SELECTORS.toastCloseButton).click());
195
193
  await expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toBeHidden();
196
194
  };
197
- this.reloadAndWait = async (requestCount) => {
195
+ this.reloadAndWait = async (requestCount, customPageContext, interceptMultipleResponsesProps = {}) => {
196
+ const pageContext = customPageContext !== null && customPageContext !== void 0 ? customPageContext : this.page;
198
197
  const reloadRequests = this.interceptMultipleResponses({
199
198
  times: requestCount,
199
+ ...interceptMultipleResponsesProps,
200
200
  });
201
- await this.page.reload();
201
+ await pageContext.reload();
202
202
  await reloadRequests;
203
203
  };
204
204
  this.apiRequest = async ({ url, failOnStatusCode = true, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
@@ -234,6 +234,7 @@ class CustomCommands {
234
234
  this.page = page;
235
235
  this.responses = [];
236
236
  this.request = request;
237
+ this.baseURL = baseURL;
237
238
  }
238
239
  }
239
240
 
@@ -260,8 +261,8 @@ class MailosaurUtils {
260
261
  }
261
262
 
262
263
  const commands = {
263
- neetoPlaywrightUtilities: async ({ page, request }, use) => {
264
- const commands = new CustomCommands(page, request);
264
+ neetoPlaywrightUtilities: async ({ page, request, baseURL }, use) => {
265
+ const commands = new CustomCommands(page, request, baseURL);
265
266
  await use(commands);
266
267
  },
267
268
  mailosaur: async ({}, use) => {
@@ -288,11 +289,11 @@ const commands = {
288
289
 
289
290
  const generateStagingData = (product = "invoice") => {
290
291
  var _a;
291
- const timestamp = `${dayjs().format("YYYYMMDDHH")}${(_a = process.env.JOB_COMPLETION_INDEX) !== null && _a !== void 0 ? _a : ""}`;
292
+ const timestamp = `${dayjs().format("MMDDHHmmssSSS")}${(_a = process.env.JOB_COMPLETION_INDEX) !== null && _a !== void 0 ? _a : ""}`;
292
293
  const firstName = "André";
293
294
  const lastName = "O'Reilly";
294
295
  const otpBypassKey = process.env.OTP_BYPASS_KEY;
295
- const stagingOrganization = `cypresstest-${product}-${timestamp}`;
296
+ const stagingOrganization = `cpt-${product}-${timestamp}`;
296
297
  return {
297
298
  firstName,
298
299
  lastName,
@@ -304,7 +305,7 @@ const generateStagingData = (product = "invoice") => {
304
305
  businessName: stagingOrganization,
305
306
  subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
306
307
  email: IS_STAGING_ENV
307
- ? `cypresstest${otpBypassKey}+${product}+${timestamp}-playwright@bigbinary.com`
308
+ ? `cpt${otpBypassKey}+${product}+${timestamp}@bigbinary.com`
308
309
  : CREDENTIALS.email,
309
310
  };
310
311
  };
@@ -7154,6 +7155,7 @@ const ROUTES = {
7154
7155
  profile: "/profile",
7155
7156
  myProfile: "/my/profile",
7156
7157
  authSettings: "/settings",
7158
+ webhooks: "/webhooks",
7157
7159
  login: `${BASE_URL}/login`,
7158
7160
  signup: `${BASE_URL}/signups`,
7159
7161
  subdomainAvailability: `${BASE_URL}/subdomain_availability`,
@@ -7174,6 +7176,9 @@ const API_ROUTES = {
7174
7176
  show: (id) => `/team_members/teams/${id}`,
7175
7177
  },
7176
7178
  };
7179
+ const THIRD_PARTY_ROUTES = {
7180
+ webhooks: { site: "https://webhook.site/" },
7181
+ };
7177
7182
 
7178
7183
  const CHAT_WIDGET_TEXTS = {
7179
7184
  newConversation: "New Conversation",
@@ -7425,7 +7430,7 @@ class HelpAndProfilePage {
7425
7430
  .replaceAll(" ", "then")
7426
7431
  .replaceAll("+", "");
7427
7432
  return osPlatform === "mac"
7428
- ? formattedShortcut.replace(/ctrl/g, "⌘")
7433
+ ? formattedShortcut.replace(/ctrl/g, "⌘").replace(/alt/g, "opt")
7429
7434
  : formattedShortcut;
7430
7435
  };
7431
7436
  this.openAndVerifyKeyboardShortcutsPane = async (productShortcuts, osPlatform = "windows") => {
@@ -7618,6 +7623,72 @@ class HelpAndProfilePage {
7618
7623
  }
7619
7624
  }
7620
7625
 
7626
+ const WEBHOOK_SELECTORS = {
7627
+ addNewWebhook: "add-new-webhook-button",
7628
+ endpointInputField: "endpoint-input-field",
7629
+ deliveryResponseCode: "delivery-response-code",
7630
+ deliveryRequestPayload: "delivery-request-payload",
7631
+ };
7632
+
7633
+ class WebhooksPage {
7634
+ constructor({ page, request, neetoPlaywrightUtilities, context, }) {
7635
+ this.getWebhookURL = async () => {
7636
+ const webhookSitePage = await this.context.newPage();
7637
+ await webhookSitePage.goto(THIRD_PARTY_ROUTES.webhooks.site);
7638
+ await webhookSitePage.waitForURL(/.*#!\/\w+/);
7639
+ const webhookToken = webhookSitePage.url().split("#!/")[1];
7640
+ const webhookSiteURL = `${THIRD_PARTY_ROUTES.webhooks.site}${webhookToken}`;
7641
+ await webhookSitePage.close();
7642
+ return { webhookSiteURL, webhookToken };
7643
+ };
7644
+ this.addWebhook = async ({ webhookSiteURL }) => {
7645
+ await this.page.getByTestId(WEBHOOK_SELECTORS.addNewWebhook).click();
7646
+ await this.page
7647
+ .getByTestId(WEBHOOK_SELECTORS.endpointInputField)
7648
+ .fill(webhookSiteURL);
7649
+ const addWebhook = this.neetoPlaywrightUtilities.interceptMultipleResponses({ responseUrl: ROUTES.webhooks, times: 2 });
7650
+ await this.page.getByTestId(COMMON_SELECTORS.saveChangesButton).click();
7651
+ await addWebhook;
7652
+ await expect(this.page.getByRole("row", { name: webhookSiteURL })).toBeVisible();
7653
+ };
7654
+ this.verifyLatestWebhookResponse = async ({ callback = () => { }, webhookToken, ...otherParams }) => {
7655
+ let response;
7656
+ await expect(async () => {
7657
+ response = await this.request.get(`https://webhook.site/token/${webhookToken}/request/latest`);
7658
+ expect(response.status()).toBe(200);
7659
+ if (response.status() === 200) {
7660
+ const { content } = await response.json();
7661
+ const parsedResponse = JSON.parse(content).webhook;
7662
+ callback({ parsedResponse, ...otherParams });
7663
+ }
7664
+ }).toPass({ timeout: 10000 });
7665
+ };
7666
+ this.verifyWebhookDeliveries = async ({ callback = () => { }, ...otherParams }) => {
7667
+ await expect(this.page.getByTestId(WEBHOOK_SELECTORS.deliveryResponseCode)).toHaveText("200");
7668
+ const requestPayload = (await this.page
7669
+ .getByTestId(WEBHOOK_SELECTORS.deliveryRequestPayload)
7670
+ .textContent());
7671
+ const parsedResponse = JSON.parse(requestPayload).webhook;
7672
+ callback({ parsedResponse, ...otherParams });
7673
+ };
7674
+ this.verifyWebhookDeliveryByEvent = async ({ event, callbackToVerifyDeliveries, ...fieldsToBeVerified }) => {
7675
+ await this.page
7676
+ .getByRole("row", { name: event })
7677
+ .getByRole("button")
7678
+ .click();
7679
+ await this.verifyWebhookDeliveries({
7680
+ callback: callbackToVerifyDeliveries,
7681
+ ...fieldsToBeVerified,
7682
+ });
7683
+ };
7684
+ this.page = page;
7685
+ this.request = request;
7686
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
7687
+ this.context = context;
7688
+ this.t = getI18nInstance().t;
7689
+ }
7690
+ }
7691
+
7621
7692
  const SIGNUP_SELECTORS = {
7622
7693
  emailTextField: "signup-email-text-field",
7623
7694
  firstNameTextField: "signup-profile-first-name-text-field",
@@ -7634,7 +7705,7 @@ const SIGNUP_SELECTORS = {
7634
7705
  };
7635
7706
 
7636
7707
  const extractSubdomainFromError = (errorString) => {
7637
- const regex = /cypresstest[a-zA-Z0-9-]+/g;
7708
+ const regex = /cpt[a-zA-Z0-9-]+/g;
7638
7709
  const matches = errorString.match(regex);
7639
7710
  return matches[1];
7640
7711
  };
@@ -7879,6 +7950,9 @@ const ROLES_SELECTORS = {
7879
7950
  headerColumn: "ntm-roles-table-header",
7880
7951
  dropDownIcon: "ntm-roles-table-header-role-dropdown-button",
7881
7952
  tableHeaderRoleTitle: "ntm-roles-table-header-role-title",
7953
+ permissionCheckbox: "ntm-roles-permission-checkbox",
7954
+ editRoleButton: "ntm-roles-table-edit-role-button",
7955
+ deleteRoleButton: " ntm-roles-table-delete-role-button",
7882
7956
  };
7883
7957
 
7884
7958
  const TAGS_SELECTORS = {
@@ -8534,5 +8608,5 @@ const definePlaywrightConfig = (overrides) => {
8534
8608
  });
8535
8609
  };
8536
8610
 
8537
- export { API_ROUTES, BASE_URL, CHANGELOG_WIDGET_SELECTORS, CHAT_WIDGET_SELECTORS, COMMON_SELECTORS, CREDENTIALS, CustomCommands, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, HELP_CENTER_SELECTORS, HelpAndProfilePage, IS_STAGING_ENV, KEYBOARD_SHORTCUTS_SELECTORS, LOGIN_SELECTORS, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MERGE_TAGS_SELECTORS, MailosaurUtils, NEETO_AUTH_BASE_URL, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, OTP_EMAIL_PATTERN, OrganizationPage, PROFILE_SECTION_SELECTORS, PROJECT_TRANSLATIONS_PATH, ROLES_SELECTORS, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, TAGS_SELECTORS, USER_AGENTS, clearCredentials, commands, definePlaywrightConfig, extractSubdomainFromError, generateStagingData, getGlobalUserState, hyphenize, i18nFixture, initializeCredentials, joinHyphenCase, joinString, login, loginWithoutSSO, memberUtils, readFileSyncIfExists, removeCredentialFile, shouldSkipSetupAndTeardown, skipTest, updateCredentials, writeDataToFile };
8611
+ export { API_ROUTES, BASE_URL, CHANGELOG_WIDGET_SELECTORS, CHAT_WIDGET_SELECTORS, COMMON_SELECTORS, CREDENTIALS, CustomCommands, ENVIRONMENT, GLOBAL_TRANSLATIONS_PATTERN, HELP_CENTER_SELECTORS, HelpAndProfilePage, IS_STAGING_ENV, KEYBOARD_SHORTCUTS_SELECTORS, LOGIN_SELECTORS, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MERGE_TAGS_SELECTORS, MailosaurUtils, NEETO_AUTH_BASE_URL, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, OTP_EMAIL_PATTERN, OrganizationPage, PROFILE_SECTION_SELECTORS, PROJECT_TRANSLATIONS_PATH, ROLES_SELECTORS, ROUTES, SIGNUP_SELECTORS, STORAGE_STATE, TAGS_SELECTORS, THIRD_PARTY_ROUTES, USER_AGENTS, WebhooksPage, clearCredentials, commands, definePlaywrightConfig, extractSubdomainFromError, generateStagingData, getGlobalUserState, hyphenize, i18nFixture, initializeCredentials, joinHyphenCase, joinString, login, loginWithoutSSO, memberUtils, readFileSyncIfExists, removeCredentialFile, shouldSkipSetupAndTeardown, skipTest, updateCredentials, writeDataToFile };
8538
8612
  //# sourceMappingURL=index.js.map