@bigbinary/neeto-playwright-commons 4.12.7 → 5.0.1

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.
Files changed (4) hide show
  1. package/README.md +2 -4
  2. package/index.d.ts +485 -2768
  3. package/index.js +460 -2436
  4. package/package.json +2 -2
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { isPresent, keysToSnakeCase, hyphenate, humanize, noop as noop$2, isNotPresent, keysToCamelCase, dynamicArray, findBy, truncate, isNotEmpty, _findBy, isNotEqualDeep, randomPick } from '@bigbinary/neeto-cist';
1
+ import { isPresent, keysToSnakeCase, isNotPresent, hyphenate, humanize, noop as noop$2, keysToCamelCase, truncate, isNotEmpty, _findBy, randomPick, findBy } from '@bigbinary/neeto-cist';
2
2
  import { faker } from '@faker-js/faker/locale/en';
3
3
  import * as fs from 'fs';
4
4
  import { readFileSync, writeFileSync, unlinkSync, mkdirSync, rmSync, existsSync, createWriteStream } from 'fs';
@@ -9,7 +9,7 @@ import path__default from 'path';
9
9
  import { expect, test, chromium, defineConfig, devices } from '@playwright/test';
10
10
  import { stringify } from 'picoquery';
11
11
  import { getI18nInstance, initI18n } from 'playwright-i18next-fixture';
12
- import { isEmpty, isNil, mergeAll, curry, isNotNil, not, pluck, mergeDeepLeft } from 'ramda';
12
+ import { isEmpty, mergeAll, curry, isNotNil, not, pluck, mergeDeepLeft } from 'ramda';
13
13
  import { spawn, execSync, spawnSync } from 'child_process';
14
14
  import dayjs from 'dayjs';
15
15
  import { Redis } from 'ioredis';
@@ -20,13 +20,11 @@ import { parse as parse$1 } from 'node-html-parser';
20
20
  import { Jimp } from 'jimp';
21
21
  import jsQRModule from 'jsqr';
22
22
  import { globSync } from 'node:fs';
23
- import customParseFormat from 'dayjs/plugin/customParseFormat.js';
24
23
  import timezone from 'dayjs/plugin/timezone.js';
25
24
  import utc from 'dayjs/plugin/utc.js';
26
25
  import https from 'https';
27
26
  import { countries } from 'countries-list';
28
27
  import { parsePhoneNumberWithError } from 'libphonenumber-js';
29
- import * as http from 'http';
30
28
  import { lock } from 'proper-lockfile';
31
29
  import dotenv from 'dotenv';
32
30
 
@@ -224,29 +222,6 @@ const APP_RESOURCES = [
224
222
  "**/neeto_widget_tokens",
225
223
  ];
226
224
  const ALL_RESOURCES = Array.from(new Set([...THIRD_PARTY_RESOURCES, ...APP_RESOURCES]));
227
- const PRODUCT_ROLES_ROUTE_MAP = {
228
- crm: "/admin/admin-panel/manageUsers/roles",
229
- planner: "/admin-panel/general/roles",
230
- ...Object.fromEntries(["code", "runner", "ci", "git", "tower", "quiz"].map(product => [
231
- product,
232
- "/admin/admin-panel/roles",
233
- ])),
234
- };
235
-
236
- class ApiKeysApi {
237
- neetoPlaywrightUtilities;
238
- API_KEYS_BASE_URL = `neeto_api_keys${BASE_URL}`;
239
- constructor(neetoPlaywrightUtilities) {
240
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
241
- }
242
- create = (label, type = "general") => this.neetoPlaywrightUtilities.apiRequest({
243
- url: `${this.API_KEYS_BASE_URL}/api_keys`,
244
- method: "post",
245
- body: {
246
- api_key: { has_no_expiry: true, expires_at: null, label, type },
247
- },
248
- });
249
- }
250
225
 
251
226
  const CUSTOM_DOMAIN_BASE_URL = `${BASE_URL}/custom_domains`;
252
227
  class CustomDomainApi {
@@ -330,13 +305,10 @@ const SLACK_DEFAULT_CHANNEL = "general";
330
305
  const CUSTOM_DOMAIN_SUFFIX = "neetoautomation.com";
331
306
  const REVIEW_APP_CUSTOM_DOMAIN_SUFFIX = `review.${CUSTOM_DOMAIN_SUFFIX}`;
332
307
  const CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX = process.env.CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX;
333
- const ZAPIER_TEST_EMAIL = (product) => `neeto-${product}-zapier-test@${process.env.FASTMAIL_DOMAIN_NAME}`;
334
308
  const MAILPIT_BASE_URL = "https://mailpit.neetodeployapp.com";
335
309
  const MAILPIT_DOMAIN_NAME = "mail.neetoautomation.com";
336
- const IS_MAILPIT_ENABLED = isPresent(process.env.MAILPIT_DOMAIN_NAME);
337
- const IS_SHADCN_UI = isPresent(process.env.IS_SHADCN_UI);
338
310
  const mailpitDomainName = () => process.env.MAILPIT_DOMAIN_NAME || MAILPIT_DOMAIN_NAME;
339
- const ZAPIER_TEST_EMAIL_V2 = (product) => `neeto-${product}-zapier-test@${mailpitDomainName()}`;
311
+ const ZAPIER_TEST_EMAIL = (product) => `neeto-${product}-zapier-test@${mailpitDomainName()}`;
340
312
  // constants for translation
341
313
  const SINGULAR = { count: 1 };
342
314
  const PLURAL = { count: 2 };
@@ -466,42 +438,6 @@ class MailpitApi {
466
438
  };
467
439
  }
468
440
 
469
- class MemberApis {
470
- neetoPlaywrightUtilities;
471
- teamMembersBaseUrl;
472
- teamsBaseUrl;
473
- constructor(neetoPlaywrightUtilities) {
474
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
475
- this.teamMembersBaseUrl = "/neeto_team_members";
476
- this.teamsBaseUrl = `${this.teamMembersBaseUrl}/teams`;
477
- }
478
- create = (body) => this.neetoPlaywrightUtilities.apiRequest({
479
- method: "post",
480
- url: this.teamsBaseUrl,
481
- body: { user: body },
482
- });
483
- jobStatus = (jobId) => this.neetoPlaywrightUtilities.apiRequest({
484
- url: `${this.teamsBaseUrl}/creation_status/${jobId}`,
485
- });
486
- fetch = (params = {}) => this.neetoPlaywrightUtilities.apiRequest({
487
- url: this.teamsBaseUrl,
488
- params,
489
- });
490
- fetchPermissions = () => this.neetoPlaywrightUtilities.apiRequest({
491
- url: `${this.teamMembersBaseUrl}/permissions`,
492
- });
493
- update = (memberId, body) => this.neetoPlaywrightUtilities.apiRequest({
494
- method: "put",
495
- url: `${this.teamsBaseUrl}/${memberId}`,
496
- body: { team: body },
497
- });
498
- bulkUpdate = (body) => this.neetoPlaywrightUtilities.apiRequest({
499
- method: "patch",
500
- url: `${this.teamsBaseUrl}/bulk_update`,
501
- body: { users: body },
502
- });
503
- }
504
-
505
441
  class RailsEmailApiClient {
506
442
  port = process.env.RAILS_SERVER_PORT;
507
443
  subdomain = process.env.SUBDOMAIN ?? "spinkart";
@@ -563,38 +499,6 @@ class RailsEmailApiClient {
563
499
  clearStaleEmails = (receivedBefore) => this.fetchJson(`${this.emailsEndpoint}?received_before=${encodeURIComponent(receivedBefore)}`, { method: "DELETE" });
564
500
  }
565
501
 
566
- class RoleApis {
567
- neetoPlaywrightUtilities;
568
- BASE_URL = "/neeto_team_members";
569
- ORGANIZATION_ROLES_URL = `${this.BASE_URL}/organization_roles`;
570
- constructor(neetoPlaywrightUtilities) {
571
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
572
- }
573
- fetch = (endpoint) => this.neetoPlaywrightUtilities.apiRequest({
574
- url: `${this.BASE_URL}/${endpoint}`,
575
- });
576
- addRole = (roleName, permissionIds) => this.neetoPlaywrightUtilities.apiRequest({
577
- url: this.ORGANIZATION_ROLES_URL,
578
- method: "post",
579
- data: {
580
- organization_role: {
581
- name: roleName,
582
- permission_ids: permissionIds,
583
- },
584
- },
585
- });
586
- editRole = (roleId, body) => this.neetoPlaywrightUtilities.apiRequest({
587
- url: `${this.ORGANIZATION_ROLES_URL}/${roleId}`,
588
- method: "patch",
589
- body: { organization_role: body },
590
- });
591
- deleteRole = (roleId, standardRoleId) => this.neetoPlaywrightUtilities.apiRequest({
592
- url: `${this.ORGANIZATION_ROLES_URL}/${roleId}`,
593
- method: "delete",
594
- body: { new_role_id: standardRoleId },
595
- });
596
- }
597
-
598
502
  const SECURITY_BASE_URL = `/secure${BASE_URL}/configuration`;
599
503
  class SecurityApi {
600
504
  neetoPlaywrightUtilities;
@@ -633,18 +537,6 @@ class SecurityApi {
633
537
  });
634
538
  }
635
539
 
636
- class TagsApi {
637
- neetoPlaywrightUtilities;
638
- constructor(neetoPlaywrightUtilities) {
639
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
640
- }
641
- create = ({ body, tagsRequestUrl, }) => this.neetoPlaywrightUtilities.apiRequest({
642
- url: tagsRequestUrl,
643
- body,
644
- method: "post",
645
- });
646
- }
647
-
648
540
  const THANK_YOU_URL = "/neeto_thank_you/thank_you_configurations";
649
541
  class ThankYouApi {
650
542
  neetoPlaywrightUtilities;
@@ -676,6 +568,34 @@ class ThankYouApi {
676
568
  });
677
569
  }
678
570
 
571
+ const formatEnvList = (names) => {
572
+ const last = names[names.length - 1];
573
+ const rest = names.slice(0, -1);
574
+ if (rest.length === 0)
575
+ return last;
576
+ if (rest.length === 1)
577
+ return `${rest[0]} and ${last}`;
578
+ return `${rest.join(", ")}, and ${last}`;
579
+ };
580
+ const missingEnvMessage = (names) => {
581
+ const noun = names.length === 1 ? "ENV variable" : "ENV variables";
582
+ const verb = names.length === 1 ? "is" : "are";
583
+ return `${noun} ${formatEnvList(names)} ${verb} not set`;
584
+ };
585
+ /**
586
+ * Reads the named environment variables. Throws when any value is missing or
587
+ * blank, listing only the names that failed. One name returns the string;
588
+ * several names return an object keyed by those names.
589
+ */
590
+ const requireEnv = (...names) => {
591
+ const missing = names.filter(name => isNotPresent(process.env[name]));
592
+ if (missing.length > 0)
593
+ throw new Error(missingEnvMessage(missing));
594
+ if (names.length === 1)
595
+ return process.env[names[0]];
596
+ return Object.fromEntries(names.map(name => [name, process.env[name]]));
597
+ };
598
+
679
599
  const NEETO_TOWER_BASE_URL = "https://ops.neetotower.com/";
680
600
  const DNS_RECORDS_BASE_URL = `${NEETO_TOWER_BASE_URL}api/v1/public/automation_tests/dns_records`;
681
601
  class NeetoTowerApi {
@@ -683,10 +603,7 @@ class NeetoTowerApi {
683
603
  apiKey;
684
604
  constructor(neetoPlaywrightUtilities) {
685
605
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
686
- if (!process.env.NEETO_TOWER_API_KEY) {
687
- throw new Error("NEETO_TOWER_API_KEY is not set");
688
- }
689
- this.apiKey = process.env.NEETO_TOWER_API_KEY;
606
+ this.apiKey = requireEnv("NEETO_TOWER_API_KEY");
690
607
  }
691
608
  apiRequest = ({ method, dnsDomainId = "", body, }) => this.neetoPlaywrightUtilities.apiRequest({
692
609
  url: `${DNS_RECORDS_BASE_URL}${dnsDomainId ? `/${dnsDomainId}` : ""}`,
@@ -707,10 +624,7 @@ class SlackApi {
707
624
  botToken;
708
625
  constructor(neetoPlaywrightUtilities) {
709
626
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
710
- if (!process.env.SLACK_BOT_TOKEN) {
711
- throw new Error("SLACK_BOT_TOKEN is not set");
712
- }
713
- this.botToken = process.env.SLACK_BOT_TOKEN;
627
+ this.botToken = requireEnv("SLACK_BOT_TOKEN");
714
628
  }
715
629
  apiRequest = (endpoint, params) => this.neetoPlaywrightUtilities.apiRequest({
716
630
  url: `https://slack.com/api/conversations.${endpoint}`,
@@ -751,14 +665,10 @@ class TwilioApi {
751
665
  defaultPhoneSid;
752
666
  constructor(neetoPlaywrightUtilities) {
753
667
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
754
- if (!process.env.TWILIO_AUTH_TOKEN ||
755
- !process.env.TWILIO_SID ||
756
- !process.env.TWILIO_DEFAULT_PHONE_SID) {
757
- throw new Error("TWILIO_AUTH_TOKEN, TWILIO_SID, and TWILIO_DEFAULT_PHONE_SID are not set");
758
- }
759
- this.authToken = process.env.TWILIO_AUTH_TOKEN;
760
- this.sid = process.env.TWILIO_SID;
761
- this.defaultPhoneSid = process.env.TWILIO_DEFAULT_PHONE_SID;
668
+ const env = requireEnv("TWILIO_AUTH_TOKEN", "TWILIO_SID", "TWILIO_DEFAULT_PHONE_SID");
669
+ this.authToken = env.TWILIO_AUTH_TOKEN;
670
+ this.sid = env.TWILIO_SID;
671
+ this.defaultPhoneSid = env.TWILIO_DEFAULT_PHONE_SID;
762
672
  }
763
673
  apiRequest = ({ endpoint, params, body, method = "get", }) => this.neetoPlaywrightUtilities.apiRequest({
764
674
  method,
@@ -813,20 +723,6 @@ const CUSTOM_DOMAIN_SELECTORS = {
813
723
  strategyContinueButton: "custom-domain-strategy-continue-button",
814
724
  onlyAddRootRadio: "custom-domain-strategy-only-add-root-radio-input",
815
725
  };
816
- const API_KEYS_SELECTORS = {
817
- countLabel: "api-keys-count",
818
- editApiKeyButton: "api-key-edit-button",
819
- deleteApiKeyButton: "api-key-delete-button",
820
- addApiKeyButton: "add-api-key-button",
821
- apiKeysLabelField: "api-keys-label-field",
822
- apiKeysExpiresAtField: "api-keys-expires-at-field",
823
- expiryDateInputError: "expiry-date-input-error",
824
- expiryDateInput: "expiry-date-input",
825
- apiKeysField: "api-keys-label-field",
826
- tokenField: "api-keys-token-field",
827
- expiresAtField: "api-keys-expires-at-field",
828
- createdAtField: "api-keys-created-at-field",
829
- };
830
726
  const IP_RESTRICTIONS_SELECTORS = {
831
727
  enableIPRestrictionChk: "enable-ip-restriction-checkbox",
832
728
  saveChanges: "ip-restriction-save-changes",
@@ -1005,7 +901,7 @@ const COMMON_SELECTORS = {
1005
901
  emailInputWrapper: "email-input-wrapper",
1006
902
  switchWrapper: "nui-switch-wrapper",
1007
903
  switchLabel: "nui-switch-item",
1008
- antdSliderRail: ".ant-slider-rail",
904
+ slider: '[data-slot="slider"]',
1009
905
  card: "neeto-molecules-card",
1010
906
  hotkeyDescription: "hotkey-description",
1011
907
  columnVisibilityBtn: (action) => `column-visibility-${action}-button`,
@@ -1038,8 +934,8 @@ const THANK_YOU_SELECTORS = {
1038
934
  showLinkToSubmitAnotherResponseSwitch: "show-link-to-submit-another-response-switch",
1039
935
  submitAnotherResponseLinkTextInputField: "submit-another-response-link-text-input-field",
1040
936
  previewEditorContent: "preview-editor-content",
1041
- redirectToExternalLinkRadioLabel: () => "neeto-thank-you-configuration-redirect-to-url-label",
1042
- thankYouConfigurationLabel: (label = "custom-message") => `neeto-thank-you-configuration-${label}-label`,
937
+ redirectToExternalLinkRadioLabel: () => "neeto-thank-you-configuration-redirect-to-url-radio-label",
938
+ thankYouConfigurationLabel: (label = "custom-message") => `neeto-thank-you-configuration-${label}-radio-label`,
1043
939
  saveChangesButton: "neeto-thank-you-configuration-save-button",
1044
940
  cancelButton: "neeto-thank-you-configuration-cancel-button",
1045
941
  thankYouPageImage: "thank-you-page-image",
@@ -1148,13 +1044,6 @@ const CHAT_WIDGET_TEXTS = {
1148
1044
  welcomeChatBubble: "Hi! I'm here to assist you with any questions you may have. What can I do for you?",
1149
1045
  preChatQuestions: "Please fill in the form to start chatting.",
1150
1046
  };
1151
- const MEMBER_TEXTS = {
1152
- agent: "Agent",
1153
- admin: "Admin",
1154
- selectAll: "Select All",
1155
- hide: "Hide all",
1156
- show: "Show all",
1157
- };
1158
1047
  const INTEGRATIONS_TEXTS = {
1159
1048
  connectHeader: (integration) => `Connect your ${integration} account`,
1160
1049
  connectedHeader: (integration) => `${integration} is connected`,
@@ -1409,24 +1298,29 @@ const startLockRefresh = (redis, provider) => {
1409
1298
  }, LOCK_REFRESH_INTERVAL_MS);
1410
1299
  return () => clearInterval(interval);
1411
1300
  };
1412
- const pollForCookies = (redis, provider, context) => {
1301
+ const pollForCookies = async (redis, provider, context) => {
1413
1302
  log$2(`"${provider}" lock held by another shard — waiting for cached cookies`);
1414
- let timedOut = false;
1415
- const timeout = new Promise((_, reject) => setTimeout(() => {
1416
- timedOut = true;
1417
- reject(new Error(`[cookieCache] Timed out waiting for "${provider}" cookies from another shard`));
1418
- }, POLL_TIMEOUT_MS));
1303
+ const controller = new AbortController();
1304
+ const { signal } = controller;
1305
+ const timeout = setTimeout$1(POLL_TIMEOUT_MS, undefined, { signal }).then(() => {
1306
+ throw new Error(`[cookieCache] Timed out waiting for "${provider}" cookies from another shard`);
1307
+ });
1419
1308
  const poll = async () => {
1420
- while (!timedOut) {
1421
- await setTimeout$1(POLL_INTERVAL_MS);
1309
+ while (true) {
1310
+ await setTimeout$1(POLL_INTERVAL_MS, undefined, { signal });
1422
1311
  if (await restoreCookies(redis, provider, context))
1423
1312
  return true;
1313
+ signal.throwIfAborted();
1424
1314
  if (!(await redis.exists(lockKey(provider))))
1425
1315
  return false;
1426
1316
  }
1427
- return false;
1428
1317
  };
1429
- return Promise.race([poll(), timeout]);
1318
+ try {
1319
+ return await Promise.race([poll(), timeout]);
1320
+ }
1321
+ finally {
1322
+ controller.abort();
1323
+ }
1430
1324
  };
1431
1325
  const cacheCookies = async (redis, provider, context, allowedDomains) => {
1432
1326
  const cookies = (await context.cookies()).filter(({ domain }) => allowedDomains.some(d => domain.includes(d)));
@@ -1540,16 +1434,13 @@ class GooglePage extends IntegrationBase {
1540
1434
  if (IS_DEV_ENV)
1541
1435
  return;
1542
1436
  return withCookieCache("google", this.page.context(), async () => {
1543
- if (isNil(process.env.GOOGLE_LOGIN_EMAIL) ||
1544
- isNil(process.env.GOOGLE_LOGIN_PASSWORD)) {
1545
- throw new Error("ENV variable GOOGLE_LOGIN_EMAIL or GOOGLE_LOGIN_PASSWORD is not properly configured");
1546
- }
1437
+ const env = requireEnv("GOOGLE_LOGIN_EMAIL", "GOOGLE_LOGIN_PASSWORD");
1547
1438
  await this.page.goto(THIRD_PARTY_ROUTES.google.signin, {
1548
1439
  timeout: 20_000,
1549
1440
  });
1550
1441
  await this.page
1551
1442
  .getByLabel(GOOGLE_LOGIN_TEXTS.emailOrPhone)
1552
- .pressSequentially(process.env.GOOGLE_LOGIN_EMAIL, { delay: 10 });
1443
+ .pressSequentially(env.GOOGLE_LOGIN_EMAIL, { delay: 10 });
1553
1444
  await this.page
1554
1445
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.next })
1555
1446
  .click();
@@ -1558,7 +1449,7 @@ class GooglePage extends IntegrationBase {
1558
1449
  await expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.showPassword)).toBeVisible({ timeout: 10_000 });
1559
1450
  await this.page
1560
1451
  .getByLabel(GOOGLE_LOGIN_TEXTS.enterYourPassword)
1561
- .pressSequentially(process.env.GOOGLE_LOGIN_PASSWORD, {
1452
+ .pressSequentially(env.GOOGLE_LOGIN_PASSWORD, {
1562
1453
  delay: 10,
1563
1454
  timeout: 20_000,
1564
1455
  });
@@ -1713,12 +1604,10 @@ const createOrganizationViaRake = async ({ email, firstName, lastName, subdomain
1713
1604
  return stdout.trim();
1714
1605
  };
1715
1606
  const createOrganizationViaApi = async ({ page, email, firstName, lastName, businessName, subdomainName, redirectUri, timeZone = DEFAULT_TIMEZONE_ID, }) => {
1716
- if (!process.env.OTP_BYPASS_KEY) {
1717
- throw new Error("OTP_BYPASS_KEY environment variable is required to create organizations via the quick setups API.");
1718
- }
1607
+ const otpBypassKey = requireEnv("OTP_BYPASS_KEY");
1719
1608
  const response = await page.request.post(`${NEETO_AUTH_BASE_URL()}/api/v1/internal/quick_setups`, {
1720
1609
  headers: {
1721
- Authorization: `Token token="${process.env.OTP_BYPASS_KEY}"`,
1610
+ Authorization: `Token token="${otpBypassKey}"`,
1722
1611
  },
1723
1612
  data: {
1724
1613
  setup: {
@@ -1979,12 +1868,6 @@ class OrganizationPage {
1979
1868
  await this.runLoginStrategy(params, email);
1980
1869
  await this.dismissAuthenticatorSetupPromptIfPresent();
1981
1870
  };
1982
- /** @deprecated Use `login({ email, via: "authenticatorApp" })`. */
1983
- loginViaAuthenticatorApp = email => this.login({ email, via: LOGIN_STRATEGIES.authenticatorApp });
1984
- /** @deprecated Use `login({ email })`. */
1985
- loginViaSSO = email => this.login({ email });
1986
- /** @deprecated Use `login({ email, via: "emailOtp", fetchOtpFromEmail })`. */
1987
- loginWithFastmailEmail = ({ email, fetchOtpFromEmail, }) => this.login({ email, via: LOGIN_STRATEGIES.emailOtp, fetchOtpFromEmail });
1988
1871
  setupProfile = async ({ firstName = faker.person.firstName(), lastName = faker.person.lastName(), country, } = {}) => {
1989
1872
  if (IS_DEV_ENV)
1990
1873
  return;
@@ -2121,8 +2004,6 @@ class OrganizationPage {
2121
2004
  .click();
2122
2005
  await expect(countrySelector).toContainText(country);
2123
2006
  };
2124
- /** @deprecated Use `login({ via: "google" })`. */
2125
- loginViaGoogleAuth = () => this.login({ via: LOGIN_STRATEGIES.google });
2126
2007
  completeGoogleAuth = async () => {
2127
2008
  const googlePage = new GooglePage({
2128
2009
  neetoPlaywrightUtilities: this.neetoPlaywrightUtilities,
@@ -2172,13 +2053,7 @@ const REVIEW_APP_POLL_INTERVAL = 10_000;
2172
2053
  const REVIEW_APP_REQUEST_TIMEOUT = 20_000;
2173
2054
  // The host is read on each call so that a product importing the package outside
2174
2055
  // the review environment never trips the guard.
2175
- const reviewAppHost = () => {
2176
- const host = process.env.REVIEW_APP_HOST;
2177
- if (!host) {
2178
- throw new Error("REVIEW_APP_HOST must be set when TEST_ENV is review");
2179
- }
2180
- return host;
2181
- };
2056
+ const reviewAppHost = () => requireEnv("REVIEW_APP_HOST");
2182
2057
  const isReviewAppServing = async () => {
2183
2058
  try {
2184
2059
  const response = await fetch(`https://${reviewAppHost()}/?_hs=${Date.now()}`, {
@@ -2554,8 +2429,8 @@ const EMBED_SELECTORS = {
2554
2429
  previewTab: "preview-tab",
2555
2430
  htmlTab: "html-tab",
2556
2431
  buttonTextInput: "button-text-input-field",
2557
- buttonPositionSelectContainer: "button-position-select-value-container",
2558
- buttonPositionSelectMenu: "button-position-select-menu",
2432
+ buttonPositionSelectContainer: "button-position-select-field-select-container",
2433
+ buttonPositionSelectMenu: "button-position-select-field-select-menu",
2559
2434
  buttonColorLabel: "button-color-label",
2560
2435
  buttonTextColorLabel: "button-text-color-label",
2561
2436
  colorPickerTarget: "color-picker-target",
@@ -2711,24 +2586,6 @@ const TWILIO_SELECTORS = {
2711
2586
  authTokenField: "auth-token-input-field",
2712
2587
  };
2713
2588
 
2714
- const WEBHOOK_SELECTORS = {
2715
- addNewWebhook: "add-new-webhook-button",
2716
- endpointInputField: "endpoint-input-field",
2717
- deliveryResponseCode: "delivery-response-code",
2718
- deliveryRequestPayload: "delivery-request-payload",
2719
- addSecretKey: "add-secret-key",
2720
- newWebhookHeader: "add-new-webhook-pane-header",
2721
- endpointInputError: "endpoint-input-error",
2722
- eventsSelectError: "events-select-error",
2723
- regenerateSecret: "regenerate-secret",
2724
- deleteSecret: "delete-secret",
2725
- deliveryRequestHeader: "delivery-request-header",
2726
- deliveryResponseBody: "delivery-response-body",
2727
- eventErrorText: "event-error-text",
2728
- editWebhookButton: "neeto-webhooks-edit-button",
2729
- deleteWebhookButton: "neeto-webhooks-delete-button",
2730
- };
2731
-
2732
2589
  const ZAPIER_SELECTORS = {
2733
2590
  zapTriggerStep: (zapId) => `[data-testid='step-node-${zapId}']`,
2734
2591
  zapAccountSubstep: "[data-testid='substep-Account']",
@@ -2775,53 +2632,6 @@ const LOGIN_SELECTORS = {
2775
2632
  authenticatorAppLaterButton: "authenticator-app-promo-later-button",
2776
2633
  };
2777
2634
 
2778
- const MEMBER_SELECTORS = {
2779
- membersTab: "members-nav-tab",
2780
- newButton: "ntm-add-member-button",
2781
- continueButton: "ntm-manage-member-continue-button",
2782
- submitButton: "ntm-manage-member-submit-button",
2783
- searchTextField: "ntm-search-members-input",
2784
- deactivatedAgentsButton: "ntm-members-menubar-deactivated-block",
2785
- activatedMembersButton: "ntm-members-menubar-active-block",
2786
- columnCheckBox: "neeto-ui-columns-checkbox",
2787
- roleLabel: (role) => `${joinHyphenCase(role)}-radio-label`,
2788
- teamMembersTable: "ntm-members-table",
2789
- dropDownIcon: "ntm-members-table-row-dropdown-button",
2790
- editButton: "ntm-edit-member-button",
2791
- menuBarHeading: "ntm-members-menubar-heading",
2792
- removeMember: "ntm-deactivate-member-button",
2793
- columnsButton: "columns-dropdown-button",
2794
- columnsDropdownContainer: "columns-dropdown-container",
2795
- emailDropdownItemLabel: "email-checkbox-label",
2796
- roleDropdownItemLabel: "role-checkbox-label",
2797
- inviteStatusDropdownItemLabel: "invite-status-checkbox-label",
2798
- heading: "ntm-manage-members-pane-header",
2799
- activateButton: "ntm-activate-members-button",
2800
- deactivateButton: "ntm-deactivate-members-button",
2801
- rolesButton: "ntm-manage-member-roles-button",
2802
- statusTag: "ntm-member-status-tag",
2803
- exportMemberHeading: "export-member-heading",
2804
- downloadAsRadioItem: (fileType) => `download-as-${fileType}-radio-item`,
2805
- exportSubmitBtn: "export-submit-button",
2806
- exportCancelBtn: "export-cancel-button",
2807
- downloadButton: "download-button",
2808
- manageAppListChk: "ntm-manage-members-app-list-checkbox",
2809
- takeActionDropdown: "ntm-members-take-action-dropdown-button",
2810
- menubarSubLink: (sublink) => `members-${sublink}-block-sub-link`,
2811
- takeActionStateOption: (option = "") => `ntm-${hyphenate(option)}-members-button`,
2812
- checkboxLabel: (label) => `${hyphenate(label)}-checkbox-label`,
2813
- subscriptionPlanTag: "ntm-member-subscription-plan-tag",
2814
- memberNameCell: (nameOrEmail) => `ntm-member-name-${hyphenate(nameOrEmail)}`,
2815
- };
2816
- const MEMBER_FORM_SELECTORS = {
2817
- emailTextField: "email-select-input-field",
2818
- firstNameTextField: "ntm-edit-member-first-name-text-field",
2819
- lastNameTextField: "ntm-edit-member-last-name-text-field",
2820
- emailInput: "ntm-manage-member-email-input",
2821
- emailErrorField: "emails-input-error",
2822
- cancelButton: "ntm-manage-member-cancel-button",
2823
- };
2824
-
2825
2635
  const ONBOARDING_SELECTORS = {
2826
2636
  welcomeTitle: "onboarding-welcome-title",
2827
2637
  welcomeDescription: "onboarding-welcome-description",
@@ -2879,33 +2689,6 @@ const PROFILE_SECTION_SELECTORS = {
2879
2689
  imageRemoveBtn: "profile-image-remove-button",
2880
2690
  };
2881
2691
 
2882
- const ROLES_SELECTORS = {
2883
- newButton: "ntm-add-role-button",
2884
- proceedButton: "ntm-add-role-submit-button",
2885
- cancelButton: "ntm-add-role-cancel-button",
2886
- tableHeaderRoleName: "ntm-roles-table-role-header",
2887
- nameTextField: "ntm-add-role-name-text-field",
2888
- searchTextField: "ntm-search-roles-input",
2889
- updateRolePaneHeading: "ntm-add-role-title",
2890
- updateRoleCancelButton: "ntm-add-role-cancel-button",
2891
- descriptionTextField: "ntm-add-role-description-text-field",
2892
- permissionCategoryTitle: "ntm-roles-permission-category-title",
2893
- headerColumn: "ntm-roles-table-header",
2894
- dropDownIcon: "ntm-roles-table-header-role-dropdown-button",
2895
- tableHeaderRoleTitle: "ntm-roles-table-header-role-title",
2896
- permissionCheckbox: (name) => `ntm-roles-permission-checkbox-${hyphenate(name)}`,
2897
- editRoleButton: "ntm-roles-table-edit-role-button",
2898
- deleteRoleButton: "ntm-roles-table-delete-role-button",
2899
- permissionCard: "ntm-roles-permission-card",
2900
- searchPermissionsInput: "ntm-search-permissions-input",
2901
- permissionDescription: "ntm-permission-category-description",
2902
- rolesEditButton: "ntm-roles-table-edit-role-button",
2903
- roleCell: (roleName) => `${hyphenate(roleName)}-role-cell`,
2904
- tablePermissionCheckbox: "ntm-roles-table-permission-checkbox",
2905
- descriptionInputError: "description-input-error",
2906
- permissionSubCategoryCard: (index) => `ntm-roles-permission-sub-category-card-${index}`,
2907
- };
2908
-
2909
2692
  const NEETO_SEO_SELECTORS = {
2910
2693
  configureButton: "neeto-seo-configure-button",
2911
2694
  };
@@ -2951,37 +2734,6 @@ const TABLE_SELECTORS = {
2951
2734
  moveColumnBtn: (position) => `move-column-${position}-menu-button`,
2952
2735
  };
2953
2736
 
2954
- const TAGS_SELECTORS = {
2955
- newTagButton: "add-new-tag-button",
2956
- tagNameTextField: "tag-name-text-field",
2957
- editButton: "tags-edit-button",
2958
- deleteButton: "tags-delete-button",
2959
- cancelButton: "neeto-tags-manage-tag-cancel-button",
2960
- submitButton: "neeto-tags-manage-tag-submit-button",
2961
- searchTextField: "neeto-tags-search-text-input-field",
2962
- descriptionTextArea: "tag-description-text-area",
2963
- addTagButton: "neeto-tags-add-tag-button",
2964
- tagSearchField: "select-tag-container",
2965
- deleteTagButton: "tag-close-icon",
2966
- metaDataCard: "metadata-card",
2967
- metaDataBlock: "metadata-block",
2968
- tagContainer: "tag-container",
2969
- tagsCount: "neeto-tags-filtered-tags-count-text",
2970
- };
2971
- const MERGE_TAGS_SELECTORS = {
2972
- mergeTagsButton: "neeto-tags-merge-tags-button",
2973
- mergeButton: "neeto-tags-merge-button",
2974
- sourceSearchTextField: "neeto-tags-merge-source-search-text-input-field",
2975
- sourceTagsList: "neeto-tags-merge-source-tags-list",
2976
- destinationTagsList: "neeto-tags-merge-destination-tags-list",
2977
- destinationSearchTextField: "neeto-tags-merge-destination-search-text-input-field",
2978
- cancelButton: "neeto-tags-merge-cancel-button",
2979
- proceedButton: "neeto-tags-merge-proceed-button",
2980
- disabledTag: ".neeto-ui-cursor-not-allowed",
2981
- sourceTagRow: "neeto-tags-merge-source-tags",
2982
- destinationTagRow: "neeto-tags-merge-destination-tags",
2983
- };
2984
-
2985
2737
  const THEMES_SELECTORS = {
2986
2738
  colorPickerDropdownContainer: (colorHex) => `${colorHex}-dropdown-container`,
2987
2739
  baseThemeStyle: (styleType) => `theme-style-${hyphenate(styleType)}`,
@@ -3053,10 +2805,9 @@ const generateRandomFile = ({ sizeInKB, fileType, fileName = `sample.${fileType}
3053
2805
  const file = new File([byteArray], fileName, { type: mimeType });
3054
2806
  return { file, fileName };
3055
2807
  };
3056
- const readFileAsBrowserFile = ({ filePath, mimeType, }) => {
3057
- const buffer = new Uint8Array(readFileSync(filePath));
3058
- return new File([buffer], path__default.basename(filePath), { type: mimeType });
3059
- };
2808
+ const readFileAsBrowserFile = ({ filePath, mimeType, }) => new File([readFileSync(filePath)], path__default.basename(filePath), {
2809
+ type: mimeType,
2810
+ });
3060
2811
 
3061
2812
  const getImagePathAndName = (localImagePath) => {
3062
2813
  const imagePath = path__default.join(import.meta.dirname, localImagePath);
@@ -3096,7 +2847,7 @@ class CustomCommands {
3096
2847
  this.blockNonEssentialResourceTypes(page),
3097
2848
  ...ALL_RESOURCES.map(pattern => page.context().route(pattern, route => route.abort())),
3098
2849
  ]);
3099
- waitForFloatingMenu = () => expect(this.page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton)).toBeVisible({ timeout: 25_000 });
2850
+ waitForFloatingMenu = (customPageContext = this.page) => expect(customPageContext.getByTestId(COMMON_SELECTORS.floatingActionMenuButton)).toBeVisible({ timeout: 30_000 });
3100
2851
  interceptMultipleResponses = ({ responseUrl = "", responseStatus = 200, times = 1, baseUrl, customPageContext = this.page, timeout = 35_000, } = {}) => Promise.all([...new Array(times)].map(() => customPageContext.waitForResponse((response) => {
3101
2852
  if (response.request().resourceType() === "xhr" &&
3102
2853
  response.status() === responseStatus &&
@@ -3124,39 +2875,13 @@ class CustomCommands {
3124
2875
  const startTime = Date.now();
3125
2876
  return await this.recursiveMethod(callback, condition, timeout, startTime, 1);
3126
2877
  };
3127
- /**
3128
- * @deprecated Targets the react-toastify-based Toastr from
3129
- * @bigbinary/neetoui. Use verifyToastV2 instead for apps whose Toastr
3130
- * comes from @bigbinary/neeto-atoms (sonner-based, e.g. neeto-engage-web).
3131
- * Kept only for apps still on the legacy neetoui Toastr.
3132
- */
3133
2878
  verifyToast = async ({ message = "", toastType = "success", closeAfterVerification = true, timeout = 10_000, toastCloseTimeout = 10_000, customPageContext = this.page, } = {}) => {
3134
- const toastrLocator = customPageContext
2879
+ const toastMessageLocator = customPageContext.getByTestId(COMMON_SELECTORS.toastMessage(toastType));
2880
+ // Some products are still on the v1 (neetoui) Toastr, which renders the thumbs up icon and close button outside the message container.
2881
+ const toastLocator = customPageContext
3135
2882
  .locator(COMMON_SELECTORS.neetoUiToastr)
3136
- .filter({
3137
- has: customPageContext.getByTestId(COMMON_SELECTORS.toastMessage(toastType)),
3138
- });
3139
- const filteredToastrLocator = (isEmpty(message)
3140
- ? toastrLocator
3141
- : toastrLocator.filter({ hasText: message }))
3142
- // eslint-disable-next-line playwright/no-nth-methods
3143
- .first();
3144
- await expect(filteredToastrLocator).toContainText(isEmpty(message) ? TOAST_DEFAULT_MESSAGE : message, { timeout });
3145
- if (!closeAfterVerification)
3146
- return;
3147
- const toastrCloseButton = filteredToastrLocator.getByTestId(COMMON_SELECTORS.toastCloseButton);
3148
- const buttonHandle = await toastrCloseButton.elementHandle();
3149
- if (buttonHandle) {
3150
- await customPageContext.evaluate(button => {
3151
- button.dispatchEvent(new Event("click", { bubbles: true }));
3152
- }, buttonHandle);
3153
- await expect(toastrCloseButton).toBeHidden({
3154
- timeout: toastCloseTimeout,
3155
- });
3156
- }
3157
- };
3158
- verifyToastV2 = async ({ message = "", toastType = "success", closeAfterVerification = true, timeout = 10_000, toastCloseTimeout = 10_000, customPageContext = this.page, } = {}) => {
3159
- const toastLocator = customPageContext.getByTestId(COMMON_SELECTORS.toastMessage(toastType));
2883
+ .filter({ has: toastMessageLocator })
2884
+ .or(toastMessageLocator);
3160
2885
  const filteredToastLocator = (isEmpty(message)
3161
2886
  ? toastLocator
3162
2887
  : toastLocator.filter({ hasText: message }))
@@ -3190,13 +2915,6 @@ class CustomCommands {
3190
2915
  }
3191
2916
  await Promise.all(loaders.map(loader => expect(loader).toHaveCount(0, { timeout: visibilityTimeout })));
3192
2917
  };
3193
- waitForPaneToLoad = async ({ visibilityTimeout = 35_000, customPageContext = this.page, } = {}) => {
3194
- const pane = customPageContext.getByTestId(COMMON_SELECTORS.paneBody);
3195
- await expect(pane).toBeVisible({ timeout: visibilityTimeout });
3196
- await expect(pane.getByTestId(COMMON_SELECTORS.uiSpinner)).toHaveCount(0, {
3197
- timeout: visibilityTimeout,
3198
- });
3199
- };
3200
2918
  apiRequest = async ({ url, failOnStatusCode = true, headers: additionalHeaders, body: data, method = "get", params = {}, timeout = 30_000, ...otherOptions }) => {
3201
2919
  const csrfToken = this.csrfToken ?? (await this.initializeCsrfToken());
3202
2920
  const requestOptions = {
@@ -3219,54 +2937,28 @@ class CustomCommands {
3219
2937
  })}`;
3220
2938
  return await this.request[method](formattedUrl, requestOptions);
3221
2939
  };
3222
- selectOptionFromDropdown = async ({ label = "nui", value, page = this.page, options = {}, }) => {
3223
- IS_SHADCN_UI
3224
- ? await this.selectOptionFromDropdownV2({ label, value, page, options })
3225
- : await this.selectOptionFromDropdownV1({ label, value, page, options });
3226
- };
3227
- selectOptionFromDropdownV1 = async ({ label = "nui", value, page = this.page, options = {}, }) => {
3228
- Object.assign({
3229
- visibilityTimeout: 2_000,
3230
- textAssertionTimeout: 1_000,
3231
- retryTimeout: 20_000,
3232
- }, options);
2940
+ selectOptionFromDropdown = async ({ label = "nui", value, page = this.page, options: { visibilityTimeout = 5_000, textAssertionTimeout = 5_000, retryTimeout = 60_000, } = {}, }) => {
3233
2941
  const menu = page.getByTestId(COMMON_SELECTORS.customDropDownMenu(label));
3234
- const container = page.getByTestId(COMMON_SELECTORS.customSelectValueContainer(label));
2942
+ const optionByName = menu.getByRole("option", { name: value, exact: true });
2943
+ const container = page.getByTestId(COMMON_SELECTORS.customSelectContainer(label));
3235
2944
  await expect(async () => {
3236
2945
  await container.click();
3237
- await expect(menu).toBeVisible({
3238
- timeout: options.visibilityTimeout,
3239
- });
2946
+ await expect(menu).toBeVisible({ timeout: visibilityTimeout });
3240
2947
  await page.keyboard.type(value);
3241
- await menu.getByText(value, { exact: true }).click();
2948
+ const option = (await optionByName.count()) > 0
2949
+ ? optionByName
2950
+ : menu.getByText(value, { exact: true });
2951
+ await option.click();
3242
2952
  await expect(container).toContainText(value, {
3243
- timeout: options.textAssertionTimeout,
2953
+ timeout: textAssertionTimeout,
3244
2954
  });
3245
- }).toPass({ timeout: options.retryTimeout });
2955
+ }).toPass({ timeout: retryTimeout });
3246
2956
  };
3247
2957
  waitForSheetOpen = () => expect(this.page.getByTestId(COMMON_SELECTORS.sheetHeader)).toBeInViewport({
3248
2958
  timeout: 10_000,
3249
2959
  ratio: 1,
3250
2960
  });
3251
2961
  waitForSheetClose = () => expect(this.page.getByTestId(COMMON_SELECTORS.sheetWrapper)).toHaveCount(0, { timeout: 10_000 });
3252
- selectOptionFromDropdownV2 = async ({ label = "nui", value, page = this.page, options = {}, }) => {
3253
- Object.assign({
3254
- visibilityTimeout: 2_000,
3255
- textAssertionTimeout: 1_000,
3256
- retryTimeout: 20_000,
3257
- }, options);
3258
- const menu = page.getByTestId(COMMON_SELECTORS.customDropDownMenu(label));
3259
- const container = page.getByTestId(COMMON_SELECTORS.customSelectContainer(label));
3260
- await expect(async () => {
3261
- await container.click();
3262
- await expect(menu).toBeVisible({ timeout: options.visibilityTimeout });
3263
- await page.keyboard.type(value);
3264
- await menu.getByRole("option", { name: value, exact: true }).click();
3265
- await expect(container).toContainText(value, {
3266
- timeout: options.textAssertionTimeout,
3267
- });
3268
- }).toPass({ timeout: options.retryTimeout });
3269
- };
3270
2962
  verifyFieldValue = values => {
3271
2963
  const verifyEachFieldValue = ({ field, value, }) => expect(this.page.getByTestId(field)).toHaveValue(value);
3272
2964
  return Array.isArray(values)
@@ -3320,31 +3012,43 @@ class CustomCommands {
3320
3012
  await this.hideTooltip(triggerElement, customPageContext);
3321
3013
  };
3322
3014
  verifyHelpPopover = async ({ triggerElement = this.page.getByTestId(COMMON_SELECTORS.helpPopoverButton), title, content, helpURL, customPageContext = this.page, }) => {
3323
- const tooltipBox = customPageContext.getByTestId(COMMON_SELECTORS.tooltip);
3324
3015
  await triggerElement.hover();
3325
- title &&
3326
- (await expect(tooltipBox.getByRole("heading", { name: title })).toBeVisible());
3327
- content && (await expect(tooltipBox).toContainText(content));
3016
+ const titleLocator = customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverTitle);
3017
+ const descLocator = customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverDesc);
3018
+ const linkLocator = customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverLinkButton);
3019
+ const popoverContentLocator = title
3020
+ ? titleLocator
3021
+ : content
3022
+ ? descLocator
3023
+ : linkLocator;
3024
+ title && (await expect(titleLocator).toHaveText(title));
3025
+ content && (await expect(descLocator).toContainText(content));
3328
3026
  helpURL &&
3329
3027
  (await Promise.all([
3330
3028
  this.assertHelpURLIsValid(helpURL),
3331
- expect(tooltipBox.getByTestId(COMMON_SELECTORS.helpPopoverLinkButton)).toHaveAttribute("href", new RegExp(helpURL, "i")),
3029
+ expect(linkLocator).toHaveAttribute("href", new RegExp(helpURL, "i")),
3332
3030
  ]));
3333
- await this.hideTooltip(triggerElement, customPageContext);
3031
+ await this.hidePopoverContent(popoverContentLocator, customPageContext);
3334
3032
  };
3335
- assertHelpURLIsValid = async (helpURL) => {
3336
- const response = await this.request.get(helpURL);
3033
+ assertHelpURLIsValid = (helpURL) => expect(async () => {
3034
+ const response = await this.request.get(helpURL, { timeout: 15_000 });
3337
3035
  await expect(response).toBeOK();
3338
- };
3036
+ }).toPass({ timeout: 45_000, intervals: [3_000] });
3339
3037
  verifyHelpText = async (helpURL) => {
3340
3038
  const isNoDataTitleHidden = await this.page
3341
- .getByTestId(COMMON_SELECTORS.noDataTitle)
3039
+ .getByTestId(COMMON_SELECTORS.noDataTitleV2)
3342
3040
  .isHidden();
3343
3041
  if (isNoDataTitleHidden)
3344
3042
  return;
3043
+ const helpLink = this.page
3044
+ .getByTestId(COMMON_SELECTORS.noDataHelpTextV2)
3045
+ .getByRole("link")
3046
+ .or(this.page
3047
+ .getByTestId(COMMON_SELECTORS.noDataDescriptionV2)
3048
+ .getByRole("link"));
3345
3049
  await Promise.all([
3346
3050
  this.assertHelpURLIsValid(helpURL),
3347
- expect(this.page.getByTestId(COMMON_SELECTORS.noDataHelpText).getByRole("link")).toHaveAttribute("href", new RegExp(helpURL, "i")),
3051
+ expect(helpLink).toHaveAttribute("href", new RegExp(helpURL, "i")),
3348
3052
  ]);
3349
3053
  };
3350
3054
  verifySearchTermBlock = async (searchTerm) => {
@@ -3363,7 +3067,7 @@ class CustomCommands {
3363
3067
  }
3364
3068
  };
3365
3069
  saveChanges = ({ isPane = false, customPageContext = this.page, closeAfterVerification = true, toastMessage = "", } = {}) => {
3366
- const pane = customPageContext.getByTestId(COMMON_SELECTORS.backdrop);
3070
+ const pane = customPageContext.getByTestId(COMMON_SELECTORS.sheetWrapper);
3367
3071
  const baseLocator = isPane ? pane : customPageContext;
3368
3072
  return Promise.all([
3369
3073
  this.clickButtonAndAwaitLoad({
@@ -3396,13 +3100,16 @@ class CustomCommands {
3396
3100
  await expect(async () => {
3397
3101
  for (const [moveX, moveY] of moves) {
3398
3102
  await customPageContext.mouse.move(moveX, moveY);
3399
- const tooltipCount = await tooltip.count();
3400
- if (tooltipCount === 0)
3103
+ if ((await tooltip.count()) === 0)
3401
3104
  break;
3402
3105
  }
3403
3106
  await expect(tooltip).toHaveCount(0);
3404
3107
  }).toPass({ timeout: 30_000 });
3405
3108
  };
3109
+ hidePopoverContent = async (contentLocator, customPageContext = this.page) => {
3110
+ await customPageContext.mouse.move(0, 0);
3111
+ await expect(contentLocator).toBeHidden();
3112
+ };
3406
3113
  verifyBreadcrumbs = async (titlesAndRoutes) => {
3407
3114
  const header = this.page.getByTestId(COMMON_SELECTORS.breadcrumbHeader);
3408
3115
  const titles = pluck("title", titlesAndRoutes);
@@ -3410,23 +3117,25 @@ class CustomCommands {
3410
3117
  await Promise.all([
3411
3118
  expect(header).toContainText(titles),
3412
3119
  expect(header).toHaveCount(titlesAndRoutes.length),
3413
- expect(header.getByRole("link", { name: last?.title, exact: true })).toHaveCount(0),
3120
+ expect(header.getByRole("link", { name: last?.title, exact: true })).toHaveAttribute("aria-disabled", "true"),
3414
3121
  ...links.map(({ title, route }) => expect(header.getByRole("link", { name: title, exact: true })).toHaveAttribute("href", route)),
3415
3122
  ]);
3416
3123
  };
3417
3124
  uploadFileViaDispatchV2 = async ({ droppableZone = this.page.getByTestId(COMMON_SELECTORS.fileUploadBody), dispatchEvent = "drop", timeout = 45_000, file, }) => {
3418
3125
  const serializedFile = await serializeFileForBrowser(file);
3419
- const dataTransfer = await Promise.race([
3420
- droppableZone.evaluateHandle(async (_, { name, type, buffer, lastModified }) => {
3421
- const uint8Array = new Uint8Array(buffer);
3422
- const file = new File([uint8Array], name, { type, lastModified });
3423
- const dataTransfer = new DataTransfer();
3424
- dataTransfer.items.add(file);
3425
- return dataTransfer;
3426
- }, serializedFile),
3427
- new Promise((_, reject) => setTimeout(() => reject(new Error("File injection timed out")), timeout)),
3428
- ]);
3429
- await droppableZone.dispatchEvent(dispatchEvent, { dataTransfer });
3126
+ const dataTransfer = await droppableZone.evaluateHandle((_, { name, type, buffer, lastModified }) => {
3127
+ const uint8Array = new Uint8Array(buffer);
3128
+ const file = new File([uint8Array], name, { type, lastModified });
3129
+ const dataTransfer = new DataTransfer();
3130
+ dataTransfer.items.add(file);
3131
+ return dataTransfer;
3132
+ }, serializedFile, { timeout });
3133
+ try {
3134
+ await droppableZone.dispatchEvent(dispatchEvent, { dataTransfer });
3135
+ }
3136
+ finally {
3137
+ await dataTransfer.dispose();
3138
+ }
3430
3139
  };
3431
3140
  verifyUnsavedChangesModal = async (shouldLeavePage = false) => {
3432
3141
  const alertBox = this.page.getByTestId(COMMON_SELECTORS.alertBox);
@@ -3445,7 +3154,8 @@ class CustomCommands {
3445
3154
  await expect(alertBox).toBeHidden();
3446
3155
  };
3447
3156
  setSliderValue = async ({ parentLocator = this.page, valueAsPercent, startFromCenter = false, }) => {
3448
- const sliderLocator = parentLocator.locator(COMMON_SELECTORS.antdSliderRail);
3157
+ const sliderLocator = parentLocator.locator(COMMON_SELECTORS.slider);
3158
+ await expect(sliderLocator).toBeVisible();
3449
3159
  await sliderLocator.evaluate(node => node.scrollIntoView({ behavior: "instant", block: "center" }));
3450
3160
  const sliderBoundingBox = await sliderLocator.boundingBox();
3451
3161
  let targetX = sliderBoundingBox.width * valueAsPercent;
@@ -3484,9 +3194,13 @@ class CustomCommands {
3484
3194
  });
3485
3195
  };
3486
3196
  toggleElement = ({ locator, shouldBeChecked = true }) => expect(async () => {
3487
- const isChecked = await locator.isChecked();
3488
- isChecked !== shouldBeChecked && (await locator.click());
3489
- await expect(locator).toBeChecked({ checked: shouldBeChecked });
3197
+ // Callers often pass an atoms Switch's wrapper (`<prefix>-switch`); the checkable control is the nested `nui-switch-item`.
3198
+ const switchItem = locator.getByTestId(COMMON_SELECTORS.switchLabel);
3199
+ const target =
3200
+ // eslint-disable-next-line playwright/no-nth-methods
3201
+ (await switchItem.count()) > 0 ? switchItem.first() : locator;
3202
+ (await target.isChecked()) !== shouldBeChecked && (await target.click());
3203
+ await expect(target).toBeChecked({ checked: shouldBeChecked });
3490
3204
  }).toPass({ timeout: 15_000 });
3491
3205
  // Polls the editor's own state, which is what the next key press acts on.
3492
3206
  // The DOM selection is not proof: ProseMirror re-applies its stored
@@ -3519,127 +3233,26 @@ class CustomCommands {
3519
3233
  await this.page.keyboard.press("Enter");
3520
3234
  };
3521
3235
  }
3522
- class CustomCommandsV2 extends CustomCommands {
3523
- selectOptionFromDropdown = async ({ label = "nui", value, page = this.page, options = {}, }) => {
3524
- Object.assign({
3525
- visibilityTimeout: 2_000,
3526
- textAssertionTimeout: 1_000,
3527
- retryTimeout: 20_000,
3528
- }, options);
3529
- const menu = page.getByTestId(COMMON_SELECTORS.customDropDownMenu(label));
3530
- const container = page.getByTestId(COMMON_SELECTORS.customSelectContainer(label));
3531
- await expect(async () => {
3532
- await container.click();
3533
- await expect(menu).toBeVisible({
3534
- timeout: options.visibilityTimeout,
3535
- });
3536
- await page.keyboard.type(value);
3537
- await menu.getByText(value, { exact: true }).click();
3538
- await expect(container).toContainText(value, {
3539
- timeout: options.textAssertionTimeout,
3540
- });
3541
- }).toPass({ timeout: options.retryTimeout });
3542
- };
3543
- verifyHelpPopover = async ({ triggerElement = this.page.getByTestId(COMMON_SELECTORS.helpPopoverButton), title, content, helpURL, customPageContext = this.page, }) => {
3544
- await triggerElement.hover();
3545
- const getPopoverContentLocator = () => {
3546
- if (title) {
3547
- return customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverTitle);
3548
- }
3549
- if (content) {
3550
- return customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverDesc);
3551
- }
3552
- return customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverLinkButton);
3553
- };
3554
- const popoverContentLocator = getPopoverContentLocator();
3555
- title && (await expect(popoverContentLocator).toHaveText(title));
3556
- content &&
3557
- (await expect(customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverDesc)).toContainText(content));
3558
- helpURL &&
3559
- (await Promise.all([
3560
- this.assertHelpURLIsValid(helpURL),
3561
- expect(customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverLinkButton)).toHaveAttribute("href", new RegExp(helpURL, "i")),
3562
- ]));
3563
- await this.hidePopoverContent(triggerElement, popoverContentLocator, customPageContext);
3564
- };
3565
- verifyHelpText = async (helpURL) => {
3566
- const isNoDataTitleHidden = await this.page
3567
- .getByTestId(COMMON_SELECTORS.noDataTitleV2)
3568
- .isHidden();
3569
- if (isNoDataTitleHidden)
3570
- return;
3571
- const helpLink = this.page
3572
- .getByTestId(COMMON_SELECTORS.noDataHelpTextV2)
3573
- .getByRole("link")
3574
- .or(this.page
3575
- .getByTestId(COMMON_SELECTORS.noDataDescriptionV2)
3576
- .getByRole("link"));
3577
- await Promise.all([
3578
- this.assertHelpURLIsValid(helpURL),
3579
- expect(helpLink).toHaveAttribute("href", new RegExp(helpURL, "i")),
3580
- ]);
3581
- };
3582
- verifyBreadcrumbs = async (titlesAndRoutes) => {
3583
- const header = this.page.getByTestId(COMMON_SELECTORS.breadcrumbHeader);
3584
- const titles = pluck("title", titlesAndRoutes);
3585
- const [last, ...links] = titlesAndRoutes.toReversed();
3586
- await Promise.all([
3587
- expect(header).toContainText(titles),
3588
- expect(header).toHaveCount(titlesAndRoutes.length),
3589
- expect(header.getByRole("link", { name: last?.title, exact: true })).toHaveAttribute("aria-disabled", "true"),
3590
- ...links.map(({ title, route }) => expect(header.getByRole("link", { name: title, exact: true })).toHaveAttribute("href", route)),
3591
- ]);
3592
- };
3593
- hidePopoverContent = async (triggerElement, contentLocator, customPageContext = this.page) => {
3594
- const boundingBox = await triggerElement.boundingBox();
3595
- if (!boundingBox) {
3596
- throw new Error("Trigger element bounding box not found");
3597
- }
3598
- const { x, y, width, height } = boundingBox;
3599
- const moves = [
3600
- [x + width + 10, y],
3601
- [x, y + height + 10],
3602
- [x - 10, y],
3603
- [x, y - 10],
3604
- ];
3605
- await expect(async () => {
3606
- for (const [moveX, moveY] of moves) {
3607
- await customPageContext.mouse.move(moveX, moveY);
3608
- const isHidden = await contentLocator.isHidden();
3609
- if (isHidden)
3610
- break;
3611
- }
3612
- await expect(contentLocator).toBeHidden();
3613
- }).toPass({ timeout: 30_000 });
3614
- };
3615
- }
3616
3236
 
3617
3237
  class Health {
3618
3238
  page;
3619
3239
  neetoPlaywrightUtilities;
3620
- email = process.env.PLAYWRIGHT_PRODUCTION_EMAIL;
3240
+ email;
3621
3241
  loginPage;
3622
3242
  constructor(page, neetoPlaywrightUtilities) {
3623
3243
  this.page = page;
3624
3244
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
3625
- if (!process.env.PLAYWRIGHT_PRODUCTION_EMAIL ||
3626
- !process.env.PLAYWRIGHT_PRODUCTION_2FA_SECRET_KEY) {
3627
- throw new Error("One or more required env variables are missing: PLAYWRIGHT_PRODUCTION_EMAIL, PLAYWRIGHT_PRODUCTION_2FA_SECRET_KEY");
3628
- }
3245
+ const env = requireEnv("PLAYWRIGHT_PRODUCTION_EMAIL", "PLAYWRIGHT_PRODUCTION_2FA_SECRET_KEY");
3246
+ this.email = env.PLAYWRIGHT_PRODUCTION_EMAIL;
3629
3247
  this.loginPage = new OrganizationPage(page, neetoPlaywrightUtilities);
3630
3248
  }
3631
- getProductSpecificRolesRoute = () => {
3632
- const { hostname } = new URL(process.env.PLAYWRIGHT_PRODUCTION_BASE_URL);
3633
- const domain = hostname
3634
- .split(".")
3635
- .find(domain => domain.startsWith("neeto"));
3636
- const product = domain.replace(/^neeto/, "").toLowerCase();
3637
- return PRODUCT_ROLES_ROUTE_MAP[product] ?? ROUTES.adminPanel.roles;
3638
- };
3639
3249
  loginToApp = async (route = ROUTES.adminPanel.index) => {
3640
3250
  await this.page.goto(route);
3641
3251
  await this.neetoPlaywrightUtilities.waitForPageLoad();
3642
- await this.loginPage.loginViaAuthenticatorApp(this.email);
3252
+ await this.loginPage.login({
3253
+ email: this.email,
3254
+ via: "authenticatorApp",
3255
+ });
3643
3256
  };
3644
3257
  verifyAppUI = async () => {
3645
3258
  await this.neetoPlaywrightUtilities.waitForFloatingMenu();
@@ -3649,82 +3262,10 @@ class Health {
3649
3262
  verifyAppIsLive = async (customSteps) => {
3650
3263
  await test.step("1: Login to the application", () => this.loginToApp());
3651
3264
  await test.step("2: Verify application UI", this.verifyAppUI);
3652
- await test.step("3: Navigate to roles page", async () => {
3653
- await this.page.goto(this.getProductSpecificRolesRoute());
3654
- await this.neetoPlaywrightUtilities.waitForFloatingMenu();
3655
- await this.neetoPlaywrightUtilities.waitForPageLoad();
3656
- });
3657
- await test.step("4: Verify adding & removing roles", async () => {
3658
- const roleName = faker.string.alphanumeric(8);
3659
- await this.page.getByTestId(ROLES_SELECTORS.newButton).click();
3660
- await this.page.getByTestId(ROLES_SELECTORS.nameTextField).fill(roleName);
3661
- await this.neetoPlaywrightUtilities.clickButtonAndAwaitLoad({
3662
- locator: this.page.getByTestId(ROLES_SELECTORS.proceedButton),
3663
- });
3664
- await this.neetoPlaywrightUtilities.verifyToast();
3665
- const roleHeaderDropDown = this.page
3666
- .getByTestId(ROLES_SELECTORS.tableHeaderRoleName)
3667
- .filter({ hasText: roleName })
3668
- .getByTestId(ROLES_SELECTORS.dropDownIcon);
3669
- await roleHeaderDropDown.click();
3670
- await this.page.getByTestId(ROLES_SELECTORS.deleteRoleButton).click();
3671
- await this.neetoPlaywrightUtilities.clickButtonAndAwaitLoad({
3672
- locator: this.page.getByTestId(COMMON_SELECTORS.alertModalSubmitButton),
3673
- });
3674
- await this.neetoPlaywrightUtilities.verifyToast();
3675
- await expect(roleHeaderDropDown).toBeHidden({ timeout: 10_000 });
3676
- });
3677
3265
  await customSteps?.();
3678
3266
  };
3679
3267
  }
3680
3268
 
3681
- class FastmailApi {
3682
- neetoPlaywrightUtilities;
3683
- headers;
3684
- accountId;
3685
- constructor(neetoPlaywrightUtilities) {
3686
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
3687
- this.headers = {
3688
- "Content-Type": "application/json",
3689
- Authorization: `Bearer ${process.env.NEETO_AUTOMATION_FASTMAIL_API_KEY}`,
3690
- };
3691
- }
3692
- assertApiKey = () => {
3693
- if (!process.env.NEETO_AUTOMATION_FASTMAIL_API_KEY)
3694
- throw new Error("Please set the environment variable NEETO_AUTOMATION_FASTMAIL_API_KEY. Credentials can be found in the Automation Credentials vault in the BigBinary 1Password account.");
3695
- };
3696
- authorizeAndSetAccountId = async () => {
3697
- if (IS_DEV_ENV)
3698
- return;
3699
- this.assertApiKey();
3700
- const response = await this.neetoPlaywrightUtilities.apiRequest({
3701
- method: "get",
3702
- url: "https://api.fastmail.com/.well-known/jmap",
3703
- headers: this.headers,
3704
- });
3705
- const { primaryAccounts: { "urn:ietf:params:jmap:mail": accountId }, } = await response.json();
3706
- this.accountId = accountId;
3707
- };
3708
- apiRequest = async (method, body) => {
3709
- this.assertApiKey();
3710
- const response = await this.neetoPlaywrightUtilities.apiRequest({
3711
- method: "post",
3712
- url: "https://api.fastmail.com/jmap/api/",
3713
- headers: this.headers,
3714
- timeout: 2_000,
3715
- data: {
3716
- using: ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
3717
- methodCalls: [[method, { accountId: this.accountId, ...body }, "0"]],
3718
- },
3719
- });
3720
- return response?.json();
3721
- };
3722
- fetchAttachments = (blobId, attachmentName) => this.neetoPlaywrightUtilities.apiRequest({
3723
- url: `https://www.fastmailusercontent.com/jmap/download/${this.accountId}/${blobId}/${attachmentName}`,
3724
- headers: this.headers,
3725
- });
3726
- }
3727
-
3728
3269
  const basicHTMLContent = (content) => `
3729
3270
  <!DOCTYPE html>
3730
3271
  <html lang="en">
@@ -3940,39 +3481,13 @@ const toMailpitSearchTerm = (value) => `"${value.replace(/"/g, "")}"`;
3940
3481
  const mailpitTimeoutError = (messageSearchCriteria, receivedAfter, expectedEmailCount) => new Error(`Timed out waiting for matching message. Searched Mailpit for ${JSON.stringify(messageSearchCriteria)} received after ${receivedAfter.toISOString()}, expecting at least ${expectedEmailCount}.`);
3941
3482
  class MailerUtils {
3942
3483
  neetoPlaywrightUtilities;
3943
- accountId;
3944
- fastmailApi;
3945
3484
  mailpitApi;
3946
3485
  railsEmailUtils;
3947
3486
  constructor(neetoPlaywrightUtilities) {
3948
3487
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
3949
- this.fastmailApi = new FastmailApi(neetoPlaywrightUtilities);
3950
3488
  this.mailpitApi = new MailpitApi(neetoPlaywrightUtilities);
3951
3489
  this.railsEmailUtils = new RailsEmailUtils(neetoPlaywrightUtilities);
3952
3490
  }
3953
- queryEmail = async (messageSearchCriteria, { receivedAfter = dateTimeOneHourAgo(), page = 1, itemsPerPage = 50, }) => {
3954
- const limit = itemsPerPage;
3955
- const position = (page - 1) * itemsPerPage;
3956
- if (itemsPerPage > 100 || itemsPerPage < 1)
3957
- throw new Error("itemsPerPage should be in the range of 1-100");
3958
- const body = {
3959
- filter: { ...messageSearchCriteria, after: receivedAfter.toISOString() },
3960
- sort: [{ property: "receivedAt", isAscending: false }],
3961
- limit,
3962
- position,
3963
- };
3964
- let ids = [], total = 0;
3965
- try {
3966
- ({
3967
- methodResponses: [[, { ids, total }]],
3968
- } = await this.fastmailApi.apiRequest("Email/query", body));
3969
- }
3970
- catch {
3971
- ids = [];
3972
- total = 0;
3973
- }
3974
- return { ids, total };
3975
- };
3976
3491
  buildMessageBodies = (emailBody, { stripInjectedLinks = false } = {}) => {
3977
3492
  const LINK_REGEX = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])/g;
3978
3493
  const CODE_REGEX = /(?<![#/])\b\d{4,}\b/g;
@@ -3995,71 +3510,10 @@ class MailerUtils {
3995
3510
  const text = { body: textBody, ...contentRecognitions };
3996
3511
  return { html, text };
3997
3512
  };
3998
- getEmails = async (ids) => {
3999
- const messageDetailsBody = {
4000
- ids,
4001
- bodyProperties: ["type", "name"],
4002
- fetchHTMLBodyValues: true,
4003
- };
4004
- const { methodResponses: [[, { list }]], } = await this.fastmailApi.apiRequest("Email/get", messageDetailsBody);
4005
- const formattedList = list.map((listItem) => {
4006
- const { id, from, to, bodyValues, cc, bcc, replyTo, receivedAt, subject, messageId, attachments, blobId, } = listItem;
4007
- const emailBody = Object.values(pluck("value", bodyValues)).join(" ");
4008
- const { html, text } = this.buildMessageBodies(emailBody, {
4009
- stripInjectedLinks: true,
4010
- });
4011
- return {
4012
- html,
4013
- text,
4014
- id,
4015
- from,
4016
- to,
4017
- cc,
4018
- bcc,
4019
- replyTo,
4020
- received: new Date(receivedAt),
4021
- subject,
4022
- attachments,
4023
- blobId,
4024
- ...(messageId?.[0] && { messageId: messageId[0] }),
4025
- };
4026
- });
4027
- return formattedList;
4028
- };
4029
- listMessages = async (messageSearchCriteria = {}, listMessagesFilterCriteria = {}) => {
4030
- if (IS_DEV_ENV) {
4031
- return this.railsEmailUtils.listMessages(messageSearchCriteria, listMessagesFilterCriteria);
4032
- }
4033
- const { ids } = await this.queryEmail(messageSearchCriteria, listMessagesFilterCriteria);
4034
- return this.getEmails(ids);
4035
- };
4036
- getEmailIds = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4037
- const ids = (await this.neetoPlaywrightUtilities.executeRecursively({
4038
- callback: async () => {
4039
- const { ids } = await this.queryEmail(messageSearchCriteria, {
4040
- receivedAfter,
4041
- });
4042
- return ids;
4043
- },
4044
- condition: async () => {
4045
- const { ids } = await this.queryEmail(messageSearchCriteria, {
4046
- receivedAfter,
4047
- });
4048
- return ids.length >= expectedEmailCount;
4049
- },
4050
- timeout,
4051
- }));
4052
- if (!ids) {
4053
- if (shouldThrowErrorOnTimeout)
4054
- throw new Error("Timed out waiting for matching message");
4055
- return [];
4056
- }
4057
- return ids;
4058
- };
4059
- matchesCriteria(email, criteria) {
4060
- const { to, from, subject, body } = criteria;
4061
- if (to && !email.to.some(r => r.email.toLowerCase() === to.toLowerCase())) {
4062
- return false;
3513
+ matchesCriteria(email, criteria) {
3514
+ const { to, from, subject, body } = criteria;
3515
+ if (to && !email.to.some(r => r.email.toLowerCase() === to.toLowerCase())) {
3516
+ return false;
4063
3517
  }
4064
3518
  if (from &&
4065
3519
  !email.from.some(s => s.email.toLowerCase() === from.toLowerCase())) {
@@ -4076,93 +3530,6 @@ class MailerUtils {
4076
3530
  }
4077
3531
  return true;
4078
3532
  }
4079
- findMessage = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4080
- if (IS_DEV_ENV) {
4081
- return this.railsEmailUtils.findMessage(messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
4082
- }
4083
- const ids = await this.getEmailIds(messageSearchCriteria, { expectedEmailCount, receivedAfter, timeout }, shouldThrowErrorOnTimeout);
4084
- const emails = await this.getEmails(ids);
4085
- const filteredEmails = emails.filter(email => this.matchesCriteria(email, messageSearchCriteria));
4086
- return filteredEmails[0] || {};
4087
- };
4088
- findOtpFromEmail = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 2 * 60 * 1000, receivedAfter = new Date(Date.now() - 3000), expectedEmailCount = 1, }) => {
4089
- if (IS_DEV_ENV) {
4090
- return this.railsEmailUtils.findOtpFromEmail({
4091
- email,
4092
- subjectSubstring,
4093
- receivedAfter,
4094
- expectedEmailCount,
4095
- timeout: timeout / 3,
4096
- });
4097
- }
4098
- if (!this.accountId) {
4099
- await this.fastmailApi.authorizeAndSetAccountId();
4100
- }
4101
- const { html: { codes }, } = await this.findMessage({ to: email, subject: subjectSubstring }, { timeout, receivedAfter, expectedEmailCount });
4102
- return codes?.[0];
4103
- };
4104
- generateRandomEmail = () => faker.internet.email({ provider: process.env.FASTMAIL_DOMAIN_NAME });
4105
- getLatestMessageId = async (subject, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), } = {}) => {
4106
- if (IS_DEV_ENV) {
4107
- return this.railsEmailUtils.getLatestMessageId(subject, {
4108
- timeout: timeout / 3,
4109
- receivedAfter,
4110
- });
4111
- }
4112
- if (!this.accountId) {
4113
- await this.fastmailApi.authorizeAndSetAccountId();
4114
- }
4115
- const messageId = (await this.neetoPlaywrightUtilities.executeRecursively({
4116
- callback: async () => {
4117
- const { methodResponses: [[, { ids }]], } = await this.fastmailApi.apiRequest("Email/query", {
4118
- filter: { subject, after: receivedAfter.toISOString() },
4119
- sort: [{ property: "receivedAt", isAscending: false }],
4120
- limit: 1,
4121
- });
4122
- const emailId = ids?.[0];
4123
- if (!emailId)
4124
- return null;
4125
- const { methodResponses: [[, { list }]], } = await this.fastmailApi.apiRequest("Email/get", {
4126
- ids: [emailId],
4127
- properties: ["messageId"],
4128
- });
4129
- const rawMessageId = list?.[0]?.messageId?.[0];
4130
- if (!rawMessageId)
4131
- return null;
4132
- return rawMessageId.replace(/^<|>$/g, "");
4133
- },
4134
- condition: async () => {
4135
- const { methodResponses: [[, { ids }]], } = await this.fastmailApi.apiRequest("Email/query", {
4136
- filter: { subject, after: receivedAfter.toISOString() },
4137
- limit: 1,
4138
- });
4139
- return ids.length >= 1;
4140
- },
4141
- timeout,
4142
- }));
4143
- return messageId || undefined;
4144
- };
4145
- getEmailAttachment = async ({ name, type }, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4146
- if (IS_DEV_ENV)
4147
- return this.railsEmailUtils.getEmailAttachment({ name, type }, messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
4148
- const { blobId, attachments: attachmentNameAndTypes } = await this.findMessage(messageSearchCriteria, { expectedEmailCount, receivedAfter, timeout }, shouldThrowErrorOnTimeout);
4149
- const attachment = attachmentNameAndTypes.find(att => {
4150
- const matchesName = name ? att.name?.includes(name) : true;
4151
- const matchesType = type ? att.type?.startsWith(type) : true;
4152
- return matchesName && matchesType;
4153
- });
4154
- if (!attachment)
4155
- throw new Error("No such attachment exists");
4156
- const emailAttachment = await this.fastmailApi.fetchAttachments(blobId, attachment.name);
4157
- const buffer = await emailAttachment.body();
4158
- const parsedEmail = await simpleParser(buffer);
4159
- const attachments = parsedEmail.attachments;
4160
- return attachments.find(att => {
4161
- const matchesName = name ? att.filename?.includes(name) : true;
4162
- const matchesType = type ? att.contentType?.startsWith(type) : true;
4163
- return matchesName && matchesType;
4164
- });
4165
- };
4166
3533
  toIdentifiers = (addresses) => {
4167
3534
  if (!addresses)
4168
3535
  return [];
@@ -4212,7 +3579,7 @@ class MailerUtils {
4212
3579
  warnOnNonMailpitRecipient = ({ to, }) => {
4213
3580
  const domain = mailpitDomainName().toLowerCase();
4214
3581
  if (to && !to.toLowerCase().endsWith(`@${domain}`))
4215
- console.warn(`MailerUtils V2 reads from Mailpit, but "${to}" is not on the Mailpit domain "${domain}". Unless mail for that address is relayed to Mailpit, this lookup will poll until it times out. Generate recipients with generateRandomEmailV2().`);
3582
+ console.warn(`MailerUtils reads from Mailpit, but "${to}" is not on the Mailpit domain "${domain}". Unless mail for that address is relayed to Mailpit, this lookup will poll until it times out. Generate recipients with generateRandomEmail().`);
4216
3583
  };
4217
3584
  queryMailpitEmails = async (messageSearchCriteria, { receivedAfter = dateTimeOneHourAgo(), page = 1, itemsPerPage = 50, }) => {
4218
3585
  if (itemsPerPage > 100 || itemsPerPage < 1)
@@ -4231,7 +3598,7 @@ class MailerUtils {
4231
3598
  return messages.filter(summary => new Date(summary.Created).valueOf() >= receivedAfter.valueOf() &&
4232
3599
  this.matchesSummaryCriteria(summary, messageSearchCriteria));
4233
3600
  };
4234
- getEmailsV2 = async (summaries) => {
3601
+ getEmails = async (summaries) => {
4235
3602
  const emails = await Promise.all(summaries.map(async (summary) => {
4236
3603
  const message = await this.mailpitApi.getMessage(summary.ID);
4237
3604
  return message && this.toFormattedList(summary, message);
@@ -4246,7 +3613,7 @@ class MailerUtils {
4246
3613
  condition: async () => {
4247
3614
  const candidates = await this.queryMailpitEmails(messageSearchCriteria, { receivedAfter });
4248
3615
  if (requiresBodyMatch) {
4249
- const emails = await this.getEmailsV2(candidates);
3616
+ const emails = await this.getEmails(candidates);
4250
3617
  const matchedIds = new Set(emails
4251
3618
  .filter(email => this.matchesCriteria(email, messageSearchCriteria))
4252
3619
  .map(({ id }) => id));
@@ -4261,16 +3628,16 @@ class MailerUtils {
4261
3628
  });
4262
3629
  return summaries === false ? null : summaries;
4263
3630
  };
4264
- listMessagesV2 = async (messageSearchCriteria = {}, listMessagesFilterCriteria = {}) => {
3631
+ listMessages = async (messageSearchCriteria = {}, listMessagesFilterCriteria = {}) => {
4265
3632
  if (IS_DEV_ENV) {
4266
3633
  return this.railsEmailUtils.listMessages(messageSearchCriteria, listMessagesFilterCriteria);
4267
3634
  }
4268
3635
  this.warnOnNonMailpitRecipient(messageSearchCriteria);
4269
3636
  const summaries = await this.queryMailpitEmails(messageSearchCriteria, listMessagesFilterCriteria);
4270
- const emails = await this.getEmailsV2(summaries);
3637
+ const emails = await this.getEmails(summaries);
4271
3638
  return emails.filter(email => this.matchesCriteria(email, messageSearchCriteria));
4272
3639
  };
4273
- getEmailIdsV2 = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
3640
+ getEmailIds = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4274
3641
  if (IS_DEV_ENV) {
4275
3642
  const emails = await this.railsEmailUtils.listMessages(messageSearchCriteria, { receivedAfter });
4276
3643
  return emails.map(({ id }) => id);
@@ -4284,7 +3651,7 @@ class MailerUtils {
4284
3651
  }
4285
3652
  return summaries.map(({ ID }) => ID);
4286
3653
  };
4287
- findMessageV2 = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
3654
+ findMessage = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4288
3655
  if (IS_DEV_ENV) {
4289
3656
  return this.railsEmailUtils.findMessage(messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
4290
3657
  }
@@ -4295,11 +3662,11 @@ class MailerUtils {
4295
3662
  throw mailpitTimeoutError(messageSearchCriteria, receivedAfter, expectedEmailCount);
4296
3663
  return {};
4297
3664
  }
4298
- const emails = await this.getEmailsV2(summaries);
3665
+ const emails = await this.getEmails(summaries);
4299
3666
  const filteredEmails = emails.filter(email => this.matchesCriteria(email, messageSearchCriteria));
4300
3667
  return filteredEmails[0] || {};
4301
3668
  };
4302
- findOtpFromEmailV2 = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 2 * 60 * 1000, receivedAfter = new Date(Date.now() - 3000), expectedEmailCount = 1, }) => {
3669
+ findOtpFromEmail = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 2 * 60 * 1000, receivedAfter = new Date(Date.now() - 3000), expectedEmailCount = 1, }) => {
4303
3670
  if (IS_DEV_ENV) {
4304
3671
  return this.railsEmailUtils.findOtpFromEmail({
4305
3672
  email,
@@ -4309,17 +3676,17 @@ class MailerUtils {
4309
3676
  timeout: timeout / 3,
4310
3677
  });
4311
3678
  }
4312
- const message = await this.findMessageV2({ to: email, subject: subjectSubstring }, { timeout, receivedAfter, expectedEmailCount });
3679
+ const message = await this.findMessage({ to: email, subject: subjectSubstring }, { timeout, receivedAfter, expectedEmailCount });
4313
3680
  return message.html?.codes?.[0];
4314
3681
  };
4315
- generateRandomEmailV2 = () => {
3682
+ generateRandomEmail = () => {
4316
3683
  const domain = mailpitDomainName();
4317
3684
  const [localPart] = faker.internet
4318
3685
  .email({ provider: domain, allowSpecialCharacters: false })
4319
3686
  .split("@");
4320
3687
  return `${localPart}.${faker.string.alpha(8).toLowerCase()}@${domain}`;
4321
3688
  };
4322
- getLatestMessageIdV2 = async (subject, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), } = {}) => {
3689
+ getLatestMessageId = async (subject, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), } = {}) => {
4323
3690
  if (IS_DEV_ENV) {
4324
3691
  return this.railsEmailUtils.getLatestMessageId(subject, {
4325
3692
  timeout: timeout / 3,
@@ -4330,10 +3697,10 @@ class MailerUtils {
4330
3697
  const messageId = summaries?.[0]?.MessageID;
4331
3698
  return messageId ? messageId.replace(/^<|>$/g, "") : undefined;
4332
3699
  };
4333
- getEmailAttachmentV2 = async ({ name, type }, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
3700
+ getEmailAttachment = async ({ name, type }, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4334
3701
  if (IS_DEV_ENV)
4335
3702
  return this.railsEmailUtils.getEmailAttachment({ name, type }, messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
4336
- const { id } = await this.findMessageV2(messageSearchCriteria, { expectedEmailCount, receivedAfter, timeout }, shouldThrowErrorOnTimeout);
3703
+ const { id } = await this.findMessage(messageSearchCriteria, { expectedEmailCount, receivedAfter, timeout }, shouldThrowErrorOnTimeout);
4337
3704
  const rawMessage = id ? await this.mailpitApi.fetchRawMessage(id) : null;
4338
3705
  if (!rawMessage)
4339
3706
  throw new Error("No such attachment exists");
@@ -4500,74 +3867,11 @@ class ColorPickerUtils {
4500
3867
  await expect(colorPickerInput).toBeHidden();
4501
3868
  }).toPass({ timeout: 40_000 });
4502
3869
  };
4503
- hexToRGBA = (hex) => {
4504
- let r = 0, g = 0, b = 0, a = 1;
4505
- if (hex.length === 5) {
4506
- r = parseInt(`${hex[1]}${hex[1]}`, 16);
4507
- g = parseInt(`${hex[2]}${hex[2]}`, 16);
4508
- b = parseInt(`${hex[3]}${hex[3]}`, 16);
4509
- a = parseInt(`${hex[4]}${hex[4]}`, 16) / 255;
4510
- }
4511
- else if (hex.length === 9) {
4512
- r = parseInt(`${hex[1]}${hex[2]}`, 16);
4513
- g = parseInt(`${hex[3]}${hex[4]}`, 16);
4514
- b = parseInt(`${hex[5]}${hex[6]}`, 16);
4515
- a = parseInt(`${hex[7]}${hex[8]}`, 16) / 255;
4516
- }
4517
- return `rgba(${r}, ${g}, ${b}, ${a.toFixed(2)})`;
4518
- };
3870
+ hexToRGBA = hexToRGBA;
4519
3871
  }
4520
3872
 
4521
- const STATIC_ASSET_PATTERN = /\.(js|css|woff2?|ttf|eot|png|svg|ico|gif|webp)(\?.*)?$/;
4522
- const EXCLUDED_RESPONSE_HEADERS = [
4523
- "content-encoding",
4524
- "content-length",
4525
- "transfer-encoding",
4526
- ];
4527
- const assetCache = new Map();
4528
3873
  const commands = {
4529
- context: async ({ context }, use) => {
4530
- if (IS_DEV_ENV && IS_CI && !IS_PLAYWRIGHT_RUN) {
4531
- await context.route(STATIC_ASSET_PATTERN, async (route) => {
4532
- const url = route.request().url();
4533
- const hit = assetCache.get(url);
4534
- if (hit)
4535
- return route.fulfill(hit);
4536
- try {
4537
- // Use Node's native fetch instead of route.fetch() to keep these
4538
- // requests out of the Playwright trace's Actions tab. Forward the
4539
- // browser's request headers so cookie/session-scoped assets still
4540
- // resolve; drop accept-encoding so we only get encodings Node can
4541
- // decode, and HTTP/2 pseudo-headers which fetch rejects.
4542
- const requestHeaders = Object.entries(await route.request().allHeaders()).filter(([name]) => name !== "accept-encoding" && !name.startsWith(":"));
4543
- const response = await fetch(url, {
4544
- headers: Object.fromEntries(requestHeaders),
4545
- });
4546
- const body = Buffer.from(await response.arrayBuffer());
4547
- // Node's fetch decompresses the body but keeps the original
4548
- // content-encoding/content-length headers; drop them so the
4549
- // browser doesn't try to decode the already-decoded body.
4550
- const headers = {};
4551
- response.headers.forEach((value, key) => {
4552
- if (!EXCLUDED_RESPONSE_HEADERS.includes(key))
4553
- headers[key] = value;
4554
- });
4555
- const entry = { body, status: response.status, headers };
4556
- if (response.ok)
4557
- assetCache.set(url, entry);
4558
- return route.fulfill(entry);
4559
- }
4560
- catch {
4561
- return route.continue();
4562
- }
4563
- });
4564
- }
4565
- await use(context);
4566
- },
4567
- neetoPlaywrightUtilities: async ({ page, request, baseURL }, use) => {
4568
- const commands = new CustomCommands(page, request, baseURL);
4569
- await use(commands);
4570
- },
3874
+ neetoPlaywrightUtilities: ({ page, request, baseURL }, use) => use(new CustomCommands(page, request, baseURL)),
4571
3875
  page: async ({ page }, use) => {
4572
3876
  await page.goto("/");
4573
3877
  await page.waitForLoadState();
@@ -4575,8 +3879,6 @@ const commands = {
4575
3879
  },
4576
3880
  mailerUtils: async ({ neetoPlaywrightUtilities }, use) => {
4577
3881
  const mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
4578
- if (!IS_MAILPIT_ENABLED)
4579
- await mailerUtils.fastmailApi.authorizeAndSetAccountId();
4580
3882
  await use(mailerUtils);
4581
3883
  IS_DEV_ENV && (await mailerUtils.railsEmailUtils.clearStaleEmails());
4582
3884
  },
@@ -4593,18 +3895,9 @@ const commands = {
4593
3895
  }
4594
3896
  }
4595
3897
  },
4596
- colorPicker: async ({ page }, use) => {
4597
- const colorPicker = new ColorPickerUtils(page);
4598
- await use(colorPicker);
4599
- },
4600
- qrCodeUtils: async ({ page }, use) => {
4601
- const qrCodeUtils = new QRCodeUtils(page);
4602
- await use(qrCodeUtils);
4603
- },
4604
- health: async ({ page, neetoPlaywrightUtilities }, use) => {
4605
- const health = new Health(page, neetoPlaywrightUtilities);
4606
- await use(health);
4607
- },
3898
+ colorPicker: ({ page }, use) => use(new ColorPickerUtils(page)),
3899
+ qrCodeUtils: ({ page }, use) => use(new QRCodeUtils(page)),
3900
+ health: ({ page, neetoPlaywrightUtilities }, use) => use(new Health(page, neetoPlaywrightUtilities)),
4608
3901
  };
4609
3902
 
4610
3903
  const loadPlaywrightExtra = () => import('playwright-extra');
@@ -4935,8 +4228,8 @@ class EmbedBase {
4935
4228
  const showIconCheckbox = this.page.getByTestId(EMBED_SELECTORS.showIconCheckbox);
4936
4229
  if (isPresent(customizationOptions.showIcon)) {
4937
4230
  const shouldShowIcon = customizationOptions.showIcon;
4938
- const showIconAction = shouldShowIcon ? "check" : "uncheck";
4939
- await showIconCheckbox[showIconAction]();
4231
+ (await showIconCheckbox.isChecked()) !== shouldShowIcon &&
4232
+ (await showIconCheckbox.click());
4940
4233
  await expect(this.codeBlock).toContainText(`showIcon: ${shouldShowIcon}`);
4941
4234
  }
4942
4235
  await this.expectMultipleTextsInCodeblock([
@@ -4949,9 +4242,11 @@ class EmbedBase {
4949
4242
  const floatingButton = this.page.getByRole("button", {
4950
4243
  name: customizationOptions.buttonText,
4951
4244
  });
4952
- const classRegExp = customizationOptions.buttonPosition
4953
- .toLocaleLowerCase()
4954
- .replace(" ", ".*");
4245
+ const [vertical, horizontal] = customizationOptions.buttonPosition
4246
+ .toLowerCase()
4247
+ .split(" ");
4248
+ const logicalSide = horizontal === "left" ? "start" : "end";
4249
+ const classRegExp = `${vertical}-0.*${logicalSide}-0|${vertical}.*${horizontal}`;
4955
4250
  await Promise.all([
4956
4251
  expect(floatingButton).toHaveClass(RegExp(classRegExp)),
4957
4252
  expect(floatingButton).toHaveCSS("background-color", hexToRGB(customizationOptions.buttonColorHex)),
@@ -5019,7 +4314,7 @@ class HelpAndProfilePage {
5019
4314
  const floatingActionMenuBtn = this.page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton);
5020
4315
  await expect(async () => {
5021
4316
  await floatingActionMenuBtn.scrollIntoViewIfNeeded();
5022
- await floatingActionMenuBtn.hover();
4317
+ await floatingActionMenuBtn.click();
5023
4318
  await expect(this.helpMenuBtn).toBeVisible();
5024
4319
  }).toPass({ timeout: 60_000 });
5025
4320
  };
@@ -5105,28 +4400,28 @@ class HelpAndProfilePage {
5105
4400
  await this.page
5106
4401
  .getByTestId(HELP_CENTER_SELECTORS.keyboardShortcutButton)
5107
4402
  .click();
5108
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "1px");
4403
+ await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5109
4404
  await this.page
5110
4405
  .getByTestId(KEYBOARD_SHORTCUTS_SELECTORS.closePaneButton)
5111
4406
  .click();
5112
- await expect(keyboardShortcutsPane).toHaveCSS("width", "1px");
4407
+ await expect(keyboardShortcutsPane).toHaveCSS("width", "0px");
5113
4408
  });
5114
4409
  await test.step("3: Open and close keyboard shortcuts through shortcut", async () => {
5115
4410
  await this.page.keyboard.press(openKeyboardShortcut);
5116
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "1px");
4411
+ await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5117
4412
  await this.page.keyboard.press("Escape");
5118
- await expect(keyboardShortcutsPane).toHaveCSS("width", "1px");
4413
+ await expect(keyboardShortcutsPane).toHaveCSS("width", "0px");
5119
4414
  });
5120
4415
  await test.step("4: Verify all displayed keyboard shortcuts", async () => {
5121
4416
  await this.page.keyboard.press(openKeyboardShortcut);
5122
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "1px");
4417
+ await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5123
4418
  await Promise.all([
5124
- expect(keyItem.locator("p")).toHaveText(shortcuts.map(shortcut => shortcut.description)),
4419
+ expect(keyItem.getByTestId(COMMON_SELECTORS.hotkeyDescription)).toHaveText(shortcuts.map(shortcut => shortcut.description)),
5125
4420
  expect(keyItem.locator("div")).toHaveText(formattedSequences),
5126
4421
  ]);
5127
4422
  });
5128
4423
  };
5129
- openAppSwitcher = () => this.page.getByTestId(COMMON_SELECTORS.appSwitcherButton).hover();
4424
+ openAppSwitcher = () => this.page.getByTestId(COMMON_SELECTORS.appSwitcherButton).click();
5130
4425
  openAppSwitcherAndVerify = async () => {
5131
4426
  const productName = "Cal";
5132
4427
  const searchQueryPartial = productName.slice(0, 1).toLowerCase();
@@ -5166,18 +4461,21 @@ class HelpAndProfilePage {
5166
4461
  });
5167
4462
  });
5168
4463
  };
5169
- openAuthLinkAndVerify = async ({ linkTestId, redirectLink, }) => {
5170
- await this.page
5171
- .getByTestId(COMMON_SELECTORS.pane)
5172
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
5173
- .click();
4464
+ openAuthLinkAndVerify = async ({ linkTestId, redirectLink, appPath, }) => {
5174
4465
  await this.page
5175
- .getByTestId(COMMON_SELECTORS.dropdownContainer)
5176
- .getByTestId(linkTestId)
4466
+ .getByTestId(PROFILE_SECTION_SELECTORS.profileMoreDropdownButton)
5177
4467
  .click();
5178
- await expect(this.page).toHaveURL(new RegExp(NEETO_AUTH_BASE_URL(readFileSyncIfExists()?.user?.subdomainName)));
5179
- await expect(this.page).toHaveURL(new RegExp(redirectLink));
5180
- await this.page.goBack();
4468
+ const appUrl = this.page.url();
4469
+ await Promise.all([
4470
+ this.page.waitForRequest(request => new URL(request.url()).pathname === appPath),
4471
+ this.page.getByTestId(linkTestId).click(),
4472
+ ]);
4473
+ // NeetoAuth runs only on staging
4474
+ if (IS_STAGING_ENV) {
4475
+ await expect(this.page).toHaveURL(new RegExp(NEETO_AUTH_BASE_URL(readFileSyncIfExists()?.user?.subdomainName)));
4476
+ await expect(this.page).toHaveURL(new RegExp(redirectLink));
4477
+ }
4478
+ await this.page.goto(appUrl);
5181
4479
  };
5182
4480
  fillTextFields = async ({ firstName, lastName, phoneNumber, }) => {
5183
4481
  const firstNameField = this.page.getByTestId(PROFILE_SECTION_SELECTORS.firstNameTextField);
@@ -5218,9 +4516,10 @@ class HelpAndProfilePage {
5218
4516
  });
5219
4517
  };
5220
4518
  uploadImage = async (imageName) => {
4519
+ if (!IS_STAGING_ENV)
4520
+ return; // Image upload needs ImageKit, which is configured only on staging
5221
4521
  await this.page
5222
- .getByTestId(COMMON_SELECTORS.paneBody)
5223
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
4522
+ .getByTestId(PROFILE_SECTION_SELECTORS.profileImageDropdownButton)
5224
4523
  .click();
5225
4524
  await this.page
5226
4525
  .getByTestId(PROFILE_SECTION_SELECTORS.imageUploadBtn)
@@ -5229,12 +4528,12 @@ class HelpAndProfilePage {
5229
4528
  fileNameWithType: `images/${imageName}`,
5230
4529
  droppableZone: this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.fileInput),
5231
4530
  });
5232
- await expect(this.page.getByTestId(COMMON_SELECTORS.modalHeader)).toBeHidden({ timeout: 10_000 });
4531
+ await expect(this.page.getByTestId(COMMON_SELECTORS.dialogHeader)).toBeHidden({ timeout: 10_000 });
5233
4532
  await expect(this.page.getByTestId(COMMON_SELECTORS.avatar).locator("img")).toHaveAttribute("src", imageRegex(imageName));
5234
4533
  };
5235
4534
  updateBasicInfo = async ({ contact, settings, imageName, }) => {
5236
4535
  await expect(this.page
5237
- .getByTestId(COMMON_SELECTORS.pane)
4536
+ .getByTestId(COMMON_SELECTORS.sheetBody)
5238
4537
  .getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden();
5239
4538
  await this.uploadImage(imageName);
5240
4539
  await this.fillTextFields(contact);
@@ -5244,7 +4543,7 @@ class HelpAndProfilePage {
5244
4543
  .or(this.page.getByTestId(PROFILE_SECTION_SELECTORS.profileSubmitBtn))
5245
4544
  .click();
5246
4545
  await this.neetoPlaywrightUtilities.waitForPageLoad();
5247
- await expect(this.page.getByTestId(COMMON_SELECTORS.paneModalCrossIcon)).toBeHidden();
4546
+ await expect(this.page.getByTestId(COMMON_SELECTORS.sheetCloseButton)).toBeHidden();
5248
4547
  };
5249
4548
  openProfile = async () => {
5250
4549
  await this.openHelpCenter();
@@ -5254,7 +4553,7 @@ class HelpAndProfilePage {
5254
4553
  await this.page
5255
4554
  .getByTestId(PROFILE_SECTION_SELECTORS.myProfileButton)
5256
4555
  .click();
5257
- await expect(this.page.getByTestId(COMMON_SELECTORS.paneHeader)).toContainText(this.t("neetoTeamMembers.profile.common.myProfile"));
4556
+ await expect(this.page.getByTestId(COMMON_SELECTORS.sheetHeader)).toContainText(this.t("neetoTeamMembers.profile.common.myProfile"));
5258
4557
  };
5259
4558
  verifyProfileSidePane = async ({ contact, settings, imageName, }) => {
5260
4559
  const timeZone = settings?.timeZone;
@@ -5302,8 +4601,7 @@ class HelpAndProfilePage {
5302
4601
  await test.step("3: Verify basic info", async () => {
5303
4602
  await this.openProfile();
5304
4603
  await this.page
5305
- .getByTestId(COMMON_SELECTORS.pane)
5306
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
4604
+ .getByTestId(PROFILE_SECTION_SELECTORS.profileMoreDropdownButton)
5307
4605
  .click();
5308
4606
  await this.page
5309
4607
  .getByTestId(PROFILE_SECTION_SELECTORS.editBasicInfoMenuBtn)
@@ -5336,26 +4634,6 @@ class HelpAndProfilePage {
5336
4634
  await workspacePage.close();
5337
4635
  });
5338
4636
  };
5339
- /**
5340
- * @deprecated This method is deprecated. Use verifyWorkspace instead.
5341
- */
5342
- verifyProfileAndOrganizationLinks = async () => {
5343
- await test.step("1: Open Help center and verify", this.openHelpCenter);
5344
- await test.step("2: Open My organization link and verify", async () => {
5345
- await this.page
5346
- .getByTestId(PROFILE_SECTION_SELECTORS.workspaceDisplay)
5347
- .click();
5348
- const [workspacePage] = await Promise.all([
5349
- this.page.waitForEvent("popup"),
5350
- this.page
5351
- .getByTestId(PROFILE_SECTION_SELECTORS.profileOrganizationSettingsButton)
5352
- .click(),
5353
- ]);
5354
- await workspacePage.waitForLoadState();
5355
- await expect(workspacePage).toHaveURL(new RegExp(ROUTES.auth.adminPanel));
5356
- await workspacePage.close();
5357
- });
5358
- };
5359
4637
  openAndVerifyStatus = async () => {
5360
4638
  await test.step("1: Open Help Center links", this.openHelpCenter);
5361
4639
  await test.step("2: Open and verify status page", async () => {
@@ -5438,208 +4716,74 @@ class HelpAndProfilePage {
5438
4716
  });
5439
4717
  };
5440
4718
  }
5441
- class HelpAndProfilePageV2 extends HelpAndProfilePage {
5442
- openAppSwitcher = () => this.page.getByTestId(COMMON_SELECTORS.appSwitcherButton).click();
5443
- openHelpCenter = async () => {
5444
- const floatingActionMenuBtn = this.page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton);
5445
- await expect(async () => {
5446
- await floatingActionMenuBtn.scrollIntoViewIfNeeded();
5447
- await floatingActionMenuBtn.click();
5448
- await expect(this.helpMenuBtn).toBeVisible();
5449
- }).toPass({ timeout: 60_000 });
5450
- };
5451
- openAndVerifyKeyboardShortcutsPane = async (productShortcuts, osPlatform = "windows") => {
5452
- const keyboardShortcutsPane = this.page.getByTestId(KEYBOARD_SHORTCUTS_SELECTORS.keyboardShortcutsPane);
5453
- const keyItem = this.page.getByTestId(KEYBOARD_SHORTCUTS_SELECTORS.hotKeyItem);
5454
- const openKeyboardShortcut = osPlatform === "mac" ? "Meta+/" : "Control+/";
5455
- const shortcuts = [...globalShortcuts(this.t), ...productShortcuts];
5456
- const formattedSequences = shortcuts.map(shortcut => this.formatKeyboardShortcut(shortcut.sequence, osPlatform));
5457
- await test.step("1: Open Help Center", this.openHelpCenter);
5458
- await test.step("2: Open and close keyboard shortcuts from UI", async () => {
5459
- await this.page
5460
- .getByTestId(HELP_CENTER_SELECTORS.keyboardShortcutButton)
5461
- .click();
5462
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5463
- await this.page
5464
- .getByTestId(KEYBOARD_SHORTCUTS_SELECTORS.closePaneButton)
5465
- .click();
5466
- await expect(keyboardShortcutsPane).toHaveCSS("width", "0px");
5467
- });
5468
- await test.step("3: Open and close keyboard shortcuts through shortcut", async () => {
5469
- await this.page.keyboard.press(openKeyboardShortcut);
5470
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5471
- await this.page.keyboard.press("Escape");
5472
- await expect(keyboardShortcutsPane).toHaveCSS("width", "0px");
4719
+
4720
+ class MicrosoftPage extends IntegrationBase {
4721
+ totp;
4722
+ mailerUtils;
4723
+ constructor({ page, neetoPlaywrightUtilities, integrationRouteIndex, integration = "", }) {
4724
+ super({
4725
+ page,
4726
+ neetoPlaywrightUtilities,
4727
+ integrationRouteIndex,
4728
+ integration,
5473
4729
  });
5474
- await test.step("4: Verify all displayed keyboard shortcuts", async () => {
5475
- await this.page.keyboard.press(openKeyboardShortcut);
5476
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5477
- await Promise.all([
5478
- expect(keyItem.getByTestId(COMMON_SELECTORS.hotkeyDescription)).toHaveText(shortcuts.map(shortcut => shortcut.description)),
5479
- expect(keyItem.locator("div")).toHaveText(formattedSequences),
5480
- ]);
4730
+ this.mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
4731
+ this.totp = initializeTotp({
4732
+ issuer: "Microsoft",
4733
+ secret: process.env.MICROSOFT_2FA_SECRET_KEY,
5481
4734
  });
5482
- };
5483
- openAuthLinkAndVerify = async ({ linkTestId, redirectLink, appPath, }) => {
4735
+ }
4736
+ stagingConsentFlow = async (abortFlow = false) => {
4737
+ await this.page.waitForLoadState("load", { timeout: 25_000 });
4738
+ await expect(this.page.getByRole("heading", {
4739
+ name: MICROSOFT_LOGIN_TEXTS.permissionsRequested,
4740
+ })).toBeVisible({ timeout: 20_000 });
5484
4741
  await this.page
5485
- .getByTestId(PROFILE_SECTION_SELECTORS.profileMoreDropdownButton)
4742
+ .locator(abortFlow
4743
+ ? MICROSOFT_LOGIN_SELECTORS.cancelButton
4744
+ : MICROSOFT_LOGIN_SELECTORS.acceptButton)
5486
4745
  .click();
5487
- const appUrl = this.page.url();
5488
- await Promise.all([
5489
- this.page.waitForRequest(request => new URL(request.url()).pathname === appPath),
5490
- this.page.getByTestId(linkTestId).click(),
5491
- ]);
5492
- // NeetoAuth runs only on staging
5493
- if (IS_STAGING_ENV) {
5494
- await expect(this.page).toHaveURL(new RegExp(NEETO_AUTH_BASE_URL(readFileSyncIfExists()?.user?.subdomainName)));
5495
- await expect(this.page).toHaveURL(new RegExp(redirectLink));
5496
- }
5497
- await this.page.goto(appUrl);
4746
+ await this.page.waitForLoadState("load", { timeout: 25_000 });
4747
+ await this.neetoPlaywrightUtilities.waitForFloatingMenu();
5498
4748
  };
5499
- uploadImage = async (imageName) => {
5500
- if (!IS_STAGING_ENV)
5501
- return; // Image upload needs ImageKit, which is configured only on staging
5502
- await this.page
5503
- .getByTestId(PROFILE_SECTION_SELECTORS.profileImageDropdownButton)
5504
- .click();
4749
+ enterEmail = async (email) => {
4750
+ await this.page.waitForLoadState("load", { timeout: 25_000 });
4751
+ await expect(this.page.getByRole("heading", { name: MICROSOFT_LOGIN_TEXTS.signIn })).toBeVisible({ timeout: 20_000 });
5505
4752
  await this.page
5506
- .getByTestId(PROFILE_SECTION_SELECTORS.imageUploadBtn)
5507
- .click();
5508
- await this.neetoPlaywrightUtilities.uploadFileViaDispatch({
5509
- fileNameWithType: `images/${imageName}`,
5510
- droppableZone: this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.fileInput),
5511
- });
5512
- await expect(this.page.getByTestId(COMMON_SELECTORS.dialogHeader)).toBeHidden({ timeout: 10_000 });
5513
- await expect(this.page.getByTestId(COMMON_SELECTORS.avatar).locator("img")).toHaveAttribute("src", imageRegex(imageName));
4753
+ .locator(MICROSOFT_LOGIN_SELECTORS.emailInput)
4754
+ .or(this.page.locator(MICROSOFT_LOGIN_SELECTORS.placeholder))
4755
+ .or(this.page.getByRole("textbox", {
4756
+ name: MICROSOFT_LOGIN_TEXTS.emailInput,
4757
+ }))
4758
+ .pressSequentially(email, { delay: 25 });
5514
4759
  };
5515
- updateBasicInfo = async ({ contact, settings, imageName, }) => {
5516
- await expect(this.page
5517
- .getByTestId(COMMON_SELECTORS.sheetBody)
5518
- .getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden();
5519
- await this.uploadImage(imageName);
5520
- await this.fillTextFields(contact);
5521
- await this.selectDropdownFields(settings);
4760
+ enterPassword = async (password) => {
4761
+ await this.page.waitForLoadState("load", { timeout: 25_000 });
4762
+ await expect(this.page.getByRole("heading", {
4763
+ name: MICROSOFT_LOGIN_TEXTS.enterPassword,
4764
+ })).toBeVisible({ timeout: 10_000 });
5522
4765
  await this.page
5523
- .getByTestId(PROFILE_SECTION_SELECTORS.submitButton)
5524
- .or(this.page.getByTestId(PROFILE_SECTION_SELECTORS.profileSubmitBtn))
5525
- .click();
5526
- await this.neetoPlaywrightUtilities.waitForPageLoad();
5527
- await expect(this.page.getByTestId(COMMON_SELECTORS.sheetCloseButton)).toBeHidden();
5528
- };
5529
- openProfile = async () => {
5530
- await this.openHelpCenter();
5531
- await this.page
5532
- .getByTestId(PROFILE_SECTION_SELECTORS.profileExpandMenuBtn)
5533
- .click();
5534
- await this.page
5535
- .getByTestId(PROFILE_SECTION_SELECTORS.myProfileButton)
5536
- .click();
5537
- await expect(this.page.getByTestId(COMMON_SELECTORS.sheetHeader)).toContainText(this.t("neetoTeamMembers.profile.common.myProfile"));
5538
- };
5539
- verifyProfile = async () => {
5540
- await test.step("1: Open Manage billing and subscriptions link and verify", async () => {
5541
- await this.openProfile();
5542
- await this.openAuthLinkAndVerify({
5543
- redirectLink: ROUTES.myProfile,
5544
- appPath: ROUTES.auth.editBilling,
5545
- linkTestId: PROFILE_SECTION_SELECTORS.manageBillingAndSubscriptionsButton,
5546
- });
5547
- });
5548
- await test.step("2: Open Update email link and verify", async () => {
5549
- await this.openProfile();
5550
- await this.openAuthLinkAndVerify({
5551
- redirectLink: ROUTES.updateEmail,
5552
- appPath: ROUTES.auth.editEmail,
5553
- linkTestId: PROFILE_SECTION_SELECTORS.updateEmailMenuBtn,
5554
- });
5555
- });
5556
- await test.step("3: Verify basic info", async () => {
5557
- await this.openProfile();
5558
- await this.page
5559
- .getByTestId(PROFILE_SECTION_SELECTORS.profileMoreDropdownButton)
5560
- .click();
5561
- await this.page
5562
- .getByTestId(PROFILE_SECTION_SELECTORS.editBasicInfoMenuBtn)
5563
- .click();
5564
- const basicInfoParams = getBasicInfoTestData();
5565
- await this.updateBasicInfo(basicInfoParams);
5566
- await this.openProfile();
5567
- await this.verifyProfileSidePane(basicInfoParams);
5568
- });
5569
- };
5570
- }
5571
-
5572
- class MicrosoftPage extends IntegrationBase {
5573
- totp;
5574
- mailerUtils;
5575
- constructor({ page, neetoPlaywrightUtilities, integrationRouteIndex, integration = "", }) {
5576
- super({
5577
- page,
5578
- neetoPlaywrightUtilities,
5579
- integrationRouteIndex,
5580
- integration,
5581
- });
5582
- this.mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
5583
- this.totp = initializeTotp({
5584
- issuer: "Microsoft",
5585
- secret: process.env.MICROSOFT_2FA_SECRET_KEY,
5586
- });
5587
- }
5588
- stagingConsentFlow = async (abortFlow = false) => {
5589
- await this.page.waitForLoadState("load", { timeout: 25_000 });
5590
- await expect(this.page.getByRole("heading", {
5591
- name: MICROSOFT_LOGIN_TEXTS.permissionsRequested,
5592
- })).toBeVisible({ timeout: 20_000 });
5593
- await this.page
5594
- .locator(abortFlow
5595
- ? MICROSOFT_LOGIN_SELECTORS.cancelButton
5596
- : MICROSOFT_LOGIN_SELECTORS.acceptButton)
5597
- .click();
5598
- await this.page.waitForLoadState("load", { timeout: 25_000 });
5599
- await this.neetoPlaywrightUtilities.waitForFloatingMenu();
5600
- };
5601
- enterEmail = async () => {
5602
- await this.page.waitForLoadState("load", { timeout: 25_000 });
5603
- await expect(this.page.getByRole("heading", { name: MICROSOFT_LOGIN_TEXTS.signIn })).toBeVisible({ timeout: 20_000 });
5604
- await this.page
5605
- .locator(MICROSOFT_LOGIN_SELECTORS.emailInput)
5606
- .or(this.page.locator(MICROSOFT_LOGIN_SELECTORS.placeholder))
5607
- .or(this.page.getByRole("textbox", {
5608
- name: MICROSOFT_LOGIN_TEXTS.emailInput,
5609
- }))
5610
- .pressSequentially(process.env.MICROSOFT_LOGIN_EMAIL, { delay: 25 });
5611
- };
5612
- enterPassword = async () => {
5613
- await this.page.waitForLoadState("load", { timeout: 25_000 });
5614
- await expect(this.page.getByRole("heading", {
5615
- name: MICROSOFT_LOGIN_TEXTS.enterPassword,
5616
- })).toBeVisible({ timeout: 10_000 });
5617
- await this.page
5618
- .getByPlaceholder(MICROSOFT_LOGIN_TEXTS.password)
5619
- .or(this.page.locator(MICROSOFT_LOGIN_SELECTORS.placeholder))
5620
- .or(this.page.getByRole("textbox", {
5621
- name: MICROSOFT_LOGIN_TEXTS.passwordInput,
5622
- }))
5623
- .pressSequentially(process.env.MICROSOFT_LOGIN_PASSWORD, { delay: 15 });
4766
+ .getByPlaceholder(MICROSOFT_LOGIN_TEXTS.password)
4767
+ .or(this.page.locator(MICROSOFT_LOGIN_SELECTORS.placeholder))
4768
+ .or(this.page.getByRole("textbox", {
4769
+ name: MICROSOFT_LOGIN_TEXTS.passwordInput,
4770
+ }))
4771
+ .pressSequentially(password, { delay: 15 });
5624
4772
  };
5625
4773
  loginToMicrosoft = async () => {
5626
4774
  if (IS_DEV_ENV)
5627
4775
  return;
5628
4776
  return withCookieCache("microsoft", this.page.context(), async () => {
5629
- if (isNil(process.env.MICROSOFT_LOGIN_EMAIL) ||
5630
- isNil(process.env.MICROSOFT_LOGIN_PASSWORD) ||
5631
- isNil(process.env.MICROSOFT_2FA_SECRET_KEY)) {
5632
- throw new Error("ENV variable MICROSOFT_LOGIN_EMAIL or MICROSOFT_LOGIN_PASSWORD or MICROSOFT_2FA_SECRET_KEY is not properly configured");
5633
- }
4777
+ const env = requireEnv("MICROSOFT_LOGIN_EMAIL", "MICROSOFT_LOGIN_PASSWORD", "MICROSOFT_2FA_SECRET_KEY");
5634
4778
  const useVerificationCodeButton = this.page.getByRole("button", {
5635
4779
  name: MICROSOFT_LOGIN_TEXTS.useVerificationCode,
5636
4780
  });
5637
4781
  await this.page.goto(THIRD_PARTY_ROUTES.microsoft.login);
5638
- await this.enterEmail();
4782
+ await this.enterEmail(env.MICROSOFT_LOGIN_EMAIL);
5639
4783
  await this.page
5640
4784
  .getByRole("button", { name: MICROSOFT_LOGIN_TEXTS.next })
5641
4785
  .click();
5642
- await this.enterPassword();
4786
+ await this.enterPassword(env.MICROSOFT_LOGIN_PASSWORD);
5643
4787
  const signInButton = this.page.getByRole("button", {
5644
4788
  name: MICROSOFT_LOGIN_TEXTS.signIn,
5645
4789
  });
@@ -5830,33 +4974,27 @@ class SlackPage extends IntegrationBase {
5830
4974
  loginToSlackWebapp = async (slackWebappPage, customCredentials) => {
5831
4975
  this.slackWebappPage = slackWebappPage;
5832
4976
  this.slackWebappPageDataQa = getByDataQA(this.slackWebappPage);
5833
- const slackWorkspace = customCredentials?.workspace || process.env.SLACK_WORKSPACE;
5834
- const slackLoginPassword = customCredentials?.loginPassword || process.env.SLACK_LOGIN_PASSWORD;
5835
- const slackLoginEmail = customCredentials?.loginEmail || process.env.SLACK_LOGIN_EMAIL;
5836
- if (isNotNil(slackWorkspace) &&
5837
- isNotNil(slackLoginPassword) &&
5838
- isNotNil(slackLoginEmail)) {
5839
- await slackWebappPage.goto(THIRD_PARTY_ROUTES.slack.loginWithPassword(slackWorkspace), { timeout: 20_000 });
5840
- await slackWebappPage.waitForLoadState("load", { timeout: 25_000 });
5841
- await slackWebappPage
5842
- .locator(SLACK_SELECTORS.loginEmail)
5843
- .pressSequentially(slackLoginEmail, { delay: 10 });
5844
- await slackWebappPage
5845
- .locator(SLACK_SELECTORS.loginPassword)
5846
- .pressSequentially(slackLoginPassword, { delay: 10 });
5847
- await slackWebappPage
5848
- .locator(SLACK_SELECTORS.signInButton)
5849
- .click({ timeout: 35_000 });
5850
- await slackWebappPage.waitForLoadState("domcontentloaded", {
5851
- timeout: 25_000,
5852
- });
5853
- const redirectOpenInBrowser = slackWebappPage.locator(SLACK_SELECTORS.redirectOpenInBrowser);
5854
- await expect(redirectOpenInBrowser).toBeVisible({ timeout: 25_000 });
5855
- await redirectOpenInBrowser.click();
5856
- await this.setupCloseHandlers(slackWebappPage);
5857
- return;
5858
- }
5859
- throw new Error("ENV variable SLACK_LOGIN_EMAIL or SLACK_LOGIN_PASSWORD or SLACK_WORKSPACE is not defined.");
4977
+ const slackWorkspace = customCredentials?.workspace || requireEnv("SLACK_WORKSPACE");
4978
+ const slackLoginPassword = customCredentials?.loginPassword || requireEnv("SLACK_LOGIN_PASSWORD");
4979
+ const slackLoginEmail = customCredentials?.loginEmail || requireEnv("SLACK_LOGIN_EMAIL");
4980
+ await slackWebappPage.goto(THIRD_PARTY_ROUTES.slack.loginWithPassword(slackWorkspace), { timeout: 20_000 });
4981
+ await slackWebappPage.waitForLoadState("load", { timeout: 25_000 });
4982
+ await slackWebappPage
4983
+ .locator(SLACK_SELECTORS.loginEmail)
4984
+ .pressSequentially(slackLoginEmail, { delay: 10 });
4985
+ await slackWebappPage
4986
+ .locator(SLACK_SELECTORS.loginPassword)
4987
+ .pressSequentially(slackLoginPassword, { delay: 10 });
4988
+ await slackWebappPage
4989
+ .locator(SLACK_SELECTORS.signInButton)
4990
+ .click({ timeout: 35_000 });
4991
+ await slackWebappPage.waitForLoadState("domcontentloaded", {
4992
+ timeout: 25_000,
4993
+ });
4994
+ const redirectOpenInBrowser = slackWebappPage.locator(SLACK_SELECTORS.redirectOpenInBrowser);
4995
+ await expect(redirectOpenInBrowser).toBeVisible({ timeout: 25_000 });
4996
+ await redirectOpenInBrowser.click();
4997
+ await this.setupCloseHandlers(slackWebappPage);
5860
4998
  };
5861
4999
  logoutFromSlackWebApp = async () => {
5862
5000
  await this.slackWebappPage
@@ -5899,73 +5037,6 @@ class SlackPage extends IntegrationBase {
5899
5037
  };
5900
5038
  }
5901
5039
 
5902
- class WebhooksPage {
5903
- page;
5904
- neetoPlaywrightUtilities;
5905
- webhookSiteApi;
5906
- t;
5907
- constructor({ page, neetoPlaywrightUtilities }) {
5908
- this.page = page;
5909
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
5910
- this.t = getI18nInstance().t;
5911
- this.webhookSiteApi = new WebhookSiteApi(page.request);
5912
- }
5913
- getTokenViaAPI = async () => {
5914
- let webhookToken = null;
5915
- await expect(async () => {
5916
- const response = await this.webhookSiteApi.create();
5917
- await expect(response).toBeOK();
5918
- webhookToken = (await response.json())?.uuid;
5919
- }).toPass({ timeout: 15_000 });
5920
- if (!webhookToken)
5921
- throw new Error("Failed to get webhook token");
5922
- return {
5923
- webhookToken,
5924
- webhookSiteURL: `${THIRD_PARTY_ROUTES.webhooks.site}${webhookToken}`,
5925
- };
5926
- };
5927
- addWebhook = async ({ webhookSiteURL }) => {
5928
- await this.page.getByTestId(WEBHOOK_SELECTORS.addNewWebhook).click();
5929
- await this.page
5930
- .getByTestId(WEBHOOK_SELECTORS.endpointInputField)
5931
- .fill(webhookSiteURL);
5932
- await Promise.all([
5933
- this.page.getByTestId(COMMON_SELECTORS.saveChangesButton).click(),
5934
- this.neetoPlaywrightUtilities.verifyToast({
5935
- message: this.t("resource.add", {
5936
- entity: "webhook",
5937
- count: 1,
5938
- }),
5939
- }),
5940
- ]);
5941
- await expect(this.page.getByRole("row", { name: webhookSiteURL })).toBeVisible();
5942
- };
5943
- verifyLatestWebhookResponse = ({ callback = () => { }, webhookToken, parseFullResponseContent = false, timeout = 20_000, ...otherParams }) => expect(async () => {
5944
- const response = await this.webhookSiteApi.fetch(webhookToken);
5945
- await expect(response).toBeOK();
5946
- const { content } = await response.json();
5947
- const parsedResponse = parseFullResponseContent
5948
- ? JSON.parse(content)
5949
- : JSON.parse(content).webhook;
5950
- callback({ parsedResponse, ...otherParams });
5951
- }).toPass({ timeout });
5952
- verifyWebhookDeliveries = async ({ callback = () => { }, ...otherParams }) => {
5953
- await expect(this.page.getByTestId(WEBHOOK_SELECTORS.deliveryResponseCode)).toHaveText("200");
5954
- const requestPayload = (await this.page
5955
- .getByTestId(WEBHOOK_SELECTORS.deliveryRequestPayload)
5956
- .textContent());
5957
- const parsedResponse = JSON.parse(requestPayload).webhook;
5958
- callback({ parsedResponse, ...otherParams });
5959
- };
5960
- verifyWebhookDeliveryByEvent = async ({ event, callbackToVerifyDeliveries, ...fieldsToBeVerified }) => {
5961
- await this.page.getByRole("row", { name: event }).getByRole("link").click();
5962
- await this.verifyWebhookDeliveries({
5963
- callback: callbackToVerifyDeliveries,
5964
- ...fieldsToBeVerified,
5965
- });
5966
- };
5967
- }
5968
-
5969
5040
  const simulateTypingWithDelay = async ({ field, value, delay = 500, }) => {
5970
5041
  const minSliceLength = Math.max(3, Math.floor(value.length * 0.6));
5971
5042
  const maxSliceLength = Math.max(4, Math.floor(value.length * 0.8));
@@ -6005,6 +5076,9 @@ class ZapierPage extends IntegrationBase {
6005
5076
  zapierWebPage;
6006
5077
  continueButton;
6007
5078
  mailerUtils;
5079
+ zapId;
5080
+ zapierLoginEmail;
5081
+ zapierLoginPassword;
6008
5082
  stepBlock;
6009
5083
  navbar;
6010
5084
  zapToggle;
@@ -6018,15 +5092,14 @@ class ZapierPage extends IntegrationBase {
6018
5092
  neetoPlaywrightUtilities,
6019
5093
  integrationRouteIndex,
6020
5094
  });
6021
- if (isNil(process.env.ZAPIER_LOGIN_PASSWORD) ||
6022
- isNil(process.env.ZAPIER_LOGIN_EMAIL) ||
6023
- isNil(process.env.ZAP_ID)) {
6024
- throw new Error("ENV variable ZAPIER_LOGIN_PASSWORD or ZAPIER_LOGIN_EMAIL or ZAP_ID is not properly configured");
6025
- }
5095
+ const env = requireEnv("ZAPIER_LOGIN_EMAIL", "ZAPIER_LOGIN_PASSWORD", "ZAP_ID");
5096
+ this.zapierLoginEmail = env.ZAPIER_LOGIN_EMAIL;
5097
+ this.zapierLoginPassword = env.ZAPIER_LOGIN_PASSWORD;
5098
+ this.zapId = env.ZAP_ID;
6026
5099
  this.mailerUtils = mailerUtils;
6027
5100
  }
6028
5101
  gotoZapEditor = async () => {
6029
- await this.zapierWebPage.goto(THIRD_PARTY_ROUTES.zapier.zapEditor(process.env.ZAP_ID));
5102
+ await this.zapierWebPage.goto(THIRD_PARTY_ROUTES.zapier.zapEditor(this.zapId));
6030
5103
  await this.zapierWebPage.waitForLoadState();
6031
5104
  await expect(this.firstStepBlock).toBeVisible({ timeout: 25_000 });
6032
5105
  };
@@ -6136,16 +5209,16 @@ class ZapierPage extends IntegrationBase {
6136
5209
  });
6137
5210
  await simulateTypingWithDelay({
6138
5211
  field: emailField,
6139
- value: process.env.ZAPIER_LOGIN_EMAIL,
5212
+ value: this.zapierLoginEmail,
6140
5213
  });
6141
5214
  await simulateClickWithDelay({
6142
5215
  element: this.continueButton,
6143
5216
  page: zapierWebPage,
6144
5217
  });
6145
- await expect(zapierWebPage.getByText(ZAPIER_WEB_TEXTS.welcomeText(process.env.ZAPIER_LOGIN_EMAIL))).toBeVisible({ timeout: 15_000 });
5218
+ await expect(zapierWebPage.getByText(ZAPIER_WEB_TEXTS.welcomeText(this.zapierLoginEmail))).toBeVisible({ timeout: 15_000 });
6146
5219
  await simulateTypingWithDelay({
6147
5220
  field: passwordField,
6148
- value: process.env.ZAPIER_LOGIN_PASSWORD,
5221
+ value: this.zapierLoginPassword,
6149
5222
  });
6150
5223
  await simulateClickWithDelay({
6151
5224
  element: this.continueButton,
@@ -6161,9 +5234,7 @@ class ZapierPage extends IntegrationBase {
6161
5234
  });
6162
5235
  await this.zapierWebPage.close();
6163
5236
  };
6164
- verifyZapIsTriggered = ({ productName, submittedEmail, zapTriggeredAfter, timeout = 2 * 60_000, }) => IS_MAILPIT_ENABLED
6165
- ? this.mailerUtils.findMessageV2({ to: ZAPIER_TEST_EMAIL_V2(productName), body: submittedEmail }, { timeout, receivedAfter: zapTriggeredAfter })
6166
- : this.mailerUtils.findMessage({ to: ZAPIER_TEST_EMAIL(productName), body: submittedEmail }, { timeout, receivedAfter: zapTriggeredAfter });
5237
+ verifyZapIsTriggered = ({ productName, submittedEmail, zapTriggeredAfter, timeout = 2 * 60_000, }) => this.mailerUtils.findMessage({ to: ZAPIER_TEST_EMAIL(productName), body: submittedEmail }, { timeout, receivedAfter: zapTriggeredAfter });
6167
5238
  skipIfTaskLimitIsExhausted = async () => {
6168
5239
  // Zapier provides 100 free task limit for free account; skip test if it's exhausted
6169
5240
  const universalSidebar = this.zapierWebPage.locator(ZAPIER_SELECTORS.universalSidebar);
@@ -6219,111 +5290,6 @@ class ZapierPage extends IntegrationBase {
6219
5290
  await this.neetoPlaywrightUtilities.verifyToast({ message: toastMessage });
6220
5291
  await this.verifyIntegrationStatus("disconnected");
6221
5292
  };
6222
- generateAPIKey = async (apiKeyLabel) => {
6223
- await this.page.getByTestId(API_KEYS_SELECTORS.addApiKeyButton).click();
6224
- await this.page
6225
- .getByTestId(COMMON_SELECTORS.paneBody)
6226
- .getByTestId(COMMON_SELECTORS.customInputField("label"))
6227
- .fill(apiKeyLabel);
6228
- await this.page.getByTestId(COMMON_SELECTORS.radioInput("zapier")).check();
6229
- await this.neetoPlaywrightUtilities.saveChanges({ isPane: true });
6230
- await this.page
6231
- .getByRole("row", { name: apiKeyLabel })
6232
- .getByTestId(COMMON_SELECTORS.copyToClipboardButton)
6233
- .click();
6234
- return getClipboardContent(this.page);
6235
- };
6236
- }
6237
-
6238
- const MEMBER_PAGE_SIZE = 200;
6239
- const NAME_SYNC_WAIT = 5_000;
6240
- class Member {
6241
- memberApis;
6242
- constructor(neetoPlaywrightUtilities) {
6243
- this.memberApis = new MemberApis(neetoPlaywrightUtilities);
6244
- }
6245
- addMemberViaRequest = async ({ email, role = MEMBER_TEXTS.agent, appName, subscriptionPlan = "free", }) => {
6246
- let response;
6247
- await expect
6248
- .poll(async () => {
6249
- response = await this.memberApis.create({
6250
- emails: [email],
6251
- organization_role: role,
6252
- app_roles: [
6253
- { app_name: appName, active_role: role, is_enabled: true },
6254
- ],
6255
- subscription_plan: subscriptionPlan,
6256
- });
6257
- return response?.status();
6258
- }, { timeout: 30_000 })
6259
- .toBe(200);
6260
- const responseBodyBuffer = await response?.body();
6261
- const { job_id: jobId } = JSON.parse(String(responseBodyBuffer));
6262
- await expect
6263
- .poll(async () => {
6264
- const jobResponse = await this.memberApis.jobStatus(jobId);
6265
- const responseBodyBuffer = await jobResponse?.body();
6266
- const { is_completed: isCompleted, is_successful: isSuccessful, error, } = JSON.parse(String(responseBodyBuffer));
6267
- if (isCompleted && !isSuccessful) {
6268
- throw new Error(`Member creation failed: ${error}`);
6269
- }
6270
- return isCompleted;
6271
- }, { timeout: 60_000 })
6272
- .toBe(true);
6273
- };
6274
- editMemberViaRequest = async ({ email, newEmail, firstName, lastName, newRole, subscriptionPlan, }) => {
6275
- const findMember = async (isRequestedMember) => {
6276
- for (let page = 1;; page++) {
6277
- const { members } = (await this.memberApis
6278
- .fetch({ page, page_size: MEMBER_PAGE_SIZE })
6279
- .then(response => response?.json()));
6280
- const member = members.find(isRequestedMember);
6281
- if (member || members.length < MEMBER_PAGE_SIZE)
6282
- return member;
6283
- }
6284
- };
6285
- const memberDetails = await findMember(member => member.email.toLowerCase() === email.toLowerCase());
6286
- if (!memberDetails)
6287
- throw new Error(`Member ${email} was not found`);
6288
- await expect(async () => {
6289
- await this.memberApis.update(memberDetails.id, keysToSnakeCase({
6290
- active: true,
6291
- firstName,
6292
- lastName,
6293
- organizationRole: newRole,
6294
- email: newEmail,
6295
- subscriptionPlan,
6296
- }));
6297
- if (!firstName && !lastName)
6298
- return;
6299
- await new Promise(resolve => setTimeout(resolve, NAME_SYNC_WAIT));
6300
- const updatedMember = await findMember(({ id }) => id === memberDetails.id);
6301
- expect(updatedMember, `Member ${email} was not found`).toBeDefined();
6302
- firstName && expect(updatedMember?.first_name).toBe(firstName);
6303
- lastName && expect(updatedMember?.last_name).toBe(lastName);
6304
- }).toPass({ timeout: 60_000 });
6305
- };
6306
- deactivateMemberViaRequest = (email) => this.memberApis.bulkUpdate({ active: false, emails: [email] });
6307
- generateRandomTeamMembers = ({ count = 1, role = "standard" }) => dynamicArray(count, () => ({
6308
- firstName: faker.person.firstName(),
6309
- lastName: faker.person.lastName(),
6310
- email: exampleEmail(),
6311
- role,
6312
- }));
6313
- getUserIdViaAPI = async (email) => {
6314
- const response = await this.memberApis.fetch();
6315
- const { members } = (await response?.json());
6316
- const member = findBy({ email }, members);
6317
- return member?.id;
6318
- };
6319
- updateEmailViaAPI = async ({ oldEmail, newEmail, role = "Admin", }) => {
6320
- const userId = await this.getUserIdViaAPI(oldEmail);
6321
- await this.memberApis.update(userId, keysToSnakeCase({
6322
- organizationRole: role,
6323
- email: newEmail,
6324
- active: true,
6325
- }));
6326
- };
6327
5293
  }
6328
5294
 
6329
5295
  const DESCRIPTION_EDITOR_TEXTS = {
@@ -6614,13 +5580,7 @@ class EditorPage {
6614
5580
  this.videoWrapperSelector = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.videoWrapper);
6615
5581
  this.emojiSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.emojiOption);
6616
5582
  const fixedMenuWrapper = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.fixedMenuWrapper);
6617
- const fixedMenuButtons = fixedMenuWrapper.getByRole("button");
6618
- const legacyMoreIcon = this.page.getByTestId(COMMON_SELECTORS.dropdownIcon);
6619
- this.moreMenuSelector = IS_SHADCN_UI
6620
- ? fixedMenuWrapper.getByTestId(NEETO_EDITOR_SELECTORS.moreMenuOption)
6621
- : fixedMenuButtons
6622
- .and(legacyMoreIcon)
6623
- .or(fixedMenuButtons.filter({ has: legacyMoreIcon }));
5583
+ this.moreMenuSelector = fixedMenuWrapper.getByTestId(NEETO_EDITOR_SELECTORS.moreMenuOption);
6624
5584
  this.contentField = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.contentField);
6625
5585
  this.dynamicVariablesButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.dynamicVariablesButton);
6626
5586
  this.calloutSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.calloutOption);
@@ -6664,9 +5624,6 @@ class EditorPage {
6664
5624
  if (await expandedMenuTrigger.isVisible()) {
6665
5625
  await expandedMenuTrigger.click({ timeout: 1_000 });
6666
5626
  }
6667
- else if (!IS_SHADCN_UI) {
6668
- await this.contentField.click();
6669
- }
6670
5627
  await expect(dropdownContainer).toBeHidden({ timeout: 1_000 });
6671
5628
  }).toPass({ timeout: 10_000 });
6672
5629
  };
@@ -6694,9 +5651,7 @@ class EditorPage {
6694
5651
  await this.moreMenuSelector.click();
6695
5652
  const dropdownContainer = this.page.getByTestId(COMMON_SELECTORS.dropdownContainer);
6696
5653
  await expect(dropdownContainer).toBeVisible();
6697
- const moreMenuButtons = await dropdownContainer
6698
- .getByRole(IS_SHADCN_UI ? "menuitem" : "button")
6699
- .all();
5654
+ const moreMenuButtons = await dropdownContainer.getByRole("menuitem").all();
6700
5655
  const moreMenuButtonLocators = await Promise.all(moreMenuButtons.map(async (button) => {
6701
5656
  const dataTestid = await button.getAttribute("data-testid");
6702
5657
  return this.cleanString(dataTestid);
@@ -6705,37 +5660,7 @@ class EditorPage {
6705
5660
  await expect(dropdownContainer).toBeHidden();
6706
5661
  return moreMenuButtonLocators;
6707
5662
  };
6708
- verifyFontSize = async (isButtonInMoreMenu = false) => IS_SHADCN_UI
6709
- ? this.verifyFontSizeV2(isButtonInMoreMenu)
6710
- : this.verifyFontSizeV1(isButtonInMoreMenu);
6711
- verifyFontSizeV1 = async (isButtonInMoreMenu) => {
6712
- const fontsAndTexts = [];
6713
- const fontSizeDropdown = this.page.getByTestId(NEETO_EDITOR_SELECTORS.fontSize);
6714
- await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
6715
- const headingButtons = await this.page
6716
- .getByTestId(NEETO_EDITOR_SELECTORS.fontSizeHeadingOptions)
6717
- .and(this.page.getByRole("button"))
6718
- .all();
6719
- const headingLevels = (await Promise.all(headingButtons.map(async (button) => {
6720
- const dataTestid = await button.getAttribute("data-testid");
6721
- const headingLevel = dataTestid?.split("-").pop();
6722
- return /^h[1-5]$/.test(headingLevel || "") ? headingLevel : null;
6723
- }))).filter(Boolean);
6724
- await this.dismissToolbarMenu();
6725
- for (const headingLevel of headingLevels) {
6726
- const fontKey = headingLevel;
6727
- const randomText = await this.fillRandomText();
6728
- await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
6729
- await this.page.getByTestId(FONT_SIZE_SELECTORS[fontKey]).click();
6730
- await expect(this.contentField.getByRole("heading", {
6731
- level: Number(headingLevel?.slice(1)),
6732
- name: randomText,
6733
- })).toBeVisible();
6734
- fontsAndTexts.push({ key: fontKey, value: randomText });
6735
- }
6736
- return fontsAndTexts;
6737
- };
6738
- verifyFontSizeV2 = async (isButtonInMoreMenu) => {
5663
+ verifyFontSize = async (isButtonInMoreMenu) => {
6739
5664
  const fontsAndTexts = [];
6740
5665
  const fontSizeDropdown = this.page.getByTestId(NEETO_EDITOR_SELECTORS.fontSize);
6741
5666
  await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
@@ -7073,9 +5998,7 @@ class EditorPage {
7073
5998
  verifyCalloutSelector = async (isButtonInMoreMenu) => {
7074
5999
  const calloutTypes = ["default", "info", "warning", "error", "success"];
7075
6000
  const calloutContentField = this.contentField.locator(NEETO_EDITOR_SELECTORS.calloutContent);
7076
- const calloutTypeOption = IS_SHADCN_UI
7077
- ? this.page.getByTestId(NEETO_EDITOR_SELECTORS.calloutTypeOptionV2)
7078
- : this.page.locator(NEETO_EDITOR_SELECTORS.calloutTypeOption);
6001
+ const calloutTypeOption = this.page.getByTestId(NEETO_EDITOR_SELECTORS.calloutTypeOptionV2);
7079
6002
  await this.moveCursorAtBottom();
7080
6003
  for (const [index, type] of calloutTypes.entries()) {
7081
6004
  await this.clickToolbarOption(this.calloutSelector, isButtonInMoreMenu);
@@ -7289,673 +6212,70 @@ class ImageUploader {
7289
6212
  aspectRatioHeight,
7290
6213
  aspectRatioWidth,
7291
6214
  width,
7292
- height,
7293
- });
7294
- await this.submitCroppedImage();
7295
- };
7296
- selectImageFromWeb = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
7297
- await this.openImageLibrary();
7298
- await this.page
7299
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashTab)
7300
- .click();
7301
- if (isNotEmpty(searchTerm)) {
7302
- await this.page
7303
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
7304
- .fill(searchTerm);
7305
- await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
7306
- timeout: 10_000,
7307
- });
7308
- }
7309
- await this.page
7310
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthUnsplashImage(nthImage))
7311
- .click();
7312
- await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
7313
- timeout: 10_000,
7314
- });
7315
- toggleOrginalImage
7316
- ? await this.page
7317
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
7318
- .click()
7319
- : await this.cropImage({
7320
- toggleAspectRatioLock,
7321
- aspectRatioHeight,
7322
- aspectRatioWidth,
7323
- width,
7324
- height,
7325
- });
7326
- await this.submitCroppedImage();
7327
- };
7328
- selectImageFromLibrary = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
7329
- await this.openImageLibrary();
7330
- await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
7331
- timeout: 10_000,
7332
- });
7333
- if (isNotEmpty(searchTerm)) {
7334
- await this.page
7335
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
7336
- .fill(searchTerm);
7337
- await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
7338
- timeout: 10_000,
7339
- });
7340
- }
7341
- await this.page
7342
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthLibraryImage(nthImage))
7343
- .click();
7344
- toggleOrginalImage
7345
- ? await this.page
7346
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
7347
- .click()
7348
- : await this.cropImage({
7349
- toggleAspectRatioLock,
7350
- aspectRatioHeight,
7351
- aspectRatioWidth,
7352
- width,
7353
- height,
7354
- });
7355
- await this.submitCroppedImage();
7356
- };
7357
- }
7358
-
7359
- const openFilterPane = async (page) => {
7360
- await page
7361
- .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7362
- .or(page.getByTestId(COMMON_SELECTORS.filterButon))
7363
- .click();
7364
- await expect(page.getByTestId(COMMON_SELECTORS.paneHeader)).toHaveText(getI18nInstance().t("neetoFilters.common.filters"));
7365
- };
7366
- const openFilterPaneV2 = async (page) => {
7367
- await page
7368
- .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7369
- .or(page.getByTestId(COMMON_SELECTORS.filterButon))
7370
- .click();
7371
- await expect(page.getByTestId(NEETO_FILTERS_SELECTORS.filterPaneHeading)).toHaveText(getI18nInstance().t("neetoFilters.common.filters"));
7372
- };
7373
- const clearFiltersFromActionBlock = async (page) => {
7374
- const isClearButtonVisible = await page
7375
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)
7376
- .isVisible();
7377
- if (isClearButtonVisible) {
7378
- await page
7379
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)
7380
- .click();
7381
- await Promise.all([
7382
- expect(page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeHidden(),
7383
- expect(page.locator(COMMON_SELECTORS.tableSpinner)).toHaveCount(0, {
7384
- timeout: 15_000,
7385
- }),
7386
- ]);
7387
- }
7388
- };
7389
- const filterUtils = {
7390
- openFilterPane,
7391
- openFilterPaneV2,
7392
- clearFiltersFromActionBlock,
7393
- };
7394
-
7395
- class TeamMembers {
7396
- page;
7397
- neetoPlaywrightUtilities;
7398
- t;
7399
- constructor({ page, neetoPlaywrightUtilities, }) {
7400
- this.page = page;
7401
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
7402
- this.t = getI18nInstance().t;
7403
- }
7404
- navigateToTeamMembers = async () => {
7405
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7406
- await this.page.getByTestId(MEMBER_SELECTORS.membersTab).click();
7407
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7408
- };
7409
- openMemberPane = async () => {
7410
- await this.page.getByTestId(MEMBER_SELECTORS.newButton).click();
7411
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7412
- const continueButton = this.page.getByTestId(MEMBER_SELECTORS.continueButton);
7413
- await expect(continueButton).toBeVisible();
7414
- await expect(continueButton.getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden({ timeout: 35_000 });
7415
- };
7416
- fillMemberForm = async (emails, role) => {
7417
- await this.page
7418
- .getByTestId(MEMBER_FORM_SELECTORS.emailTextField)
7419
- .fill(emails.join(", "));
7420
- await this.page.keyboard.press("Enter");
7421
- role &&
7422
- (await this.neetoPlaywrightUtilities.toggleElement({
7423
- locator: this.page.getByTestId(MEMBER_SELECTORS.roleLabel(role)),
7424
- }));
7425
- const continueBtn = this.page.getByTestId(MEMBER_SELECTORS.continueButton);
7426
- await continueBtn.click();
7427
- if (IS_DEV_ENV)
7428
- return;
7429
- await this.page
7430
- .getByTestId(COMMON_SELECTORS.paneBody)
7431
- .getByTestId(COMMON_SELECTORS.checkboxLabel)
7432
- .click();
7433
- await continueBtn.click();
7434
- };
7435
- addMemberViaUI = async ({ emails = [exampleEmail()], role = "standard", } = {}) => {
7436
- await this.openMemberPane();
7437
- await this.fillMemberForm(emails, role);
7438
- await this.submit();
7439
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7440
- };
7441
- submit = async () => {
7442
- const pane = this.page.getByTestId(COMMON_SELECTORS.paneBody);
7443
- const submitBtn = this.page.getByTestId(MEMBER_SELECTORS.submitButton);
7444
- const buttonSpinner = submitBtn.getByTestId(COMMON_SELECTORS.uiSpinner);
7445
- await expect(submitBtn).toBeVisible({ timeout: 10_000 });
7446
- await expect(async () => {
7447
- if (await pane.isHidden())
7448
- return;
7449
- (await buttonSpinner.isHidden()) && (await submitBtn.click());
7450
- await expect(buttonSpinner).toHaveCount(0, { timeout: 10_000 });
7451
- await expect(pane).toBeHidden();
7452
- }).toPass({ timeout: 60_000 });
7453
- await this.neetoPlaywrightUtilities.verifyToast();
7454
- };
7455
- searchAndVerifyMemberByEmail = async ({ email }) => {
7456
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7457
- await this.page.getByTestId(MEMBER_SELECTORS.searchTextField).fill(email);
7458
- const emailSubstr = email.length > 20 ? email.substring(0, 20) : email;
7459
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.searchTermBlock)).toContainText(emailSubstr);
7460
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7461
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7462
- await expect(this.page.getByRole("cell", { name: email, exact: true })).toBeVisible();
7463
- };
7464
- editMemberViaUI = async ({ email = "", firstName = "", lastName = "", role = "standard", } = {}) => {
7465
- await this.page.getByTestId(MEMBER_SELECTORS.dropDownIcon).click();
7466
- await this.page.getByTestId(MEMBER_SELECTORS.editButton).click();
7467
- await this.neetoPlaywrightUtilities.waitForPaneToLoad();
7468
- await expect(this.page
7469
- .getByTestId(MEMBER_SELECTORS.submitButton)
7470
- .getByTestId(COMMON_SELECTORS.uiSpinner)).toHaveCount(0, { timeout: 35_000 });
7471
- isPresent(email) &&
7472
- (await this.page
7473
- .getByTestId(MEMBER_FORM_SELECTORS.emailInput)
7474
- .fill(email));
7475
- isPresent(firstName) &&
7476
- (await this.page
7477
- .getByTestId(MEMBER_FORM_SELECTORS.firstNameTextField)
7478
- .fill(firstName));
7479
- isPresent(lastName) &&
7480
- (await this.page
7481
- .getByTestId(MEMBER_FORM_SELECTORS.lastNameTextField)
7482
- .fill(lastName));
7483
- await this.neetoPlaywrightUtilities.toggleElement({
7484
- locator: this.page.getByTestId(MEMBER_SELECTORS.roleLabel(role)),
7485
- });
7486
- await this.submit();
7487
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7488
- };
7489
- removeMemberViaUI = async (parentLocator = this.page) => {
7490
- await parentLocator.getByTestId(MEMBER_SELECTORS.dropDownIcon).click();
7491
- await this.page.getByTestId(MEMBER_SELECTORS.removeMember).click();
7492
- await this.page
7493
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
7494
- .click();
7495
- await this.neetoPlaywrightUtilities.verifyToast();
7496
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7497
- };
7498
- openFilterPane = async () => {
7499
- await this.page
7500
- .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7501
- .or(this.page.getByTestId(COMMON_SELECTORS.filterButon))
7502
- .click();
7503
- await expect(this.page.getByTestId(COMMON_SELECTORS.paneHeader)).toHaveText(this.t("neetoFilters.common.filters"));
7504
- };
7505
- filterMembersByMultiSelect = async ({ selectedOptions = [], selectContainerLocator = NEETO_FILTERS_SELECTORS.roleSelectContainer, }) => {
7506
- await this.page
7507
- .getByTestId(selectContainerLocator)
7508
- .getByTestId(COMMON_SELECTORS.actionSelectIndicator)
7509
- .click();
7510
- for (const option of selectedOptions) {
7511
- await this.page
7512
- .getByTestId(COMMON_SELECTORS.selectOption(option))
7513
- .click();
7514
- }
7515
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7516
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7517
- };
7518
- filterMembers = async ({ email = { id: "", condition: "Is" }, roles = [], name = "", }) => {
7519
- await filterUtils.clearFiltersFromActionBlock(this.page);
7520
- await filterUtils.openFilterPane(this.page);
7521
- if (isPresent(email.id)) {
7522
- await this.page
7523
- .getByTestId(NEETO_FILTERS_SELECTORS.emailSelectContainer)
7524
- .getByTestId(COMMON_SELECTORS.actionSelectIndicator)
7525
- .click();
7526
- await this.page
7527
- .getByTestId(COMMON_SELECTORS.selectOption(email.condition))
7528
- .click();
7529
- await this.page
7530
- .getByTestId(NEETO_FILTERS_SELECTORS.filtersEmailFilter)
7531
- .fill(email.id);
7532
- }
7533
- isPresent(name) &&
7534
- (await this.page
7535
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersNameFilterField)
7536
- .fill(name));
7537
- isPresent(roles) &&
7538
- (await this.filterMembersByMultiSelect({ selectedOptions: roles }));
7539
- await this.applyFilter();
7540
- };
7541
- getMemberRowByName = (name) => this.page.getByRole("row").filter({
7542
- has: this.page.getByTestId(MEMBER_SELECTORS.memberNameCell(name)),
7543
- });
7544
- takeActionOnMembers = async ({ names = [], state, action, }) => {
7545
- if (isPresent(names)) {
7546
- for (const name of names) {
7547
- await this.getMemberRowByName(name).getByRole("checkbox").click();
7548
- }
7549
- }
7550
- else {
7551
- await this.page
7552
- .getByRole("columnheader", { name: MEMBER_TEXTS.selectAll })
7553
- .click();
7554
- }
7555
- await this.page.getByTestId(COMMON_SELECTORS.takeActionDropdown).click();
7556
- if (isPresent(state)) {
7557
- await this.page
7558
- .getByTestId(MEMBER_SELECTORS.takeActionStateOption(state))
7559
- .click();
7560
- }
7561
- else {
7562
- await this.page
7563
- .getByRole("button", { name: action?.actionButtonText })
7564
- .click();
7565
- await this.page
7566
- .getByRole("button", { name: action?.valueButtonText })
7567
- .click();
7568
- }
7569
- await this.page
7570
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
7571
- .click();
7572
- await this.neetoPlaywrightUtilities.verifyToast();
7573
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7574
- };
7575
- performColumnAction = async ({ columnName = "Name", actionButtonText = "Ascending", } = {}) => {
7576
- await this.page
7577
- .getByTestId(MEMBER_SELECTORS.teamMembersTable)
7578
- .getByLabel(columnName)
7579
- .getByTestId(TABLE_SELECTORS.columnMenuButton)
7580
- .click();
7581
- await this.page.getByRole("button", { name: actionButtonText }).click();
7582
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7583
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7584
- };
7585
- toggleMemberColumns = async ({ columns = [], bulkAction, }) => {
7586
- await expect(async () => {
7587
- await this.page
7588
- .getByTestId(COMMON_SELECTORS.columnsDropdownButton)
7589
- .click();
7590
- await expect(this.page.getByTestId(COMMON_SELECTORS.columnsSearchInput)).toBeVisible();
7591
- }).toPass({ timeout: 15_000 });
7592
- if (isPresent(bulkAction)) {
7593
- await this.page
7594
- .getByTestId(COMMON_SELECTORS.columnVisibilityBtn(bulkAction === "hide" ? "hide-all" : "reset"))
7595
- .click();
7596
- }
7597
- else {
7598
- for (const column of columns) {
7599
- await this.page
7600
- .getByTestId(COMMON_SELECTORS.columnsSearchInput)
7601
- .fill(column);
7602
- const columnCheckbox = this.page
7603
- .getByTestId(COMMON_SELECTORS.nuiCheckboxContainer)
7604
- .filter({ hasText: column })
7605
- .getByTestId(MEMBER_SELECTORS.columnCheckBox);
7606
- const isChecked = await columnCheckbox.isChecked();
7607
- await columnCheckbox.click();
7608
- await expect(columnCheckbox).toBeChecked({ checked: !isChecked });
7609
- }
7610
- }
7611
- await this.page.getByTestId(COMMON_SELECTORS.columnsDropdownButton).click();
7612
- };
7613
- verifyMemberInTable = ({ name, email }) => expect(this.getMemberRowByName(name).getByRole("cell", {
7614
- name: email,
7615
- exact: true,
7616
- })).toBeVisible();
7617
- applyFilter = async () => {
7618
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible();
7619
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7620
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden({
7621
- timeout: 30_000,
7622
- });
7623
- await this.page
7624
- .getByTestId(NEETO_FILTERS_SELECTORS.filterDoneButton)
7625
- .click();
7626
- };
7627
- exportDetails = async (fileType, adminEmail) => {
7628
- await this.page.getByTestId(MEMBER_SELECTORS.downloadButton).click();
7629
- await expect(this.page.getByTestId(MEMBER_SELECTORS.exportMemberHeading)).toHaveText(this.t("neetoTeamMembers.exportPane.title"));
7630
- await this.page
7631
- .getByTestId(MEMBER_SELECTORS.downloadAsRadioItem(fileType))
7632
- .check();
7633
- const exportStartTime = new Date();
7634
- await this.page.getByTestId(MEMBER_SELECTORS.exportSubmitBtn).click();
7635
- await this.neetoPlaywrightUtilities.verifyToast({
7636
- message: this.t("toastr.success.exportMembers", { email: adminEmail }),
7637
- });
7638
- return exportStartTime;
7639
- };
7640
- verifyNoDataTitle = async (email) => {
7641
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7642
- await this.page.getByTestId(MEMBER_SELECTORS.searchTextField).fill(email);
7643
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible();
7644
- await expect(this.page.getByTestId(COMMON_SELECTORS.noDataTitle)).toBeVisible({ timeout: 10_000 });
7645
- await filterUtils.clearFiltersFromActionBlock(this.page);
7646
- };
7647
- }
7648
- class TeamMembersV2 extends TeamMembers {
7649
- fillMemberForm = async (emails, role) => {
7650
- await this.page
7651
- .getByTestId(MEMBER_FORM_SELECTORS.emailTextField)
7652
- .pressSequentially(emails.join(", "));
7653
- const continueBtn = this.page.getByTestId(MEMBER_SELECTORS.continueButton);
7654
- await this.page.keyboard.press("Enter");
7655
- await expect(continueBtn).toBeEnabled();
7656
- role &&
7657
- (await this.neetoPlaywrightUtilities.toggleElement({
7658
- locator: this.page.getByRole("radio", { name: role, exact: true }),
7659
- }));
7660
- await continueBtn.click();
7661
- if (IS_DEV_ENV)
7662
- return;
7663
- await this.page.getByTestId(MEMBER_SELECTORS.manageAppListChk).click();
7664
- await continueBtn.click();
7665
- };
7666
- openMemberPane = async () => {
7667
- await this.page.getByTestId(MEMBER_SELECTORS.newButton).click();
7668
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7669
- const continueButton = this.page.getByTestId(MEMBER_SELECTORS.continueButton);
7670
- await expect(continueButton).toBeVisible();
7671
- await this.neetoPlaywrightUtilities.waitForSheetOpen();
7672
- await expect(continueButton.getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden({ timeout: 35_000 });
7673
- };
7674
- addMemberViaUI = async ({ emails = [exampleEmail()], role = "standard", } = {}) => {
7675
- await this.openMemberPane();
7676
- await this.fillMemberForm(emails, role);
7677
- await this.submit();
7678
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7679
- };
7680
- submit = async () => {
7681
- const pane = this.page.getByRole("dialog");
7682
- const submitBtn = this.page.getByTestId(MEMBER_SELECTORS.submitButton);
7683
- const buttonSpinner = submitBtn.getByTestId(COMMON_SELECTORS.uiSpinner);
7684
- await expect(submitBtn).toBeVisible({ timeout: 10_000 });
7685
- await expect(async () => {
7686
- if (await pane.isHidden())
7687
- return;
7688
- (await buttonSpinner.isHidden()) && (await submitBtn.click());
7689
- await expect(buttonSpinner).toHaveCount(0, { timeout: 10_000 });
7690
- await expect(pane).toBeHidden();
7691
- }).toPass({ timeout: 60_000 });
7692
- await this.neetoPlaywrightUtilities.verifyToast();
7693
- };
7694
- editMemberViaUI = async ({ email = "", firstName = "", lastName = "", role = "standard", } = {}) => {
7695
- await expect(this.page.getByTestId(MEMBER_SELECTORS.dropDownIcon)).toHaveCount(1);
7696
- await this.page.getByTestId(MEMBER_SELECTORS.dropDownIcon).click();
7697
- await this.page.getByTestId(MEMBER_SELECTORS.editButton).click();
7698
- const editPane = this.page.getByRole("dialog");
7699
- await expect(editPane).toBeVisible({ timeout: 35_000 });
7700
- await expect(editPane.getByTestId(COMMON_SELECTORS.uiSpinner)).toHaveCount(0, { timeout: 35_000 });
7701
- await expect(this.page
7702
- .getByTestId(MEMBER_SELECTORS.submitButton)
7703
- .getByTestId(COMMON_SELECTORS.uiSpinner)).toHaveCount(0, { timeout: 35_000 });
7704
- await this.neetoPlaywrightUtilities.waitForSheetOpen();
7705
- isPresent(email) &&
7706
- (await this.page
7707
- .getByTestId(MEMBER_FORM_SELECTORS.emailInput)
7708
- .fill(email));
7709
- isPresent(firstName) &&
7710
- (await this.page
7711
- .getByTestId(MEMBER_FORM_SELECTORS.firstNameTextField)
7712
- .fill(firstName));
7713
- isPresent(lastName) &&
7714
- (await this.page
7715
- .getByTestId(MEMBER_FORM_SELECTORS.lastNameTextField)
7716
- .fill(lastName));
7717
- await this.neetoPlaywrightUtilities.toggleElement({
7718
- locator: this.page.getByRole("radio", { name: role, exact: true }),
7719
- });
7720
- await this.submit();
7721
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7722
- };
7723
- openFilterPane = async () => {
7724
- await this.page
7725
- .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7726
- .or(this.page.getByTestId(COMMON_SELECTORS.filterButon))
7727
- .click();
7728
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.filterPaneHeading)).toHaveText(this.t("neetoFilters.common.filters"));
7729
- };
7730
- filterMembersByMultiSelect = async ({ selectedOptions = [], selectContainerLocator = NEETO_FILTERS_SELECTORS.roleSelectContainer, }) => {
7731
- await this.page
7732
- .getByTestId(selectContainerLocator)
7733
- .getByRole("combobox")
7734
- .click({ timeout: 30_000 });
7735
- for (const option of selectedOptions) {
7736
- await this.page
7737
- .getByRole("option", { name: option, exact: true })
7738
- .click();
7739
- }
7740
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7741
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7742
- };
7743
- filterMembers = async ({ email = { id: "", condition: "Is" }, roles = [], name = "", }) => {
7744
- await filterUtils.clearFiltersFromActionBlock(this.page);
7745
- await this.openFilterPane();
7746
- if (isPresent(email.id)) {
7747
- await this.page
7748
- .getByTestId(NEETO_FILTERS_SELECTORS.emailSelectContainer)
7749
- .getByRole("combobox")
7750
- .click();
7751
- await this.page
7752
- .getByRole("option", { name: email.condition, exact: true })
7753
- .click();
7754
- await this.page
7755
- .getByTestId(NEETO_FILTERS_SELECTORS.filtersEmailFilter)
7756
- .fill(email.id);
7757
- }
7758
- isPresent(name) &&
7759
- (await this.page
7760
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersNameFilterField)
7761
- .fill(name));
7762
- isPresent(roles) &&
7763
- (await this.filterMembersByMultiSelect({ selectedOptions: roles }));
7764
- await this.applyFilter();
7765
- };
7766
- verifyNoDataTitle = async (email) => {
7767
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7768
- await this.page.getByTestId(MEMBER_SELECTORS.searchTextField).fill(email);
7769
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible();
7770
- await expect(this.page.getByTestId(COMMON_SELECTORS.noDataTitleV2)).toBeVisible({ timeout: 10_000 });
7771
- await filterUtils.clearFiltersFromActionBlock(this.page);
7772
- };
7773
- applyFilter = async () => {
7774
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible();
7775
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7776
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden({
7777
- timeout: 30_000,
7778
- });
7779
- await this.page
7780
- .getByTestId(NEETO_FILTERS_SELECTORS.filterDoneButton)
7781
- .click();
7782
- await this.neetoPlaywrightUtilities.waitForSheetClose();
7783
- };
7784
- performColumnAction = async ({ columnName = "Name", actionButtonText = "Ascending", } = {}) => {
7785
- await this.page
7786
- .getByTestId(TABLE_SELECTORS.columnHeaderTitle(hyphenate(columnName)))
7787
- .getByTestId(TABLE_SELECTORS.columnMenuButton)
7788
- .click();
7789
- await this.page.getByRole("menuitem", { name: actionButtonText }).click();
7790
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7791
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7792
- };
7793
- takeActionOnMembers = async ({ names = [], state, action, }) => {
7794
- if (isPresent(names)) {
7795
- for (const name of names) {
7796
- await this.getMemberRowByName(name).getByRole("checkbox").click();
7797
- }
7798
- }
7799
- else {
7800
- await this.page
7801
- .getByRole("columnheader", { name: MEMBER_TEXTS.selectAll })
7802
- .click();
7803
- }
7804
- await this.page.getByTestId(MEMBER_SELECTORS.takeActionDropdown).click();
7805
- if (isPresent(state)) {
7806
- await this.page
7807
- .getByTestId(MEMBER_SELECTORS.takeActionStateOption(state))
7808
- .click();
7809
- }
7810
- else {
7811
- await this.page
7812
- .getByRole("menuitem", { name: action?.actionButtonText })
7813
- .click();
7814
- await this.page
7815
- .getByRole("menuitem", { name: action?.valueButtonText })
7816
- .click();
7817
- }
7818
- await this.page
7819
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
7820
- .click();
7821
- await this.neetoPlaywrightUtilities.verifyToast();
7822
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7823
- };
7824
- }
7825
-
7826
- dayjs.extend(customParseFormat);
7827
- class ApiKeysPage {
7828
- page;
7829
- neetoPlaywrightUtilities;
7830
- t;
7831
- constructor(page, neetoPlaywrightUtilities) {
7832
- this.page = page;
7833
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
7834
- this.t = getI18nInstance().t;
7835
- }
7836
- enableExpiryDate = async (expiryDate) => {
7837
- const userProps = await getGlobalUserProps(this.page);
7838
- const normalizedDate = dayjs(expiryDate, DATE_FORMATS.date);
7839
- const formattedExpiryDate = normalizedDate.format(userProps?.dateFormat);
7840
- const expiryDateInput = this.page
7841
- .getByTestId(COMMON_SELECTORS.paneBody)
7842
- .getByTestId(ADMIN_PANEL_SELECTORS.expiryDateInput);
7843
- const nextYearBtn = this.page.getByLabel(DATE_TEXTS.nextYear, {
7844
- exact: true,
7845
- });
7846
- await this.page
7847
- .getByTestId(COMMON_SELECTORS.checkboxInput("never-expires"))
7848
- .uncheck();
7849
- await expiryDateInput.click();
7850
- await expect(nextYearBtn).toBeVisible();
7851
- await expiryDateInput.pressSequentially(formattedExpiryDate, {
7852
- delay: 250,
7853
- });
7854
- await Promise.all([
7855
- expect(expiryDateInput).toHaveValue(formattedExpiryDate),
7856
- expect(this.page.getByRole("button", { name: CALENDAR_LABELS.month })).toHaveText(normalizedDate.format(DATE_FORMATS.month)),
7857
- expect(this.page.getByRole("button", { name: CALENDAR_LABELS.year })).toHaveText(normalizedDate.format(DATE_FORMATS.year)),
7858
- expect(this.page.getByTitle(normalizedDate.format(DATE_FORMATS.calendarDate))).toHaveClass(RegExp(DATE_PICKER_SELECTORS.selectedDateInCalendarClass)),
7859
- ]);
7860
- await this.page.keyboard.press("Enter");
7861
- await expect(nextYearBtn).toBeHidden({ timeout: 15_000 });
7862
- };
7863
- fillApiKeyDetails = async ({ label, expiryDate }) => {
7864
- await this.page
7865
- .getByTestId(COMMON_SELECTORS.paneBody)
7866
- .getByTestId(COMMON_SELECTORS.customInputField("name"))
7867
- .fill(label);
7868
- isPresent(expiryDate) && (await this.enableExpiryDate(expiryDate));
7869
- await this.neetoPlaywrightUtilities.saveChanges({ isPane: true });
7870
- };
7871
- verifyApiKey = ({ targetRow, label, date }) => Promise.all([
7872
- expect(targetRow.getByRole("cell", { name: label })).toBeVisible(),
7873
- expect(targetRow.getByRole("cell", { name: date })).toBeVisible(),
7874
- expect(targetRow.getByRole("cell", {
7875
- name: this.t("neetoApiKeys.common.never"),
7876
- })).toBeVisible(),
7877
- expect(targetRow.getByTestId(TAGS_SELECTORS.tagContainer)).toHaveText(this.t("neetoApiKeys.tags.active")),
7878
- ]);
7879
- editApiKey = async ({ label, expiryDate }) => {
7880
- await this.page
7881
- .getByTestId(COMMON_SELECTORS.dropdownContainer)
7882
- .getByTestId(API_KEYS_SELECTORS.editApiKeyButton)
7883
- .click();
7884
- await this.fillApiKeyDetails({ label, expiryDate });
6215
+ height,
6216
+ });
6217
+ await this.submitCroppedImage();
7885
6218
  };
7886
- deleteApiKey = async (targetRow) => {
7887
- await targetRow.getByTestId(COMMON_SELECTORS.dropdownIcon).click();
6219
+ selectImageFromWeb = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
6220
+ await this.openImageLibrary();
7888
6221
  await this.page
7889
- .getByTestId(COMMON_SELECTORS.dropdownContainer)
7890
- .getByTestId(API_KEYS_SELECTORS.deleteApiKeyButton)
6222
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashTab)
7891
6223
  .click();
6224
+ if (isNotEmpty(searchTerm)) {
6225
+ await this.page
6226
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
6227
+ .fill(searchTerm);
6228
+ await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
6229
+ timeout: 10_000,
6230
+ });
6231
+ }
7892
6232
  await this.page
7893
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
6233
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthUnsplashImage(nthImage))
7894
6234
  .click();
7895
- await this.neetoPlaywrightUtilities.verifyToast();
7896
- await expect(targetRow).toBeHidden();
7897
- };
7898
- }
7899
- class ApiKeysPageV2 extends ApiKeysPage {
7900
- enableExpiryDate = async (expiryDate) => {
7901
- const dialog = this.page.getByRole("dialog");
7902
- const neverExpiresCheckbox = dialog.getByRole("checkbox", {
7903
- name: this.t("neetoApiKeys.fields.neverExpire"),
7904
- });
7905
- await expect(async () => {
7906
- await neverExpiresCheckbox.uncheck();
7907
- await expect(neverExpiresCheckbox).not.toBeChecked();
7908
- }).toPass({ timeout: 10_000 });
7909
- const userProps = await getGlobalUserProps(this.page);
7910
- const formattedExpiryDate = dayjs(expiryDate, DATE_FORMATS.date).format(userProps?.dateFormat);
7911
- const expiryDateInput = dialog.getByRole("textbox", {
7912
- name: this.t("neetoApiKeys.fields.expiryDate"),
6235
+ await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
6236
+ timeout: 10_000,
7913
6237
  });
7914
- await expect(async () => {
7915
- await expiryDateInput.fill(formattedExpiryDate);
7916
- await expect(expiryDateInput).toHaveValue(formattedExpiryDate);
7917
- }).toPass({ timeout: 10_000 });
7918
- };
7919
- fillApiKeyDetails = async ({ label, expiryDate }) => {
7920
- const dialog = this.page.getByRole("dialog");
7921
- await this.page
7922
- .getByTestId(COMMON_SELECTORS.customInputField("name"))
7923
- .fill(label);
7924
- isPresent(expiryDate) && (await this.enableExpiryDate(expiryDate));
7925
- const saveChangesButton = this.page.getByTestId(COMMON_SELECTORS.saveChangesButton);
7926
- await expect(saveChangesButton).toBeEnabled({ timeout: 10_000 });
7927
- await saveChangesButton.click();
7928
- await Promise.all([
7929
- expect(dialog).toBeHidden(),
7930
- this.neetoPlaywrightUtilities.verifyToast(),
7931
- ]);
7932
- };
7933
- verifyApiKey = ({ targetRow, label, date }) => Promise.all([
7934
- expect(targetRow.getByRole("cell", { name: label })).toBeVisible(),
7935
- expect(targetRow.getByRole("cell", { name: date })).toBeVisible(),
7936
- expect(targetRow.getByRole("cell", {
7937
- name: this.t("neetoApiKeys.common.never"),
7938
- })).toBeVisible(),
7939
- expect(targetRow.getByTestId(COMMON_SELECTORS.badgeContainer)).toHaveText(this.t("neetoApiKeys.tags.active")),
7940
- ]);
7941
- editApiKey = async ({ label, expiryDate }) => {
7942
- await this.page
7943
- .getByRole("menu")
7944
- .getByTestId(API_KEYS_SELECTORS.editApiKeyButton)
7945
- .click();
7946
- await this.fillApiKeyDetails({ label, expiryDate });
6238
+ toggleOrginalImage
6239
+ ? await this.page
6240
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
6241
+ .click()
6242
+ : await this.cropImage({
6243
+ toggleAspectRatioLock,
6244
+ aspectRatioHeight,
6245
+ aspectRatioWidth,
6246
+ width,
6247
+ height,
6248
+ });
6249
+ await this.submitCroppedImage();
7947
6250
  };
7948
- deleteApiKey = async (targetRow) => {
7949
- await targetRow.getByTestId(COMMON_SELECTORS.dropdownIcon).click();
7950
- await this.page
7951
- .getByRole("menu")
7952
- .getByTestId(API_KEYS_SELECTORS.deleteApiKeyButton)
7953
- .click();
6251
+ selectImageFromLibrary = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
6252
+ await this.openImageLibrary();
6253
+ await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
6254
+ timeout: 10_000,
6255
+ });
6256
+ if (isNotEmpty(searchTerm)) {
6257
+ await this.page
6258
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
6259
+ .fill(searchTerm);
6260
+ await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
6261
+ timeout: 10_000,
6262
+ });
6263
+ }
7954
6264
  await this.page
7955
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
6265
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthLibraryImage(nthImage))
7956
6266
  .click();
7957
- await this.neetoPlaywrightUtilities.verifyToast();
7958
- await expect(targetRow).toBeHidden();
6267
+ toggleOrginalImage
6268
+ ? await this.page
6269
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
6270
+ .click()
6271
+ : await this.cropImage({
6272
+ toggleAspectRatioLock,
6273
+ aspectRatioHeight,
6274
+ aspectRatioWidth,
6275
+ width,
6276
+ height,
6277
+ });
6278
+ await this.submitCroppedImage();
7959
6279
  };
7960
6280
  }
7961
6281
 
@@ -7978,15 +6298,11 @@ dayjs.extend(timezone);
7978
6298
  class AuditLogsPage {
7979
6299
  page;
7980
6300
  neetoPlaywrightUtilities;
7981
- currentDate;
7982
6301
  messageBuilders;
7983
6302
  admin;
7984
- constructor(page, neetoPlaywrightUtilities,
7985
- /** @deprecated Audit log messages no longer include the product name. */
7986
- _product, timeZone = "Asia/Kolkata") {
6303
+ constructor(page, neetoPlaywrightUtilities) {
7987
6304
  this.page = page;
7988
6305
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
7989
- this.currentDate = dayjs().tz(timeZone).format("MMM D, YYYY");
7990
6306
  this.messageBuilders = {
7991
6307
  [ACTIONS.inviteUsers]: (data) => `${this.admin} added ${data.emails.join(", ").toLowerCase()}.`,
7992
6308
  [ACTIONS.updatedUser]: (data) => `${this.admin} changed ${data.emails[0].toLowerCase()}'s email from ${data.emails[0].toLowerCase()} to ${data.emails[1].toLowerCase()}.`,
@@ -8017,8 +6333,10 @@ class AuditLogsPage {
8017
6333
  // eslint-disable-next-line playwright/no-nth-methods
8018
6334
  const card = this.page.getByTestId(AUDIT_LOGS_SELECTORS.card).first();
8019
6335
  const content = card.getByTestId(AUDIT_LOGS_SELECTORS.content);
6336
+ const { timeZone } = await getGlobalUserProps(this.page);
6337
+ const currentDate = dayjs().tz(timeZone).format("MMM D, YYYY");
8020
6338
  await Promise.all([
8021
- expect(content.getByTestId(AUDIT_LOGS_SELECTORS.timestamp)).toContainText(this.currentDate),
6339
+ expect(content.getByTestId(AUDIT_LOGS_SELECTORS.timestamp)).toContainText(currentDate),
8022
6340
  expect(content.getByTestId(AUDIT_LOGS_SELECTORS.text)).toHaveText(expectedMessage),
8023
6341
  ]);
8024
6342
  };
@@ -8110,9 +6428,7 @@ class CustomDomainPage {
8110
6428
  const validateButton = this.page.getByTestId(CUSTOM_DOMAIN_SELECTORS.customDomainValidateButton);
8111
6429
  await Promise.all([
8112
6430
  expect(validateButton).toBeVisible(),
8113
- expect(this.getValidationPaneBody().getByRole("cell", {
8114
- name: domain.split(".")[0],
8115
- })).toBeVisible(),
6431
+ expect(this.validationSheet.getByRole("cell", { name: domain.split(".")[0] })).toBeVisible(),
8116
6432
  ]);
8117
6433
  await this.neetoPlaywrightUtilities.waitForPageLoad();
8118
6434
  await validateButton.click();
@@ -8157,7 +6473,7 @@ class CustomDomainPage {
8157
6473
  const organizationPage = new OrganizationPage(loginPage, playwrightUtils);
8158
6474
  await loginPage.goto(loginUrl);
8159
6475
  await playwrightUtils.waitForPageLoad();
8160
- await organizationPage.loginViaSSO(email);
6476
+ await organizationPage.login({ email });
8161
6477
  await expect(loginPage).toHaveURL(RegExp(loginUrl), { timeout: 15_000 });
8162
6478
  await playwrightUtils.waitForPageLoad();
8163
6479
  };
@@ -8311,19 +6627,19 @@ class CustomDomainPage {
8311
6627
  waitUntil: "load",
8312
6628
  }));
8313
6629
  };
8314
- getValidationPaneBody = () => this.page.getByTestId(IS_SHADCN_UI ? COMMON_SELECTORS.sheetWrapper : COMMON_SELECTORS.paneBody);
8315
- getValidationPane = () => this.page.getByTestId(IS_SHADCN_UI ? COMMON_SELECTORS.sheetWrapper : COMMON_SELECTORS.pane);
6630
+ get validationSheet() {
6631
+ return this.page.getByTestId(COMMON_SELECTORS.sheetWrapper);
6632
+ }
8316
6633
  getCertificateInfrastructureSkipReason = async () => {
8317
- const pane = this.getValidationPaneBody();
8318
- if (await pane
6634
+ if (await this.validationSheet
8319
6635
  .getByText(RegExp(CERTIFICATE_LIMIT_EXCEEDED_REGEXP, "i"))
8320
6636
  .isVisible()) {
8321
6637
  return CERTIFICATE_LIMIT_EXCEEDED_MESSAGE;
8322
6638
  }
8323
6639
  const message = this.t("neetoCustomDomains.certificateProvisionFailed");
8324
6640
  const [hasProvisionFailedMessage, hasProvisionFailedFallback] = await Promise.all([
8325
- pane.getByText(message).isVisible(),
8326
- pane
6641
+ this.validationSheet.getByText(message).isVisible(),
6642
+ this.validationSheet
8327
6643
  .getByText(RegExp(CERTIFICATE_PROVISION_FAILED_REGEXP, "i"))
8328
6644
  .isVisible(),
8329
6645
  ]);
@@ -8333,7 +6649,7 @@ class CustomDomainPage {
8333
6649
  return null;
8334
6650
  };
8335
6651
  closeValidationPane = async () => {
8336
- const cancelButton = this.getValidationPane().getByTestId(COMMON_SELECTORS.cancelButton);
6652
+ const cancelButton = this.validationSheet.getByTestId(COMMON_SELECTORS.cancelButton);
8337
6653
  if (await cancelButton.isVisible())
8338
6654
  await cancelButton.click();
8339
6655
  };
@@ -8404,145 +6720,6 @@ class IPRestrictionsPage {
8404
6720
  };
8405
6721
  }
8406
6722
 
8407
- class RolesPage {
8408
- page;
8409
- neetoPlaywrightUtilities;
8410
- roleApis;
8411
- t;
8412
- constructor(page, neetoPlaywrightUtilities) {
8413
- this.page = page;
8414
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
8415
- this.roleApis = new RoleApis(neetoPlaywrightUtilities);
8416
- this.t = getI18nInstance().t;
8417
- }
8418
- getPermissionIds = async (targetPermissions, isGranularPermission = false) => {
8419
- const { permissions } = await this.roleApis
8420
- .fetch("permissions")
8421
- .then(response => response?.json());
8422
- const permissionObjects = targetPermissions.flatMap(permission => permissions.filter((p) => isGranularPermission
8423
- ? p.description === permission
8424
- : p.category === permission));
8425
- return pluck("id", permissionObjects);
8426
- };
8427
- getRoleIdAndOrganizationId = async (roleName) => {
8428
- const roles = await this.roleApis
8429
- .fetch("organization_roles")
8430
- .then(response => response?.json());
8431
- const { id: roleId, organization_id: organizationId } = findBy({ name: roleName }, roles.organization_roles);
8432
- return { roleId, organizationId };
8433
- };
8434
- addCustomRoleViaRequest = async (roleName, targetPermissions, isGranularPermission = false) => {
8435
- const permissionIds = await this.getPermissionIds(targetPermissions, isGranularPermission);
8436
- return this.roleApis.addRole(roleName, permissionIds);
8437
- };
8438
- editRoleViaRequest = async (roleName, targetPermissions, isGranularPermission = false) => {
8439
- const [permissionIds, { roleId, organizationId }] = await Promise.all([
8440
- this.getPermissionIds(targetPermissions, isGranularPermission),
8441
- this.getRoleIdAndOrganizationId(roleName),
8442
- ]);
8443
- return this.roleApis.editRole(roleId, {
8444
- id: roleId,
8445
- kind: "custom",
8446
- name: roleName,
8447
- organization_id: organizationId,
8448
- permission_ids: permissionIds,
8449
- });
8450
- };
8451
- deleteRoleViaRequest = async (roleName, secondaryRoleName = "Editor") => {
8452
- const [{ roleId }, { roleId: secondaryRoleId }] = await Promise.all([roleName, secondaryRoleName].map(this.getRoleIdAndOrganizationId));
8453
- return this.roleApis.deleteRole(roleId, secondaryRoleId);
8454
- };
8455
- addRoleViaUI = async ({ roleName, permissions, parentPermission = "", hierarchyLevelOfPermissions = 2, }) => {
8456
- await this.page.getByTestId(ROLES_SELECTORS.newButton).click();
8457
- await this.page.getByTestId(ROLES_SELECTORS.nameTextField).fill(roleName);
8458
- await this.selectAndSubmitPermissions(permissions, parentPermission, hierarchyLevelOfPermissions);
8459
- };
8460
- editRoleViaUI = async ({ roleName, permissions, parentPermission = "", hierarchyLevelOfPermissions = 2, }) => {
8461
- await this.page
8462
- .getByTestId(ROLES_SELECTORS.tableHeaderRoleName)
8463
- .filter({ hasText: roleName })
8464
- .getByTestId(ROLES_SELECTORS.dropDownIcon)
8465
- .click();
8466
- await this.page.getByTestId(ROLES_SELECTORS.editRoleButton).click();
8467
- await expect(this.page.getByTestId(ROLES_SELECTORS.updateRolePaneHeading)).toBeVisible();
8468
- await this.selectAndSubmitPermissions(permissions, parentPermission, hierarchyLevelOfPermissions);
8469
- };
8470
- selectAndSubmitPermissions = async (permissions, parentPermission = "", hierarchyLevelOfPermissions = 2) => {
8471
- const parentPermissionSelector = parentPermission
8472
- ? this.page
8473
- .getByTestId(ROLES_SELECTORS.permissionSubCategoryCard(hierarchyLevelOfPermissions - 1))
8474
- .filter({ hasText: parentPermission })
8475
- : this.page;
8476
- parentPermission &&
8477
- (await parentPermissionSelector
8478
- .getByTestId(COMMON_SELECTORS.customCheckboxLabel(parentPermission))
8479
- .click({ force: true }));
8480
- for (const permission of permissions) {
8481
- await parentPermissionSelector
8482
- .getByTestId(COMMON_SELECTORS.customCheckboxLabel(permission))
8483
- .click({ force: true }); // Used force: true because disabling the parent permission disables the child permissions means the checkboxes label become disable
8484
- }
8485
- await Promise.all([
8486
- this.page.getByTestId(ROLES_SELECTORS.proceedButton).click(),
8487
- this.neetoPlaywrightUtilities.verifyToast(),
8488
- ]);
8489
- };
8490
- deleteRoleViaUI = async (roleName) => {
8491
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8492
- await this.page
8493
- .getByTestId(ROLES_SELECTORS.tableHeaderRoleName)
8494
- .filter({ hasText: roleName })
8495
- .getByTestId(ROLES_SELECTORS.dropDownIcon)
8496
- .click();
8497
- await this.page.getByTestId(ROLES_SELECTORS.deleteRoleButton).click();
8498
- await expect(this.page.getByTestId(COMMON_SELECTORS.alertTitle)).toHaveText(this.t("neetoTeamMembers.labels.deleteRole"));
8499
- await this.neetoPlaywrightUtilities.clickButtonAndAwaitLoad({
8500
- locator: this.page.getByTestId(COMMON_SELECTORS.alertModalSubmitButton),
8501
- });
8502
- await this.neetoPlaywrightUtilities.verifyToast();
8503
- await expect(this.page
8504
- .getByTestId(ROLES_SELECTORS.tableHeaderRoleTitle)
8505
- .filter({ hasText: roleName })).toBeHidden();
8506
- };
8507
- verifyPermissions = ({ allPermissions, rolePermissions, }) => Promise.all(Object.values(allPermissions).map(async (permission) => rolePermissions.includes(permission)
8508
- ? await expect(this.page.getByTestId(permission)).toBeVisible()
8509
- : await expect(this.page.getByTestId(permission)).toBeHidden()));
8510
- verifyRoleSpecificLinkAccess = async ({ roleAccessableLinks = [], adminAccessableLinks = [], }) => {
8511
- if (isNotEqualDeep(roleAccessableLinks, adminAccessableLinks)) {
8512
- for (const link of adminAccessableLinks) {
8513
- await this.page.goto(link);
8514
- await this.neetoPlaywrightUtilities.waitForFloatingMenu();
8515
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8516
- await expect(this.page.getByRole("heading", {
8517
- name: this.t("neetoMolecules.errorPage.unauthorized"),
8518
- }))[roleAccessableLinks.includes(link) ? "toBeHidden" : "toBeVisible"]();
8519
- }
8520
- }
8521
- };
8522
- }
8523
- class RolesPageV2 extends RolesPage {
8524
- selectAndSubmitPermissions = async (permissions, parentPermission = "", hierarchyLevelOfPermissions = 2) => {
8525
- const parentPermissionSelector = parentPermission
8526
- ? this.page
8527
- .getByTestId(ROLES_SELECTORS.permissionSubCategoryCard(hierarchyLevelOfPermissions - 1))
8528
- .filter({ hasText: parentPermission })
8529
- : this.page;
8530
- parentPermission &&
8531
- (await parentPermissionSelector
8532
- .getByLabel(parentPermission, { exact: true })
8533
- .click());
8534
- for (const permission of permissions) {
8535
- await parentPermissionSelector
8536
- .getByLabel(permission, { exact: true })
8537
- .click();
8538
- }
8539
- await Promise.all([
8540
- this.page.getByTestId(ROLES_SELECTORS.proceedButton).click(),
8541
- this.neetoPlaywrightUtilities.verifyToast(),
8542
- ]);
8543
- };
8544
- }
8545
-
8546
6723
  class SidebarSection {
8547
6724
  page;
8548
6725
  neetoPlaywrightUtilities;
@@ -8556,123 +6733,6 @@ class SidebarSection {
8556
6733
  clickOnGoBackButton = (label) => this.page.getByTestId(COMMON_SELECTORS.sidebarGoBackButton(label)).click();
8557
6734
  }
8558
6735
 
8559
- class TagsPage {
8560
- page;
8561
- neetoPlaywrightUtilities;
8562
- t;
8563
- tagsApi;
8564
- constructor(page, neetoPlaywrightUtilities) {
8565
- this.page = page;
8566
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
8567
- this.t = getI18nInstance().t;
8568
- this.tagsApi = new TagsApi(neetoPlaywrightUtilities);
8569
- }
8570
- searchAndVerifyTags = async (tagName) => {
8571
- await this.page.getByTestId(TAGS_SELECTORS.searchTextField).fill(tagName);
8572
- await expect(this.page.getByRole("row", { name: tagName })).toBeVisible();
8573
- };
8574
- addTagViaUI = async ({ tagName, addTagsLabel, }) => {
8575
- await this.page
8576
- .getByTestId(COMMON_SELECTORS.header)
8577
- .getByTestId(TAGS_SELECTORS.newTagButton)
8578
- .click();
8579
- await expect(this.page.getByTestId(COMMON_SELECTORS.sheetHeader)).toHaveText(addTagsLabel);
8580
- await this.page.getByTestId(TAGS_SELECTORS.tagNameTextField).fill(tagName);
8581
- await this.page
8582
- .getByTestId(TAGS_SELECTORS.descriptionTextArea)
8583
- .fill(faker.lorem.word(7));
8584
- await this.page.getByTestId(TAGS_SELECTORS.submitButton).click();
8585
- await this.neetoPlaywrightUtilities.verifyToast();
8586
- await this.neetoPlaywrightUtilities.waitForSheetClose();
8587
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8588
- };
8589
- filterTagsViaUI = async (tagName) => {
8590
- const nameBlock = this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFilterNameBlock);
8591
- const rows = this.page.getByRole("row");
8592
- const tagRow = this.page.getByRole("row", { name: tagName });
8593
- await filterUtils.openFilterPaneV2(this.page);
8594
- await this.page
8595
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersNameFilterField)
8596
- .fill(tagName);
8597
- await this.page.waitForURL(new RegExp(tagName));
8598
- await this.page
8599
- .getByTestId(NEETO_FILTERS_SELECTORS.filterDoneButton)
8600
- .click();
8601
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8602
- await Promise.all([
8603
- expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.filterPaneHeading)).toBeHidden(),
8604
- expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible(),
8605
- expect(nameBlock).toContainText(tagName),
8606
- expect(tagRow).toBeVisible(),
8607
- expect(rows).toHaveCount(2),
8608
- ]);
8609
- await filterUtils.clearFiltersFromActionBlock(this.page);
8610
- await Promise.all([
8611
- expect(nameBlock).toBeHidden(),
8612
- expect(tagRow).toBeVisible(),
8613
- expect(rows).not.toHaveCount(2),
8614
- ]);
8615
- };
8616
- editTagViaUI = async ({ tagName, newTagName, }) => {
8617
- await this.page
8618
- .getByRole("row", { name: tagName })
8619
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
8620
- .click();
8621
- await this.page.getByTestId(TAGS_SELECTORS.editButton).click();
8622
- await this.page
8623
- .getByTestId(TAGS_SELECTORS.tagNameTextField)
8624
- .fill(newTagName);
8625
- await this.page.getByTestId(TAGS_SELECTORS.submitButton).click();
8626
- await this.neetoPlaywrightUtilities.verifyToast();
8627
- await expect(this.page.getByRole("row", { name: tagName })).toBeHidden();
8628
- await expect(this.page.getByRole("row", { name: newTagName })).toBeVisible();
8629
- };
8630
- deleteTagViaUI = async (tagName) => {
8631
- await this.page
8632
- .getByRole("row", { name: tagName })
8633
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
8634
- .click();
8635
- await this.page.getByTestId(TAGS_SELECTORS.deleteButton).click();
8636
- await this.page
8637
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
8638
- .click();
8639
- await this.neetoPlaywrightUtilities.verifyToast();
8640
- await expect(this.page.getByRole("row", { name: tagName })).toBeHidden();
8641
- };
8642
- addTagsViaRequest = ({ name, description = "", tagsRequestUrl, }) => this.tagsApi.create({ body: { name, description }, tagsRequestUrl });
8643
- navigateToMergeTagsPage = async () => {
8644
- await this.page.getByTestId(MERGE_TAGS_SELECTORS.mergeTagsButton).click();
8645
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8646
- await expect(this.page.getByTestId(COMMON_SELECTORS.heading)).toHaveText(this.t("neetoTags.common.mergeTag_other"));
8647
- };
8648
- searchAndSelect = async ({ selector, tagName, rowSelector, }) => {
8649
- await this.page.getByTestId(selector).fill(tagName);
8650
- await this.page
8651
- .getByTestId(rowSelector)
8652
- .filter({ hasText: tagName })
8653
- .click();
8654
- };
8655
- mergeAndVerifyTagsViaUI = async ({ sourceTagName, destinationTagName, tagsBreadcrumbSelector, }) => {
8656
- await this.searchAndSelect({
8657
- selector: MERGE_TAGS_SELECTORS.sourceSearchTextField,
8658
- tagName: sourceTagName,
8659
- rowSelector: MERGE_TAGS_SELECTORS.sourceTagRow,
8660
- });
8661
- await this.searchAndSelect({
8662
- selector: MERGE_TAGS_SELECTORS.destinationSearchTextField,
8663
- tagName: destinationTagName,
8664
- rowSelector: MERGE_TAGS_SELECTORS.destinationTagRow,
8665
- });
8666
- await this.page.getByTestId(MERGE_TAGS_SELECTORS.mergeButton).click();
8667
- await expect(this.page.getByTestId(COMMON_SELECTORS.dialogHeader)).toHaveText(this.t("neetoTags.common.mergeTag_other"));
8668
- await this.page.getByTestId(MERGE_TAGS_SELECTORS.proceedButton).click();
8669
- await this.neetoPlaywrightUtilities.verifyToast();
8670
- await this.page.getByTestId(tagsBreadcrumbSelector).click();
8671
- await expect(this.page.getByText(sourceTagName)).toBeHidden();
8672
- await expect(this.page.getByText(destinationTagName)).toBeVisible();
8673
- };
8674
- }
8675
-
8676
6736
  const USER_AGENTS = {
8677
6737
  windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36",
8678
6738
  mac: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36",
@@ -8730,10 +6790,6 @@ const FILE_FORMATS = {
8730
6790
  gif: "gif",
8731
6791
  };
8732
6792
 
8733
- const TEAM_MEMBER_TEXTS = {
8734
- emailSubject: "Your team members export is here",
8735
- };
8736
-
8737
6793
  const KEYBOARD_SHORTCUT_TEST_CASES = [
8738
6794
  { os: "windows", agent: USER_AGENTS.windows },
8739
6795
  { os: "mac", agent: USER_AGENTS.mac },
@@ -9099,128 +7155,83 @@ const toggleColumnCheckboxAndVerifyVisibility = async ({ page, tableColumns, sho
9099
7155
  });
9100
7156
  }
9101
7157
  };
7158
+ // The checkbox column and some product columns render no column menu, so only
7159
+ // the columns between the first and last menu are frozen and unfrozen.
9102
7160
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
9103
7161
  const verifyFreezeColumnAction = async (page, _t) => {
9104
7162
  const columnHeader = page.getByRole("columnheader");
9105
- const [columnHeaders, originalColumnNames, checkboxVisible] = await Promise.all([
7163
+ const columnsDropdown = page.getByTestId(COMMON_SELECTORS.columnsDropdownContainer);
7164
+ (await columnsDropdown.isVisible()) && (await page.keyboard.press("Escape"));
7165
+ await expect(columnsDropdown).toBeHidden();
7166
+ // A column menu only appears once the real header row has rendered, so wait
7167
+ // for one before reading the headers.
7168
+ await expect(
7169
+ // eslint-disable-next-line playwright/no-nth-methods
7170
+ columnHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).first()).toBeAttached();
7171
+ const [columnHeaders, originalColumnNames] = await Promise.all([
9106
7172
  columnHeader.all(),
9107
7173
  columnHeader.allTextContents(),
9108
- columnHeader.getByRole("checkbox").isVisible(),
9109
7174
  ]);
9110
- const columnOffset = checkboxVisible ? 1 : 0;
9111
- const moreThanFiveColumns = columnHeaders.length > 5;
9112
- moreThanFiveColumns &&
9113
- (await page.evaluate(() => {
9114
- document.body.style.zoom = "0.25";
9115
- }));
9116
- await unFreezeAllColumns({ columnHeaders, columnOffset, page });
9117
- await toggleColumnState({ columnHeaders, columnOffset, page });
9118
- await validateColumnNames(columnHeaders, columnOffset, originalColumnNames);
9119
- await toggleColumnState({
7175
+ const hasMenu = await Promise.all(columnHeaders.map(async (header) => (await header.getByTestId(TABLE_SELECTORS.columnMenuButton).count()) > 0));
7176
+ const range = {
9120
7177
  columnHeaders,
9121
- columnOffset,
9122
- action: "Unfreeze",
7178
+ firstIndex: hasMenu.indexOf(true),
7179
+ lastIndex: hasMenu.lastIndexOf(true),
9123
7180
  page,
9124
- });
9125
- await expect(columnHeader).toHaveText(originalColumnNames);
9126
- moreThanFiveColumns &&
9127
- (await page.evaluate(() => {
9128
- document.body.style.zoom = "1";
9129
- }));
9130
- };
9131
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
9132
- const verifyFreezeColumnActionV2 = async (page, _t) => {
9133
- const columnHeader = page.getByRole("columnheader");
9134
- const [columnHeaders, originalColumnNames, checkboxVisible] = await Promise.all([
9135
- columnHeader.all(),
9136
- columnHeader.allTextContents(),
9137
- columnHeader.getByRole("checkbox").isVisible(),
9138
- ]);
9139
- const columnOffset = checkboxVisible ? 1 : 0;
7181
+ };
7182
+ expect(range.firstIndex, "No column renders a column menu, so this table offers no column freeze").toBeGreaterThan(-1);
9140
7183
  const moreThanFiveColumns = columnHeaders.length > 5;
9141
7184
  moreThanFiveColumns &&
9142
7185
  (await page.evaluate(() => {
9143
7186
  document.body.style.zoom = "0.25";
9144
7187
  }));
9145
- await unFreezeAllColumnsV2({ columnHeaders, columnOffset, page });
9146
- await toggleColumnStateV2({ columnHeaders, columnOffset, page });
9147
- await validateColumnNamesV2(columnHeaders, columnOffset, originalColumnNames);
9148
- await toggleColumnStateV2({
9149
- columnHeaders,
9150
- columnOffset,
9151
- action: "Unfreeze",
9152
- page,
9153
- });
7188
+ await unFreezeAllColumns(range);
7189
+ await toggleColumnState(range);
7190
+ await validateColumnNames(range, originalColumnNames);
7191
+ await toggleColumnState({ ...range, action: "Unfreeze" });
9154
7192
  await expect(columnHeader).toHaveText(originalColumnNames);
9155
7193
  moreThanFiveColumns &&
9156
7194
  (await page.evaluate(() => {
9157
7195
  document.body.style.zoom = "1";
9158
7196
  }));
9159
7197
  };
9160
- const unFreezeAllColumns = async ({ columnHeaders, columnOffset, page, }) => {
9161
- const unFreezeColumnButton = freezeUnfreezeMenuItem(page, TABLE_COLUMN_TEXTS.unfreezeColumn);
9162
- for (let i = columnHeaders.length - 1; i >= columnOffset; i--) {
9163
- const currentHeader = columnHeaders[i];
9164
- await currentHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
9165
- await expect(page.getByTestId(COMMON_SELECTORS.dropdownContainer)).toBeVisible();
9166
- (await unFreezeColumnButton.isVisible())
9167
- ? await unFreezeColumnButton.click()
9168
- : await currentHeader
9169
- .getByTestId(TABLE_SELECTORS.columnMenuButton)
9170
- .click();
9171
- }
7198
+ const openColumnMenu = async (page, columnHeader) => {
7199
+ const menu = page.getByRole("menu");
7200
+ (await page.getByTestId(COMMON_SELECTORS.tooltip).isVisible()) &&
7201
+ (await page.mouse.move(0, 0));
7202
+ // Let the previous menu finish its close animation, or two menus match below.
7203
+ await expect(menu).toHaveCount(0);
7204
+ await columnHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
7205
+ await expect(menu).toBeVisible();
9172
7206
  };
9173
- const unFreezeAllColumnsV2 = async ({ columnHeaders, columnOffset, page, }) => {
7207
+ const unFreezeAllColumns = async ({ columnHeaders, firstIndex, lastIndex, page, }) => {
9174
7208
  const unFreezeColumnButton = freezeUnfreezeMenuItem(page, TABLE_COLUMN_TEXTS.unfreezeColumn);
9175
- for (let i = columnHeaders.length - 1; i >= columnOffset; i--) {
9176
- const currentHeader = columnHeaders[i];
9177
- await currentHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
9178
- await expect(page.getByRole("menu")).toBeVisible();
7209
+ // Escape closes the Radix menu visually but can leave `body` with
7210
+ // `pointer-events: none`, blocking the next column; closing it through its
7211
+ // trigger lets Radix clean up.
7212
+ const openColumnMenuButton = page
7213
+ .getByTestId(TABLE_SELECTORS.columnMenuButton)
7214
+ .and(page.locator('[aria-expanded="true"]'));
7215
+ for (let i = lastIndex; i >= firstIndex; i--) {
7216
+ await openColumnMenu(page, columnHeaders[i]);
9179
7217
  (await unFreezeColumnButton.isVisible())
9180
7218
  ? await unFreezeColumnButton.click()
9181
- : await page.keyboard.press("Escape");
9182
- }
9183
- };
9184
- const toggleColumnState = async ({ columnHeaders, columnOffset, action = "Freeze", page, }) => {
9185
- const firstColumnIndex = columnOffset;
9186
- const lastColumnIndex = columnHeaders.length - 1;
9187
- const targetIndex = action === "Freeze" ? lastColumnIndex : firstColumnIndex;
9188
- const toggleButton = freezeUnfreezeMenuItem(page, action === "Freeze"
9189
- ? TABLE_COLUMN_TEXTS.freezeColumn
9190
- : TABLE_COLUMN_TEXTS.unfreezeColumn);
9191
- for (let i = firstColumnIndex; i < lastColumnIndex; i++) {
9192
- const columnHeader = columnHeaders[targetIndex];
9193
- (await page.getByTestId(COMMON_SELECTORS.tooltip).isVisible()) &&
9194
- (await page.mouse.move(0, 0));
9195
- await columnHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
9196
- await toggleButton.click();
7219
+ : await openColumnMenuButton.click({ force: true });
9197
7220
  }
9198
7221
  };
9199
- const toggleColumnStateV2 = async ({ columnHeaders, columnOffset, action = "Freeze", page, }) => {
9200
- const firstColumnIndex = columnOffset;
9201
- const lastColumnIndex = columnHeaders.length - 1;
9202
- const targetIndex = action === "Freeze" ? lastColumnIndex : firstColumnIndex;
7222
+ const toggleColumnState = async ({ columnHeaders, firstIndex, lastIndex, action = "Freeze", page, }) => {
7223
+ const targetIndex = action === "Freeze" ? lastIndex : firstIndex;
9203
7224
  const toggleButton = freezeUnfreezeMenuItem(page, action === "Freeze"
9204
7225
  ? TABLE_COLUMN_TEXTS.freezeColumn
9205
7226
  : TABLE_COLUMN_TEXTS.unfreezeColumn);
9206
- for (let i = firstColumnIndex; i < lastColumnIndex; i++) {
9207
- const columnHeader = columnHeaders[targetIndex];
9208
- (await page.getByTestId(COMMON_SELECTORS.tooltip).isVisible()) &&
9209
- (await page.mouse.move(0, 0));
9210
- await columnHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
7227
+ for (let i = firstIndex; i < lastIndex; i++) {
7228
+ await openColumnMenu(page, columnHeaders[targetIndex]);
9211
7229
  await toggleButton.click();
9212
7230
  }
9213
7231
  };
9214
- const validateColumnNames = async (columnHeaders, columnOffset, originalColumnNames) => {
9215
- for (let i = columnOffset; i < originalColumnNames.length - 1; i++) {
9216
- const expectedName = originalColumnNames[i + 1];
9217
- await expect(columnHeaders[i]).toHaveText(expectedName);
9218
- }
9219
- };
9220
- const validateColumnNamesV2 = async (columnHeaders, columnOffset, originalColumnNames) => {
9221
- const lastColumnIndex = columnHeaders.length - 1;
9222
- for (let i = columnOffset; i < lastColumnIndex; i++) {
9223
- await expect(columnHeaders[i]).toHaveText(originalColumnNames[columnOffset + lastColumnIndex - i]);
7232
+ const validateColumnNames = async ({ columnHeaders, firstIndex, lastIndex }, originalColumnNames) => {
7233
+ for (let i = firstIndex; i < lastIndex; i++) {
7234
+ await expect(columnHeaders[i]).toHaveText(originalColumnNames[firstIndex + lastIndex - i]);
9224
7235
  }
9225
7236
  };
9226
7237
  const verifyReorderColumns = async (page) => {
@@ -9263,7 +7274,6 @@ const tableUtils = {
9263
7274
  assertColumnHeaderVisibility,
9264
7275
  toggleColumnCheckboxAndVerifyVisibility,
9265
7276
  verifyFreezeColumnAction,
9266
- verifyFreezeColumnActionV2,
9267
7277
  verifyReorderColumns,
9268
7278
  };
9269
7279
 
@@ -9298,6 +7308,34 @@ const executeWithThrottledResources = async ({ code: emulatedCode, kind = "both"
9298
7308
  await cpuThrottlingUsingCDP({ cdpSession, rate: 1 });
9299
7309
  };
9300
7310
 
7311
+ const openFilterPane = async (page) => {
7312
+ await page
7313
+ .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7314
+ .or(page.getByTestId(COMMON_SELECTORS.filterButon))
7315
+ .click();
7316
+ await expect(page.getByTestId(NEETO_FILTERS_SELECTORS.filterPaneHeading)).toHaveText(getI18nInstance().t("neetoFilters.common.filters"));
7317
+ };
7318
+ const clearFiltersFromActionBlock = async (page) => {
7319
+ const isClearButtonVisible = await page
7320
+ .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)
7321
+ .isVisible();
7322
+ if (isClearButtonVisible) {
7323
+ await page
7324
+ .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)
7325
+ .click();
7326
+ await Promise.all([
7327
+ expect(page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeHidden(),
7328
+ expect(page.locator(COMMON_SELECTORS.tableSpinner)).toHaveCount(0, {
7329
+ timeout: 15_000,
7330
+ }),
7331
+ ]);
7332
+ }
7333
+ };
7334
+ const filterUtils = {
7335
+ openFilterPane,
7336
+ clearFiltersFromActionBlock,
7337
+ };
7338
+
9301
7339
  const getAmountWithSymbol = (amount, options) => {
9302
7340
  const formatter = new Intl.NumberFormat(dayjs.locale(), {
9303
7341
  ...options,
@@ -12291,11 +10329,9 @@ const DEFAULT_WARMUP_URLS = ["/login"];
12291
10329
  async function warmup({ urls = DEFAULT_WARMUP_URLS, timeout = 60_000, } = {}) {
12292
10330
  if (!IS_DEV_ENV)
12293
10331
  return;
12294
- const { RAILS_SERVER_PORT, SUBDOMAIN = "spinkart" } = process.env;
12295
- if (!RAILS_SERVER_PORT) {
12296
- throw new Error("RAILS_SERVER_PORT is not defined in environment variables.");
12297
- }
12298
- const baseURL = `http://${SUBDOMAIN}.lvh.me:${RAILS_SERVER_PORT}`;
10332
+ const railsServerPort = requireEnv("RAILS_SERVER_PORT");
10333
+ const subdomain = process.env.SUBDOMAIN ?? "spinkart";
10334
+ const baseURL = `http://${subdomain}.lvh.me:${railsServerPort}`;
12299
10335
  const browser = await chromium.launch();
12300
10336
  const page = await browser.newPage();
12301
10337
  try {
@@ -12310,6 +10346,22 @@ async function warmup({ urls = DEFAULT_WARMUP_URLS, timeout = 60_000, } = {}) {
12310
10346
  }
12311
10347
  }
12312
10348
 
10349
+ /** Check for an HTTP response without following redirects or downloading its body. */
10350
+ const httpCheck = async (url, timeout = 3000) => {
10351
+ try {
10352
+ const response = await fetch(url, {
10353
+ redirect: "manual",
10354
+ signal: AbortSignal.timeout(timeout),
10355
+ });
10356
+ // Any status means the server is listening, including redirects and errors.
10357
+ await response.body?.cancel();
10358
+ return true;
10359
+ }
10360
+ catch {
10361
+ return false;
10362
+ }
10363
+ };
10364
+
12313
10365
  const DIR = "/tmp/neeto-auth-web";
12314
10366
  const CONFIG$1 = {
12315
10367
  DIR,
@@ -12342,14 +10394,7 @@ const buildEmailCaptureInitializer = (targetApp) => {
12342
10394
  return template.replace("{{TARGET_APP}}", escapeRubyString(targetApp));
12343
10395
  };
12344
10396
  const log$1 = (msg) => console.log(`[NeetoAuth] ${msg}`);
12345
- const httpCheck$1 = (port, timeout = 3000) => new Promise(resolve => {
12346
- const req = http.get(`http://localhost:${port}/`, () => resolve(true));
12347
- req.on("error", () => resolve(false));
12348
- req.setTimeout(timeout, () => {
12349
- req.destroy();
12350
- resolve(false);
12351
- });
12352
- });
10397
+ const isServerListening$1 = () => httpCheck(`http://localhost:${CONFIG$1.PORT}/`);
12353
10398
  const pollUntil = async (check, timeoutMs, intervalMs) => {
12354
10399
  const deadline = Date.now() + timeoutMs;
12355
10400
  while (Date.now() < deadline) {
@@ -12516,7 +10561,7 @@ class NeetoAuthServer {
12516
10561
  if (this.process !== null && this.process.exitCode !== null) {
12517
10562
  throw new Error(`[NeetoAuth] Server process exited unexpectedly with code ${this.process.exitCode}.\nLog:\n${readServerLog()}`);
12518
10563
  }
12519
- return httpCheck$1(CONFIG$1.PORT);
10564
+ return isServerListening$1();
12520
10565
  }, timeoutMs, CONFIG$1.WAIT_FOR_SERVER_POLL_MS);
12521
10566
  if (started)
12522
10567
  return;
@@ -12556,7 +10601,7 @@ class NeetoAuthServer {
12556
10601
  const currentContent = fs.readFileSync(CONFIG$1.EMAIL_INIT, "utf-8");
12557
10602
  return currentContent === buildEmailCaptureInitializer(this.targetApp);
12558
10603
  };
12559
- isServingCurrentApp = async () => (await httpCheck$1(CONFIG$1.PORT)) && this.isRunningForCurrentApp();
10604
+ isServingCurrentApp = async () => (await isServerListening$1()) && this.isRunningForCurrentApp();
12560
10605
  start = async () => {
12561
10606
  if (IS_STAGING_ENV)
12562
10607
  return;
@@ -12577,7 +10622,7 @@ class NeetoAuthServer {
12577
10622
  log$1("Server already running for this app.");
12578
10623
  return;
12579
10624
  }
12580
- if (await httpCheck$1(CONFIG$1.PORT)) {
10625
+ if (await isServerListening$1()) {
12581
10626
  log$1("Server running for a different app — restarting...");
12582
10627
  await this.killServerOnPort();
12583
10628
  }
@@ -12629,14 +10674,7 @@ const DEFAULT_STATE = { pid: null, refCount: 0 };
12629
10674
  const WIDGET_BASE_URL = `http://localhost:${CONFIG.PORT}`;
12630
10675
  const SCRIPTS_DIR = path.join(import.meta.dirname, "scripts", "neeto-chat-widget");
12631
10676
  const log = (msg) => console.log(`[NeetoChatWidget] ${msg}`);
12632
- const httpCheck = (timeout = 3000) => new Promise(resolve => {
12633
- const req = http.get(`${WIDGET_BASE_URL}/main.js`, () => resolve(true));
12634
- req.on("error", () => resolve(false));
12635
- req.setTimeout(timeout, () => {
12636
- req.destroy();
12637
- resolve(false);
12638
- });
12639
- });
10677
+ const isServerListening = () => httpCheck(`${WIDGET_BASE_URL}/main.js`);
12640
10678
  class NeetoChatWidget {
12641
10679
  process = null;
12642
10680
  hasLease = false;
@@ -12776,7 +10814,7 @@ class NeetoChatWidget {
12776
10814
  if (this.process !== null && this.process.exitCode !== null) {
12777
10815
  throw new Error(`[NeetoChatWidget] Server process exited unexpectedly with code ${this.process.exitCode}.\nLog:\n${this.getLogContent()}`);
12778
10816
  }
12779
- if (await httpCheck())
10817
+ if (await isServerListening())
12780
10818
  return;
12781
10819
  await setTimeout$1(CONFIG.SERVER_POLL_INTERVAL_MS);
12782
10820
  }
@@ -12787,7 +10825,7 @@ class NeetoChatWidget {
12787
10825
  return;
12788
10826
  await this.withLock(async () => {
12789
10827
  const state = this.readState();
12790
- if (await httpCheck()) {
10828
+ if (await isServerListening()) {
12791
10829
  this.hasLease = true;
12792
10830
  this.writeState({ ...state, refCount: state.refCount + 1 });
12793
10831
  log("Server already running.");
@@ -12809,7 +10847,7 @@ class NeetoChatWidget {
12809
10847
  const pid = this.process?.pid;
12810
10848
  this.killServer(pid);
12811
10849
  pid && (await this.waitForProcessExit(pid));
12812
- (await httpCheck()) && (await this.killProcessOnWidgetPort());
10850
+ (await isServerListening()) && (await this.killProcessOnWidgetPort());
12813
10851
  this.process = null;
12814
10852
  this.closeLogStream();
12815
10853
  throw error;
@@ -12837,7 +10875,7 @@ class NeetoChatWidget {
12837
10875
  log("Stopping server...");
12838
10876
  this.killServer(state.pid);
12839
10877
  await this.waitForProcessExit(state.pid);
12840
- (await httpCheck()) && (await this.killProcessOnWidgetPort());
10878
+ (await isServerListening()) && (await this.killProcessOnWidgetPort());
12841
10879
  }
12842
10880
  this.process = null;
12843
10881
  this.closeLogStream();
@@ -12881,11 +10919,7 @@ class EmailDeliveryUtils {
12881
10919
  }
12882
10920
  connectViaRequest = async ({ provider, ownerId }) => {
12883
10921
  if (provider === "sparkpost") {
12884
- const sparkpostEmailEnvKey = FROM_EMAIL_ENV_KEYS.sparkpost;
12885
- const email = process.env[sparkpostEmailEnvKey];
12886
- if (isNil(email)) {
12887
- throw new Error(`ENV variable ${sparkpostEmailEnvKey} is not properly configured`);
12888
- }
10922
+ const email = requireEnv(FROM_EMAIL_ENV_KEYS.sparkpost);
12889
10923
  const response = await this.emailDeliveryApi.connect({
12890
10924
  emailProvider: "sparkpost",
12891
10925
  email,
@@ -12894,11 +10928,7 @@ class EmailDeliveryUtils {
12894
10928
  expect(response?.ok()).toBeTruthy();
12895
10929
  return response;
12896
10930
  }
12897
- const refreshTokenEnvKey = REFRESH_TOKEN_ENV_KEYS[provider];
12898
- const refreshToken = process.env[refreshTokenEnvKey];
12899
- if (isNil(refreshToken)) {
12900
- throw new Error(`ENV variable ${refreshTokenEnvKey} is not properly configured`);
12901
- }
10931
+ const refreshToken = requireEnv(REFRESH_TOKEN_ENV_KEYS[provider]);
12902
10932
  const response = await this.emailDeliveryApi.connect({
12903
10933
  emailProvider: provider,
12904
10934
  refreshToken,
@@ -12908,10 +10938,7 @@ class EmailDeliveryUtils {
12908
10938
  return response;
12909
10939
  };
12910
10940
  verifyEmailViaRequest = async ({ subject, to, partialBody, from }, { provider, ownerId, timeout = 30 * 1000, shouldThrowErrorOnTimeout = true, }) => {
12911
- const fromEmail = from ?? process.env[FROM_EMAIL_ENV_KEYS[provider]];
12912
- if (isNil(fromEmail)) {
12913
- throw new Error(`ENV variable ${FROM_EMAIL_ENV_KEYS[provider]} is not properly configured`);
12914
- }
10941
+ const fromEmail = from ?? requireEnv(FROM_EMAIL_ENV_KEYS[provider]);
12915
10942
  const verifyParams = {
12916
10943
  emailProvider: provider,
12917
10944
  subject,
@@ -13296,10 +11323,7 @@ class InboundEmailApis {
13296
11323
  : this.deliverViaMailgunIngress(source);
13297
11324
  };
13298
11325
  deliverViaMailgunIngress = (source) => {
13299
- const signingKey = process.env.MAILGUN_INGRESS_SIGNING_KEY;
13300
- if (!signingKey) {
13301
- throw new Error("MAILGUN_INGRESS_SIGNING_KEY is required to inject inbound emails outside development");
13302
- }
11326
+ const signingKey = requireEnv("MAILGUN_INGRESS_SIGNING_KEY");
13303
11327
  const timestamp = Math.floor(Date.now() / 1000).toString();
13304
11328
  const token = randomBytes(25).toString("hex");
13305
11329
  const signature = createHmac("sha256", signingKey)
@@ -13313,4 +11337,4 @@ class InboundEmailApis {
13313
11337
  };
13314
11338
  }
13315
11339
 
13316
- export { ACME_SUBDOMAIN, ACTIONS, ADMIN_PANEL_SELECTORS, ALL_RESOURCES, ANALYTICS_RESOURCES, API_KEYS_SELECTORS, API_ROUTES, APP_RESOURCES, AUDIT_LOGS_SELECTORS, ApiKeysApi, ApiKeysPage, ApiKeysPageV2, AuditLogsPage, BASE_URL, CALENDAR_LABELS, CERTIFICATE_LIMIT_EXCEEDED_MESSAGE, CERTIFICATE_LIMIT_EXCEEDED_REGEXP, CERTIFICATE_PROVISION_FAILED_MESSAGE, CERTIFICATE_PROVISION_FAILED_REGEXP, CHANGELOG_WIDGET_SELECTORS, CHAT_WIDGET_SELECTORS, CHAT_WIDGET_TEXTS, COLOR, COMMON_SELECTORS, COMMON_TEXTS, COMMUNITY_TEXTS, CREDENTIALS, CURRENT_TIME_RANGES, CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX, CUSTOM_DOMAIN_SELECTORS, CUSTOM_DOMAIN_SUFFIX, ColorPickerUtils, CustomCommands, CustomCommandsV2, CustomDomainApi, CustomDomainPage, DATE_FORMATS, DATE_PICKER_SELECTORS, DATE_RANGES, DATE_TEXTS, DEFAULT_TIMEZONE_ID, DEFAULT_WEBHOOKS_RESPONSE_TEXT, DESCRIPTION_EDITOR_TEXTS, EDITOR_VERIFY_TEXT_COLOR, EMBED_SELECTORS, EMOJI_LABEL, EMPTY_STORAGE_STATE, ENGAGE_TEXTS, ENVIRONMENT, EXAMPLE_URL, EXPANDED_FONT_SIZE, EXPORT_FILE_TYPES, EditorPage, EmailDeliveryUtils, EmbedBase, FILE_FORMATS, FONTS_RESOURCES, FONT_SIZE_SELECTORS, FROM_EMAIL_ENV_KEYS, GLOBAL_TRANSLATIONS_PATTERN, GOOGLE_ANALYTICS_SELECTORS, GOOGLE_CALENDAR_DATE_FORMAT, GOOGLE_LOGIN_SELECTORS, GOOGLE_LOGIN_TEXTS, GOOGLE_SHEETS_SELECTORS, GooglePage, HELP_CENTER_ROUTES, HELP_CENTER_SELECTORS, HelpAndProfilePage, HelpAndProfilePageV2, INTEGRATIONS_TEXTS, INTEGRATION_SELECTORS, IPRestrictionsPage, IP_RESTRICTIONS_SELECTORS, IS_CI, IS_DEV_CI, IS_DEV_ENV, IS_MAILPIT_ENABLED, IS_PLAYWRIGHT_RUN, IS_REVIEW_ENV, IS_SHADCN_UI, IS_STAGING_ENV, IS_WEBKIT, ImageUploader, InboundEmailApis, IntegrationBase, IpRestrictionsApi, KEYBOARD_SHORTCUTS_SELECTORS, KEYBOARD_SHORTCUT_TEST_CASES, LIST_MODIFIER_SELECTORS, LIST_MODIFIER_TAGS, LOGIN_DEFAULTS, LOGIN_SELECTORS, LOGIN_STRATEGIES, LOGIN_TIMEOUT, MAILPIT_BASE_URL, MAILPIT_DOMAIN_NAME, MEMBER_FORM_SELECTORS, MEMBER_SELECTORS, MEMBER_TEXTS, MERGE_TAGS_SELECTORS, MICROSOFT_LOGIN_SELECTORS, MICROSOFT_LOGIN_TEXTS, MailerUtils, MailpitApi, Member, MemberApis, MicrosoftPage, NEETO_AUTH_BASE_URL, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, NEETO_IMAGE_UPLOADER_SELECTORS, NEETO_ROUTES, NEETO_SEO_SELECTORS, NEETO_TEXT_MODIFIER_SELECTORS, NeetoAuthServer, NeetoChatWidget, NeetoEmailDeliveryApi, NeetoTowerApi, ONBOARDING_SELECTORS, ORGANIZATION_TEXTS, OTP_EMAIL_PATTERN, OTP_FETCH_TIMEOUT, OrganizationPage, PAST_TIME_RANGES, PHONE_NUMBER_FORMATS, PLURAL, PRODUCT_ROLES_ROUTE_MAP, PROFILE_LINKS, PROFILE_SECTION_SELECTORS, PROJECT_NAMES, PROJECT_TRANSLATIONS_PATH, REVIEW_APP_CUSTOM_DOMAIN_SUFFIX, ROLES_SELECTORS, ROUTES, RailsEmailApiClient, RailsEmailUtils, RoleApis, RolesPage, RolesPageV2, SIGNUP_SELECTORS, SINGULAR, SLACK_DATA_QA_SELECTORS, SLACK_DEFAULT_CHANNEL, SLACK_SELECTORS, SLACK_WEB_TEXTS, STATUS_TEXTS, STORAGE_STATE, SecurityApi, SidebarSection, SlackApi, SlackPage, SmsApi, SmsUtils, TABLE_SELECTORS, TAB_SELECTORS, TAGS_SELECTORS, TEAM_MEMBER_TEXTS, TEXT_MODIFIER_ROLES, TEXT_MODIFIER_SELECTORS, TEXT_MODIFIER_TAGS, THANK_YOU_SELECTORS, THEMES_SELECTORS, THEMES_TEXTS, THIRD_PARTY_RESOURCES, THIRD_PARTY_ROUTES, TIME_RANGES, TOASTR_MESSAGES, TRAEFIK_NOT_FOUND_TEXT, TWILIO_SELECTORS, TagsApi, TagsPage, TeamMembers, TeamMembersV2, ThankYouApi, ThankYouPage, TwilioApi, USER_AGENTS, WEBHOOK_SELECTORS, WebhookSiteApi, WebhooksPage, ZAPIER_LIMIT_EXHAUSTED_MESSAGE, ZAPIER_SELECTORS, ZAPIER_TEST_EMAIL, ZAPIER_TEST_EMAIL_V2, ZAPIER_WEB_TEXTS, ZapierPage, authenticateUser, baseURLGenerator, basicHTMLContent, clearCredentials, commands, cpuThrottlingUsingCDP, createOrganizationViaApi, createOrganizationViaRake, currencyUtils, dataQa, decodeQRCodeFromFile, definePlaywrightConfig, exampleEmail, executeWithThrottledResources, extractSubdomainFromError, filterUtils, fixedMenuSelector, generatePhoneNumber, generatePhoneNumberDetails, generateRandomBypassEmail, generateRandomFile, generateStagingData, getByDataQA, getClipboardContent, getFormattedPhoneNumber, getFullUrl, getGithubToken, getGlobalUserProps, getGlobalUserState, getImagePathAndName, getIsoCodeFromPhoneCode, getListCount, globalShortcuts, grantClipboardPermissions, hexToRGB, hexToRGBA, i18nFixture, imageRegex, initializeCredentials, initializeReviewAppCredentials, initializeTestData, initializeTotp, isGithubIssueOpen, isStagingOrganizationExpired, joinHyphenCase, joinString, login, loginToReviewApp, mailpitDomainName, minutesAgo, networkConditions, networkThrottlingUsingCDP, optionSelector, readFileAsBrowserFile, readFileSyncIfExists, removeCredentialFile, reviewAppBaseURL, reviewAppOrganizationOptions, serializeFileForBrowser, shouldSkipCustomDomainSetup, shouldSkipSetupAndTeardown, simulateClickWithDelay, simulateTypingWithDelay, skipTest, squish, stealth as stealthTest, tableUtils, toCamelCase, updateCredentials, waitForReviewApp, warmup, withCookieCache, writeDataToFile };
11340
+ export { ACME_SUBDOMAIN, ACTIONS, ADMIN_PANEL_SELECTORS, ALL_RESOURCES, ANALYTICS_RESOURCES, API_ROUTES, APP_RESOURCES, AUDIT_LOGS_SELECTORS, AuditLogsPage, BASE_URL, CALENDAR_LABELS, CERTIFICATE_LIMIT_EXCEEDED_MESSAGE, CERTIFICATE_LIMIT_EXCEEDED_REGEXP, CERTIFICATE_PROVISION_FAILED_MESSAGE, CERTIFICATE_PROVISION_FAILED_REGEXP, CHANGELOG_WIDGET_SELECTORS, CHAT_WIDGET_SELECTORS, CHAT_WIDGET_TEXTS, COLOR, COMMON_SELECTORS, COMMON_TEXTS, COMMUNITY_TEXTS, CREDENTIALS, CURRENT_TIME_RANGES, CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX, CUSTOM_DOMAIN_SELECTORS, CUSTOM_DOMAIN_SUFFIX, ColorPickerUtils, CustomCommands, CustomDomainApi, CustomDomainPage, DATE_FORMATS, DATE_PICKER_SELECTORS, DATE_RANGES, DATE_TEXTS, DEFAULT_TIMEZONE_ID, DEFAULT_WEBHOOKS_RESPONSE_TEXT, DESCRIPTION_EDITOR_TEXTS, EDITOR_VERIFY_TEXT_COLOR, EMBED_SELECTORS, EMOJI_LABEL, EMPTY_STORAGE_STATE, ENGAGE_TEXTS, ENVIRONMENT, EXAMPLE_URL, EXPANDED_FONT_SIZE, EXPORT_FILE_TYPES, EditorPage, EmailDeliveryUtils, EmbedBase, FILE_FORMATS, FONTS_RESOURCES, FONT_SIZE_SELECTORS, FROM_EMAIL_ENV_KEYS, GLOBAL_TRANSLATIONS_PATTERN, GOOGLE_ANALYTICS_SELECTORS, GOOGLE_CALENDAR_DATE_FORMAT, GOOGLE_LOGIN_SELECTORS, GOOGLE_LOGIN_TEXTS, GOOGLE_SHEETS_SELECTORS, GooglePage, HELP_CENTER_ROUTES, HELP_CENTER_SELECTORS, HelpAndProfilePage, INTEGRATIONS_TEXTS, INTEGRATION_SELECTORS, IPRestrictionsPage, IP_RESTRICTIONS_SELECTORS, IS_CI, IS_DEV_CI, IS_DEV_ENV, IS_PLAYWRIGHT_RUN, IS_REVIEW_ENV, IS_STAGING_ENV, IS_WEBKIT, ImageUploader, InboundEmailApis, IntegrationBase, IpRestrictionsApi, KEYBOARD_SHORTCUTS_SELECTORS, KEYBOARD_SHORTCUT_TEST_CASES, LIST_MODIFIER_SELECTORS, LIST_MODIFIER_TAGS, LOGIN_DEFAULTS, LOGIN_SELECTORS, LOGIN_STRATEGIES, LOGIN_TIMEOUT, MAILPIT_BASE_URL, MAILPIT_DOMAIN_NAME, MICROSOFT_LOGIN_SELECTORS, MICROSOFT_LOGIN_TEXTS, MailerUtils, MailpitApi, MicrosoftPage, NEETO_AUTH_BASE_URL, NEETO_EDITOR_SELECTORS, NEETO_FILTERS_SELECTORS, NEETO_IMAGE_UPLOADER_SELECTORS, NEETO_ROUTES, NEETO_SEO_SELECTORS, NEETO_TEXT_MODIFIER_SELECTORS, NeetoAuthServer, NeetoChatWidget, NeetoEmailDeliveryApi, NeetoTowerApi, ONBOARDING_SELECTORS, ORGANIZATION_TEXTS, OTP_EMAIL_PATTERN, OTP_FETCH_TIMEOUT, OrganizationPage, PAST_TIME_RANGES, PHONE_NUMBER_FORMATS, PLURAL, PROFILE_LINKS, PROFILE_SECTION_SELECTORS, PROJECT_NAMES, PROJECT_TRANSLATIONS_PATH, REVIEW_APP_CUSTOM_DOMAIN_SUFFIX, ROUTES, RailsEmailApiClient, RailsEmailUtils, SIGNUP_SELECTORS, SINGULAR, SLACK_DATA_QA_SELECTORS, SLACK_DEFAULT_CHANNEL, SLACK_SELECTORS, SLACK_WEB_TEXTS, STATUS_TEXTS, STORAGE_STATE, SecurityApi, SidebarSection, SlackApi, SlackPage, SmsApi, SmsUtils, TABLE_SELECTORS, TAB_SELECTORS, TEXT_MODIFIER_ROLES, TEXT_MODIFIER_SELECTORS, TEXT_MODIFIER_TAGS, THANK_YOU_SELECTORS, THEMES_SELECTORS, THEMES_TEXTS, THIRD_PARTY_RESOURCES, THIRD_PARTY_ROUTES, TIME_RANGES, TOASTR_MESSAGES, TRAEFIK_NOT_FOUND_TEXT, TWILIO_SELECTORS, ThankYouApi, ThankYouPage, TwilioApi, USER_AGENTS, WebhookSiteApi, ZAPIER_LIMIT_EXHAUSTED_MESSAGE, ZAPIER_SELECTORS, ZAPIER_TEST_EMAIL, ZAPIER_WEB_TEXTS, ZapierPage, authenticateUser, baseURLGenerator, basicHTMLContent, clearCredentials, commands, cpuThrottlingUsingCDP, createOrganizationViaApi, createOrganizationViaRake, currencyUtils, dataQa, decodeQRCodeFromFile, definePlaywrightConfig, exampleEmail, executeWithThrottledResources, extractSubdomainFromError, filterUtils, fixedMenuSelector, generatePhoneNumber, generatePhoneNumberDetails, generateRandomBypassEmail, generateRandomFile, generateStagingData, getByDataQA, getClipboardContent, getFormattedPhoneNumber, getFullUrl, getGithubToken, getGlobalUserProps, getGlobalUserState, getImagePathAndName, getIsoCodeFromPhoneCode, getListCount, globalShortcuts, grantClipboardPermissions, hexToRGB, hexToRGBA, i18nFixture, imageRegex, initializeCredentials, initializeReviewAppCredentials, initializeTestData, initializeTotp, isGithubIssueOpen, isStagingOrganizationExpired, joinHyphenCase, joinString, login, loginToReviewApp, mailpitDomainName, minutesAgo, networkConditions, networkThrottlingUsingCDP, optionSelector, readFileAsBrowserFile, readFileSyncIfExists, removeCredentialFile, requireEnv, reviewAppBaseURL, reviewAppOrganizationOptions, serializeFileForBrowser, shouldSkipCustomDomainSetup, shouldSkipSetupAndTeardown, simulateClickWithDelay, simulateTypingWithDelay, skipTest, squish, stealth as stealthTest, tableUtils, toCamelCase, updateCredentials, waitForReviewApp, warmup, withCookieCache, writeDataToFile };