@bigbinary/neeto-playwright-commons 3.0.3 → 3.0.5

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 CHANGED
@@ -145,6 +145,99 @@ const HELP_CENTER_ROUTES = {
145
145
  kbDocs: (product) => `https://help.neeto${product.toLowerCase()}.com/`,
146
146
  changelog: (product) => `https://neeto${product.toLowerCase()}help.neetoengage.net/changelogs`,
147
147
  };
148
+ const ANALYTICS_RESOURCES = [
149
+ "**/analytics/**",
150
+ "**/mixpanel/**",
151
+ "**/static.cloudflareinsights.com/**",
152
+ ];
153
+ const FONTS_RESOURCES = [
154
+ "**/fonts.googleapis.com/**",
155
+ "**/fonts.gstatic.com/**",
156
+ "**/api.fontshare.com/**",
157
+ ];
158
+ const THIRD_PARTY_RESOURCES = [
159
+ ...ANALYTICS_RESOURCES,
160
+ // Advertising networks
161
+ "**amazon-adsystem.com/**",
162
+ "**paa-reporting-advertising.amazon/**",
163
+ "**adsrvr.org/**",
164
+ "**adnxs.com/**",
165
+ "**doubleclick.net/**",
166
+ "**googlesyndication.com/**",
167
+ "**googletagmanager.com/**",
168
+ "**bat.bing.com/**",
169
+ "**connect.facebook.net/**",
170
+ "**facebook.com/**",
171
+ "**ads.linkedin.com/**",
172
+ "**snap.licdn.com/**",
173
+ "**linkedin.com/**",
174
+ "**analytics.tiktok.com/**",
175
+ "**tiktokw.us/**",
176
+ "**alb.reddit.com/**",
177
+ "**redditstatic.com/**",
178
+ "**pixel-config.reddit.com/**",
179
+ "**bidswitch.net/**",
180
+ "**casalemedia.com/**",
181
+ "**pubmatic.com/**",
182
+ "**rubiconproject.com/**",
183
+ "**podscribe.com/**",
184
+ "**trkn.us/**",
185
+ "**usbrowserspeed.com/**",
186
+ // Analytics & tracking
187
+ "**amplitude.com/**",
188
+ "**segment.com/**",
189
+ "**clearbitjs.com/**",
190
+ "**clearbitscripts.com/**",
191
+ "**clearbit.com/**",
192
+ "**builder.io/**",
193
+ "**influ2.com/**",
194
+ "**axiom-vitals.com/**",
195
+ "**qualtrics.com/**",
196
+ // HubSpot
197
+ "**hubspot.com/**",
198
+ "**hs-scripts.com/**",
199
+ "**hs-analytics.net/**",
200
+ "**hsadspixel.net/**",
201
+ "**hs-banner.com/**",
202
+ "**hsforms.com/**",
203
+ "**hubapi.com/**",
204
+ // Monitoring & error tracking
205
+ "**sentry.io/**",
206
+ "**bugsnag.com/**",
207
+ "**datadoghq.com/**",
208
+ "**datadoghq-browser-agent.com/**",
209
+ "**fullstory.com/**",
210
+ // Chat & support widgets
211
+ "**intercom.io/**",
212
+ "**intercomcdn.com/**",
213
+ "**ada.support/**",
214
+ // Product research & feature flags
215
+ "**sprig.com/**",
216
+ "**split.io/**",
217
+ // Cookie consent
218
+ "**cookielaw.org/**",
219
+ "**onetrust.com/**",
220
+ // Zapier layout & marketing (non-functional)
221
+ "**cdn.zapier.com/**",
222
+ "**design-system-bff.zapier.com/**",
223
+ // Realtime messaging
224
+ "**ably.net/**",
225
+ // Microsoft telemetry
226
+ "**browser.events.data.microsoft.com/**",
227
+ ];
228
+ const APP_RESOURCES = [
229
+ ...ANALYTICS_RESOURCES,
230
+ ...FONTS_RESOURCES,
231
+ "**/neeto-widget**",
232
+ "**/neeto-engage-widget**",
233
+ "**.neetoreplay.net",
234
+ "**neeto-replay**.amazonaws.com/**",
235
+ "**/cdn-cgi/rum?",
236
+ "**.neetochat.net/**",
237
+ "**.neetoengage.net/**",
238
+ "**/sticky_ribbons",
239
+ "**/neeto_widget_tokens",
240
+ ];
148
241
 
149
242
  class ApiKeysApi {
150
243
  neetoPlaywrightUtilities;
@@ -321,6 +414,7 @@ class RailsEmailApiClient {
321
414
  clearEmails = () => this.fetchJson(this.emailsEndpoint, {
322
415
  method: "DELETE",
323
416
  });
417
+ clearStaleEmails = (receivedBefore) => this.fetchJson(`${this.emailsEndpoint}?received_before=${encodeURIComponent(receivedBefore)}`, { method: "DELETE" });
324
418
  }
325
419
 
326
420
  class RoleApis {
@@ -5943,6 +6037,18 @@ class CustomCommands {
5943
6037
  .getAttribute("content");
5944
6038
  return this.csrfToken;
5945
6039
  };
6040
+ blockExternalResources = (page = this.page) => Promise.all(THIRD_PARTY_RESOURCES.map(pattern => page.context().route(pattern, route => route.abort())));
6041
+ blockInternalResources = (page = this.page) => Promise.all(APP_RESOURCES.map(pattern => page.context().route(pattern, route => route.abort())));
6042
+ blockNonEssentialResourceTypes = (page = this.page) => page
6043
+ .context()
6044
+ .route("**/*", route => ["image", "stylesheet", "font", "media"].includes(route.request().resourceType())
6045
+ ? route.abort()
6046
+ : route.continue());
6047
+ blockAllResources = (page = this.page) => Promise.all([
6048
+ this.blockExternalResources(page),
6049
+ this.blockInternalResources(page),
6050
+ this.blockNonEssentialResourceTypes(page),
6051
+ ]);
5946
6052
  waitForFloatingMenu = () => test.expect(this.page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton)).toBeVisible({ timeout: 25_000 });
5947
6053
  interceptMultipleResponses = ({ responseUrl = "", responseStatus = 200, times = 1, baseUrl, customPageContext = this.page, timeout = 35_000, } = {}) => Promise.all([...new Array(times)].map(() => customPageContext.waitForResponse((response) => {
5948
6054
  if (response.request().resourceType() === "xhr" &&
@@ -8726,6 +8832,7 @@ class OrganizationPage {
8726
8832
  await fillCredentialsAndSubmit({ page: this.page, email });
8727
8833
  return;
8728
8834
  }
8835
+ await this.neetoPlaywrightUtilities.blockInternalResources();
8729
8836
  await this.fillEmailAndSubmit(email, loginTimeout);
8730
8837
  await this.fillOTP();
8731
8838
  await this.dismissAuthenticatorSetupPromptIfPresent();
@@ -8791,6 +8898,7 @@ class OrganizationPage {
8791
8898
  }
8792
8899
  else {
8793
8900
  let otp = "123456";
8901
+ await this.neetoPlaywrightUtilities.blockInternalResources();
8794
8902
  await this.page.goto(`${ROUTES.neetoAuthSignup}?redirect_uri=${credentials.domain}`, { timeout: 20_000 });
8795
8903
  await this.submitEmail(credentials.email);
8796
8904
  if (fetchOtpFromEmail !== undefined) {
@@ -60367,7 +60475,14 @@ class RailsEmailUtils {
60367
60475
  };
60368
60476
  };
60369
60477
  clearEmails = () => this.railsEmailClient.clearEmails();
60370
- getLatestEmail = (searchParams) => this.railsEmailClient.getLatestEmail(searchParams);
60478
+ clearStaleEmails = () => {
60479
+ const tenMinutesAgo = new Date(Date.now() - 10 * 60 * 1000);
60480
+ return this.railsEmailClient.clearStaleEmails(tenMinutesAgo.toISOString());
60481
+ };
60482
+ getLatestEmail = async (searchParams) => {
60483
+ await this.clearStaleEmails();
60484
+ await this.railsEmailClient.getLatestEmail(searchParams);
60485
+ };
60371
60486
  listEmails = (searchParams) => this.railsEmailClient.listEmails(searchParams);
60372
60487
  listMessages = async (messageSearchCriteria = {}, { receivedAfter = new Date(new Date().valueOf() - 60 * 60 * 1000), } = {}) => {
60373
60488
  const emails = await this.railsEmailClient.listEmails({
@@ -107297,6 +107412,7 @@ const commands = {
107297
107412
  const mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
107298
107413
  await mailerUtils.fastmailApi.authorizeAndSetAccountId();
107299
107414
  await use(mailerUtils);
107415
+ IS_DEV_ENV && (await mailerUtils.railsEmailUtils.clearStaleEmails());
107300
107416
  },
107301
107417
  colorPicker: async ({ page }, use) => {
107302
107418
  const colorPicker = new ColorPickerUtils(page);
@@ -126073,8 +126189,10 @@ const definePlaywrightConfig = (overrides) => {
126073
126189
 
126074
126190
  exports.ACTIONS = ACTIONS;
126075
126191
  exports.ADMIN_PANEL_SELECTORS = ADMIN_PANEL_SELECTORS;
126192
+ exports.ANALYTICS_RESOURCES = ANALYTICS_RESOURCES;
126076
126193
  exports.API_KEYS_SELECTORS = API_KEYS_SELECTORS;
126077
126194
  exports.API_ROUTES = API_ROUTES;
126195
+ exports.APP_RESOURCES = APP_RESOURCES;
126078
126196
  exports.AUDIT_LOGS_SELECTORS = AUDIT_LOGS_SELECTORS;
126079
126197
  exports.ApiKeysApi = ApiKeysApi;
126080
126198
  exports.ApiKeysPage = ApiKeysPage;
@@ -126115,6 +126233,7 @@ exports.EditorPage = EditorPage;
126115
126233
  exports.EmailDeliveryUtils = EmailDeliveryUtils;
126116
126234
  exports.EmbedBase = EmbedBase;
126117
126235
  exports.FILE_FORMATS = FILE_FORMATS;
126236
+ exports.FONTS_RESOURCES = FONTS_RESOURCES;
126118
126237
  exports.FONT_SIZE_SELECTORS = FONT_SIZE_SELECTORS;
126119
126238
  exports.FROM_EMAIL_ENV_KEYS = FROM_EMAIL_ENV_KEYS;
126120
126239
  exports.GLOBAL_TRANSLATIONS_PATTERN = GLOBAL_TRANSLATIONS_PATTERN;
@@ -126201,6 +126320,7 @@ exports.TEXT_MODIFIER_TAGS = TEXT_MODIFIER_TAGS;
126201
126320
  exports.THANK_YOU_SELECTORS = THANK_YOU_SELECTORS;
126202
126321
  exports.THEMES_SELECTORS = THEMES_SELECTORS;
126203
126322
  exports.THEMES_TEXTS = THEMES_TEXTS;
126323
+ exports.THIRD_PARTY_RESOURCES = THIRD_PARTY_RESOURCES;
126204
126324
  exports.THIRD_PARTY_ROUTES = THIRD_PARTY_ROUTES;
126205
126325
  exports.TIME_RANGES = TIME_RANGES;
126206
126326
  exports.TOASTR_MESSAGES = TOASTR_MESSAGES;