@bigbinary/neeto-playwright-commons 4.12.6 → 5.0.0

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 +508 -2761
  3. package/index.js +473 -2432
  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 {
@@ -324,18 +299,16 @@ const CREDENTIALS = {
324
299
  password: "welcome",
325
300
  subdomainName: "spinkart",
326
301
  };
302
+ const ACME_SUBDOMAIN = "acme";
327
303
  const OTP_EMAIL_PATTERN = "Your login code is";
328
304
  const SLACK_DEFAULT_CHANNEL = "general";
329
305
  const CUSTOM_DOMAIN_SUFFIX = "neetoautomation.com";
330
306
  const REVIEW_APP_CUSTOM_DOMAIN_SUFFIX = `review.${CUSTOM_DOMAIN_SUFFIX}`;
331
307
  const CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX = process.env.CUSTOM_DOMAIN_EDGE_CERTIFICATE_SUFFIX;
332
- const ZAPIER_TEST_EMAIL = (product) => `neeto-${product}-zapier-test@${process.env.FASTMAIL_DOMAIN_NAME}`;
333
308
  const MAILPIT_BASE_URL = "https://mailpit.neetodeployapp.com";
334
309
  const MAILPIT_DOMAIN_NAME = "mail.neetoautomation.com";
335
- const IS_MAILPIT_ENABLED = isPresent(process.env.MAILPIT_DOMAIN_NAME);
336
- const IS_SHADCN_UI = isPresent(process.env.IS_SHADCN_UI);
337
310
  const mailpitDomainName = () => process.env.MAILPIT_DOMAIN_NAME || MAILPIT_DOMAIN_NAME;
338
- const ZAPIER_TEST_EMAIL_V2 = (product) => `neeto-${product}-zapier-test@${mailpitDomainName()}`;
311
+ const ZAPIER_TEST_EMAIL = (product) => `neeto-${product}-zapier-test@${mailpitDomainName()}`;
339
312
  // constants for translation
340
313
  const SINGULAR = { count: 1 };
341
314
  const PLURAL = { count: 2 };
@@ -465,42 +438,6 @@ class MailpitApi {
465
438
  };
466
439
  }
467
440
 
468
- class MemberApis {
469
- neetoPlaywrightUtilities;
470
- teamMembersBaseUrl;
471
- teamsBaseUrl;
472
- constructor(neetoPlaywrightUtilities) {
473
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
474
- this.teamMembersBaseUrl = "/neeto_team_members";
475
- this.teamsBaseUrl = `${this.teamMembersBaseUrl}/teams`;
476
- }
477
- create = (body) => this.neetoPlaywrightUtilities.apiRequest({
478
- method: "post",
479
- url: this.teamsBaseUrl,
480
- body: { user: body },
481
- });
482
- jobStatus = (jobId) => this.neetoPlaywrightUtilities.apiRequest({
483
- url: `${this.teamsBaseUrl}/creation_status/${jobId}`,
484
- });
485
- fetch = (params = {}) => this.neetoPlaywrightUtilities.apiRequest({
486
- url: this.teamsBaseUrl,
487
- params,
488
- });
489
- fetchPermissions = () => this.neetoPlaywrightUtilities.apiRequest({
490
- url: `${this.teamMembersBaseUrl}/permissions`,
491
- });
492
- update = (memberId, body) => this.neetoPlaywrightUtilities.apiRequest({
493
- method: "put",
494
- url: `${this.teamsBaseUrl}/${memberId}`,
495
- body: { team: body },
496
- });
497
- bulkUpdate = (body) => this.neetoPlaywrightUtilities.apiRequest({
498
- method: "patch",
499
- url: `${this.teamsBaseUrl}/bulk_update`,
500
- body: { users: body },
501
- });
502
- }
503
-
504
441
  class RailsEmailApiClient {
505
442
  port = process.env.RAILS_SERVER_PORT;
506
443
  subdomain = process.env.SUBDOMAIN ?? "spinkart";
@@ -562,38 +499,6 @@ class RailsEmailApiClient {
562
499
  clearStaleEmails = (receivedBefore) => this.fetchJson(`${this.emailsEndpoint}?received_before=${encodeURIComponent(receivedBefore)}`, { method: "DELETE" });
563
500
  }
564
501
 
565
- class RoleApis {
566
- neetoPlaywrightUtilities;
567
- BASE_URL = "/neeto_team_members";
568
- ORGANIZATION_ROLES_URL = `${this.BASE_URL}/organization_roles`;
569
- constructor(neetoPlaywrightUtilities) {
570
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
571
- }
572
- fetch = (endpoint) => this.neetoPlaywrightUtilities.apiRequest({
573
- url: `${this.BASE_URL}/${endpoint}`,
574
- });
575
- addRole = (roleName, permissionIds) => this.neetoPlaywrightUtilities.apiRequest({
576
- url: this.ORGANIZATION_ROLES_URL,
577
- method: "post",
578
- data: {
579
- organization_role: {
580
- name: roleName,
581
- permission_ids: permissionIds,
582
- },
583
- },
584
- });
585
- editRole = (roleId, body) => this.neetoPlaywrightUtilities.apiRequest({
586
- url: `${this.ORGANIZATION_ROLES_URL}/${roleId}`,
587
- method: "patch",
588
- body: { organization_role: body },
589
- });
590
- deleteRole = (roleId, standardRoleId) => this.neetoPlaywrightUtilities.apiRequest({
591
- url: `${this.ORGANIZATION_ROLES_URL}/${roleId}`,
592
- method: "delete",
593
- body: { new_role_id: standardRoleId },
594
- });
595
- }
596
-
597
502
  const SECURITY_BASE_URL = `/secure${BASE_URL}/configuration`;
598
503
  class SecurityApi {
599
504
  neetoPlaywrightUtilities;
@@ -632,18 +537,6 @@ class SecurityApi {
632
537
  });
633
538
  }
634
539
 
635
- class TagsApi {
636
- neetoPlaywrightUtilities;
637
- constructor(neetoPlaywrightUtilities) {
638
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
639
- }
640
- create = ({ body, tagsRequestUrl, }) => this.neetoPlaywrightUtilities.apiRequest({
641
- url: tagsRequestUrl,
642
- body,
643
- method: "post",
644
- });
645
- }
646
-
647
540
  const THANK_YOU_URL = "/neeto_thank_you/thank_you_configurations";
648
541
  class ThankYouApi {
649
542
  neetoPlaywrightUtilities;
@@ -675,6 +568,34 @@ class ThankYouApi {
675
568
  });
676
569
  }
677
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
+
678
599
  const NEETO_TOWER_BASE_URL = "https://ops.neetotower.com/";
679
600
  const DNS_RECORDS_BASE_URL = `${NEETO_TOWER_BASE_URL}api/v1/public/automation_tests/dns_records`;
680
601
  class NeetoTowerApi {
@@ -682,10 +603,7 @@ class NeetoTowerApi {
682
603
  apiKey;
683
604
  constructor(neetoPlaywrightUtilities) {
684
605
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
685
- if (!process.env.NEETO_TOWER_API_KEY) {
686
- throw new Error("NEETO_TOWER_API_KEY is not set");
687
- }
688
- this.apiKey = process.env.NEETO_TOWER_API_KEY;
606
+ this.apiKey = requireEnv("NEETO_TOWER_API_KEY");
689
607
  }
690
608
  apiRequest = ({ method, dnsDomainId = "", body, }) => this.neetoPlaywrightUtilities.apiRequest({
691
609
  url: `${DNS_RECORDS_BASE_URL}${dnsDomainId ? `/${dnsDomainId}` : ""}`,
@@ -706,10 +624,7 @@ class SlackApi {
706
624
  botToken;
707
625
  constructor(neetoPlaywrightUtilities) {
708
626
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
709
- if (!process.env.SLACK_BOT_TOKEN) {
710
- throw new Error("SLACK_BOT_TOKEN is not set");
711
- }
712
- this.botToken = process.env.SLACK_BOT_TOKEN;
627
+ this.botToken = requireEnv("SLACK_BOT_TOKEN");
713
628
  }
714
629
  apiRequest = (endpoint, params) => this.neetoPlaywrightUtilities.apiRequest({
715
630
  url: `https://slack.com/api/conversations.${endpoint}`,
@@ -750,14 +665,10 @@ class TwilioApi {
750
665
  defaultPhoneSid;
751
666
  constructor(neetoPlaywrightUtilities) {
752
667
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
753
- if (!process.env.TWILIO_AUTH_TOKEN ||
754
- !process.env.TWILIO_SID ||
755
- !process.env.TWILIO_DEFAULT_PHONE_SID) {
756
- throw new Error("TWILIO_AUTH_TOKEN, TWILIO_SID, and TWILIO_DEFAULT_PHONE_SID are not set");
757
- }
758
- this.authToken = process.env.TWILIO_AUTH_TOKEN;
759
- this.sid = process.env.TWILIO_SID;
760
- 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;
761
672
  }
762
673
  apiRequest = ({ endpoint, params, body, method = "get", }) => this.neetoPlaywrightUtilities.apiRequest({
763
674
  method,
@@ -812,20 +723,6 @@ const CUSTOM_DOMAIN_SELECTORS = {
812
723
  strategyContinueButton: "custom-domain-strategy-continue-button",
813
724
  onlyAddRootRadio: "custom-domain-strategy-only-add-root-radio-input",
814
725
  };
815
- const API_KEYS_SELECTORS = {
816
- countLabel: "api-keys-count",
817
- editApiKeyButton: "api-key-edit-button",
818
- deleteApiKeyButton: "api-key-delete-button",
819
- addApiKeyButton: "add-api-key-button",
820
- apiKeysLabelField: "api-keys-label-field",
821
- apiKeysExpiresAtField: "api-keys-expires-at-field",
822
- expiryDateInputError: "expiry-date-input-error",
823
- expiryDateInput: "expiry-date-input",
824
- apiKeysField: "api-keys-label-field",
825
- tokenField: "api-keys-token-field",
826
- expiresAtField: "api-keys-expires-at-field",
827
- createdAtField: "api-keys-created-at-field",
828
- };
829
726
  const IP_RESTRICTIONS_SELECTORS = {
830
727
  enableIPRestrictionChk: "enable-ip-restriction-checkbox",
831
728
  saveChanges: "ip-restriction-save-changes",
@@ -1004,7 +901,7 @@ const COMMON_SELECTORS = {
1004
901
  emailInputWrapper: "email-input-wrapper",
1005
902
  switchWrapper: "nui-switch-wrapper",
1006
903
  switchLabel: "nui-switch-item",
1007
- antdSliderRail: ".ant-slider-rail",
904
+ slider: '[data-slot="slider"]',
1008
905
  card: "neeto-molecules-card",
1009
906
  hotkeyDescription: "hotkey-description",
1010
907
  columnVisibilityBtn: (action) => `column-visibility-${action}-button`,
@@ -1037,8 +934,8 @@ const THANK_YOU_SELECTORS = {
1037
934
  showLinkToSubmitAnotherResponseSwitch: "show-link-to-submit-another-response-switch",
1038
935
  submitAnotherResponseLinkTextInputField: "submit-another-response-link-text-input-field",
1039
936
  previewEditorContent: "preview-editor-content",
1040
- redirectToExternalLinkRadioLabel: () => "neeto-thank-you-configuration-redirect-to-url-label",
1041
- 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`,
1042
939
  saveChangesButton: "neeto-thank-you-configuration-save-button",
1043
940
  cancelButton: "neeto-thank-you-configuration-cancel-button",
1044
941
  thankYouPageImage: "thank-you-page-image",
@@ -1147,13 +1044,6 @@ const CHAT_WIDGET_TEXTS = {
1147
1044
  welcomeChatBubble: "Hi! I'm here to assist you with any questions you may have. What can I do for you?",
1148
1045
  preChatQuestions: "Please fill in the form to start chatting.",
1149
1046
  };
1150
- const MEMBER_TEXTS = {
1151
- agent: "Agent",
1152
- admin: "Admin",
1153
- selectAll: "Select All",
1154
- hide: "Hide all",
1155
- show: "Show all",
1156
- };
1157
1047
  const INTEGRATIONS_TEXTS = {
1158
1048
  connectHeader: (integration) => `Connect your ${integration} account`,
1159
1049
  connectedHeader: (integration) => `${integration} is connected`,
@@ -1408,24 +1298,29 @@ const startLockRefresh = (redis, provider) => {
1408
1298
  }, LOCK_REFRESH_INTERVAL_MS);
1409
1299
  return () => clearInterval(interval);
1410
1300
  };
1411
- const pollForCookies = (redis, provider, context) => {
1301
+ const pollForCookies = async (redis, provider, context) => {
1412
1302
  log$2(`"${provider}" lock held by another shard — waiting for cached cookies`);
1413
- let timedOut = false;
1414
- const timeout = new Promise((_, reject) => setTimeout(() => {
1415
- timedOut = true;
1416
- reject(new Error(`[cookieCache] Timed out waiting for "${provider}" cookies from another shard`));
1417
- }, 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
+ });
1418
1308
  const poll = async () => {
1419
- while (!timedOut) {
1420
- await setTimeout$1(POLL_INTERVAL_MS);
1309
+ while (true) {
1310
+ await setTimeout$1(POLL_INTERVAL_MS, undefined, { signal });
1421
1311
  if (await restoreCookies(redis, provider, context))
1422
1312
  return true;
1313
+ signal.throwIfAborted();
1423
1314
  if (!(await redis.exists(lockKey(provider))))
1424
1315
  return false;
1425
1316
  }
1426
- return false;
1427
1317
  };
1428
- return Promise.race([poll(), timeout]);
1318
+ try {
1319
+ return await Promise.race([poll(), timeout]);
1320
+ }
1321
+ finally {
1322
+ controller.abort();
1323
+ }
1429
1324
  };
1430
1325
  const cacheCookies = async (redis, provider, context, allowedDomains) => {
1431
1326
  const cookies = (await context.cookies()).filter(({ domain }) => allowedDomains.some(d => domain.includes(d)));
@@ -1539,16 +1434,13 @@ class GooglePage extends IntegrationBase {
1539
1434
  if (IS_DEV_ENV)
1540
1435
  return;
1541
1436
  return withCookieCache("google", this.page.context(), async () => {
1542
- if (isNil(process.env.GOOGLE_LOGIN_EMAIL) ||
1543
- isNil(process.env.GOOGLE_LOGIN_PASSWORD)) {
1544
- throw new Error("ENV variable GOOGLE_LOGIN_EMAIL or GOOGLE_LOGIN_PASSWORD is not properly configured");
1545
- }
1437
+ const env = requireEnv("GOOGLE_LOGIN_EMAIL", "GOOGLE_LOGIN_PASSWORD");
1546
1438
  await this.page.goto(THIRD_PARTY_ROUTES.google.signin, {
1547
1439
  timeout: 20_000,
1548
1440
  });
1549
1441
  await this.page
1550
1442
  .getByLabel(GOOGLE_LOGIN_TEXTS.emailOrPhone)
1551
- .pressSequentially(process.env.GOOGLE_LOGIN_EMAIL, { delay: 10 });
1443
+ .pressSequentially(env.GOOGLE_LOGIN_EMAIL, { delay: 10 });
1552
1444
  await this.page
1553
1445
  .getByRole("button", { name: GOOGLE_LOGIN_TEXTS.next })
1554
1446
  .click();
@@ -1557,7 +1449,7 @@ class GooglePage extends IntegrationBase {
1557
1449
  await expect(this.page.getByText(GOOGLE_LOGIN_TEXTS.showPassword)).toBeVisible({ timeout: 10_000 });
1558
1450
  await this.page
1559
1451
  .getByLabel(GOOGLE_LOGIN_TEXTS.enterYourPassword)
1560
- .pressSequentially(process.env.GOOGLE_LOGIN_PASSWORD, {
1452
+ .pressSequentially(env.GOOGLE_LOGIN_PASSWORD, {
1561
1453
  delay: 10,
1562
1454
  timeout: 20_000,
1563
1455
  });
@@ -1712,12 +1604,10 @@ const createOrganizationViaRake = async ({ email, firstName, lastName, subdomain
1712
1604
  return stdout.trim();
1713
1605
  };
1714
1606
  const createOrganizationViaApi = async ({ page, email, firstName, lastName, businessName, subdomainName, redirectUri, timeZone = DEFAULT_TIMEZONE_ID, }) => {
1715
- if (!process.env.OTP_BYPASS_KEY) {
1716
- throw new Error("OTP_BYPASS_KEY environment variable is required to create organizations via the quick setups API.");
1717
- }
1607
+ const otpBypassKey = requireEnv("OTP_BYPASS_KEY");
1718
1608
  const response = await page.request.post(`${NEETO_AUTH_BASE_URL()}/api/v1/internal/quick_setups`, {
1719
1609
  headers: {
1720
- Authorization: `Token token="${process.env.OTP_BYPASS_KEY}"`,
1610
+ Authorization: `Token token="${otpBypassKey}"`,
1721
1611
  },
1722
1612
  data: {
1723
1613
  setup: {
@@ -1978,12 +1868,6 @@ class OrganizationPage {
1978
1868
  await this.runLoginStrategy(params, email);
1979
1869
  await this.dismissAuthenticatorSetupPromptIfPresent();
1980
1870
  };
1981
- /** @deprecated Use `login({ email, via: "authenticatorApp" })`. */
1982
- loginViaAuthenticatorApp = email => this.login({ email, via: LOGIN_STRATEGIES.authenticatorApp });
1983
- /** @deprecated Use `login({ email })`. */
1984
- loginViaSSO = email => this.login({ email });
1985
- /** @deprecated Use `login({ email, via: "emailOtp", fetchOtpFromEmail })`. */
1986
- loginWithFastmailEmail = ({ email, fetchOtpFromEmail, }) => this.login({ email, via: LOGIN_STRATEGIES.emailOtp, fetchOtpFromEmail });
1987
1871
  setupProfile = async ({ firstName = faker.person.firstName(), lastName = faker.person.lastName(), country, } = {}) => {
1988
1872
  if (IS_DEV_ENV)
1989
1873
  return;
@@ -2120,8 +2004,6 @@ class OrganizationPage {
2120
2004
  .click();
2121
2005
  await expect(countrySelector).toContainText(country);
2122
2006
  };
2123
- /** @deprecated Use `login({ via: "google" })`. */
2124
- loginViaGoogleAuth = () => this.login({ via: LOGIN_STRATEGIES.google });
2125
2007
  completeGoogleAuth = async () => {
2126
2008
  const googlePage = new GooglePage({
2127
2009
  neetoPlaywrightUtilities: this.neetoPlaywrightUtilities,
@@ -2171,13 +2053,7 @@ const REVIEW_APP_POLL_INTERVAL = 10_000;
2171
2053
  const REVIEW_APP_REQUEST_TIMEOUT = 20_000;
2172
2054
  // The host is read on each call so that a product importing the package outside
2173
2055
  // the review environment never trips the guard.
2174
- const reviewAppHost = () => {
2175
- const host = process.env.REVIEW_APP_HOST;
2176
- if (!host) {
2177
- throw new Error("REVIEW_APP_HOST must be set when TEST_ENV is review");
2178
- }
2179
- return host;
2180
- };
2056
+ const reviewAppHost = () => requireEnv("REVIEW_APP_HOST");
2181
2057
  const isReviewAppServing = async () => {
2182
2058
  try {
2183
2059
  const response = await fetch(`https://${reviewAppHost()}/?_hs=${Date.now()}`, {
@@ -2242,6 +2118,27 @@ const loginToReviewApp = async ({ page, loginPath = "/login", }) => {
2242
2118
  writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
2243
2119
  updateCredentials({ key: "isLoggedIn", value: "true" });
2244
2120
  };
2121
+ const reviewAppOrganizationOptions = ({ subdomain = CREDENTIALS.subdomainName, loginPath = "/login", } = {}) => IS_REVIEW_ENV
2122
+ ? {
2123
+ baseURL: reviewAppBaseURL(subdomain),
2124
+ storageState: async ({ browser, baseURL }, use) => {
2125
+ const context = await browser.newContext({
2126
+ ...EMPTY_STORAGE_STATE,
2127
+ baseURL,
2128
+ });
2129
+ try {
2130
+ await authenticateUser({
2131
+ page: await context.newPage(),
2132
+ loginPath,
2133
+ });
2134
+ await use(await context.storageState());
2135
+ }
2136
+ finally {
2137
+ await context.close();
2138
+ }
2139
+ },
2140
+ }
2141
+ : {};
2245
2142
 
2246
2143
  const execCommand = (command) => execSync(command, { encoding: "utf8" }).trimEnd();
2247
2144
  const joinString = (string1, string2, string3 = "", separator = " ") => {
@@ -2532,8 +2429,8 @@ const EMBED_SELECTORS = {
2532
2429
  previewTab: "preview-tab",
2533
2430
  htmlTab: "html-tab",
2534
2431
  buttonTextInput: "button-text-input-field",
2535
- buttonPositionSelectContainer: "button-position-select-value-container",
2536
- buttonPositionSelectMenu: "button-position-select-menu",
2432
+ buttonPositionSelectContainer: "button-position-select-field-select-container",
2433
+ buttonPositionSelectMenu: "button-position-select-field-select-menu",
2537
2434
  buttonColorLabel: "button-color-label",
2538
2435
  buttonTextColorLabel: "button-text-color-label",
2539
2436
  colorPickerTarget: "color-picker-target",
@@ -2689,24 +2586,6 @@ const TWILIO_SELECTORS = {
2689
2586
  authTokenField: "auth-token-input-field",
2690
2587
  };
2691
2588
 
2692
- const WEBHOOK_SELECTORS = {
2693
- addNewWebhook: "add-new-webhook-button",
2694
- endpointInputField: "endpoint-input-field",
2695
- deliveryResponseCode: "delivery-response-code",
2696
- deliveryRequestPayload: "delivery-request-payload",
2697
- addSecretKey: "add-secret-key",
2698
- newWebhookHeader: "add-new-webhook-pane-header",
2699
- endpointInputError: "endpoint-input-error",
2700
- eventsSelectError: "events-select-error",
2701
- regenerateSecret: "regenerate-secret",
2702
- deleteSecret: "delete-secret",
2703
- deliveryRequestHeader: "delivery-request-header",
2704
- deliveryResponseBody: "delivery-response-body",
2705
- eventErrorText: "event-error-text",
2706
- editWebhookButton: "neeto-webhooks-edit-button",
2707
- deleteWebhookButton: "neeto-webhooks-delete-button",
2708
- };
2709
-
2710
2589
  const ZAPIER_SELECTORS = {
2711
2590
  zapTriggerStep: (zapId) => `[data-testid='step-node-${zapId}']`,
2712
2591
  zapAccountSubstep: "[data-testid='substep-Account']",
@@ -2753,53 +2632,6 @@ const LOGIN_SELECTORS = {
2753
2632
  authenticatorAppLaterButton: "authenticator-app-promo-later-button",
2754
2633
  };
2755
2634
 
2756
- const MEMBER_SELECTORS = {
2757
- membersTab: "members-nav-tab",
2758
- newButton: "ntm-add-member-button",
2759
- continueButton: "ntm-manage-member-continue-button",
2760
- submitButton: "ntm-manage-member-submit-button",
2761
- searchTextField: "ntm-search-members-input",
2762
- deactivatedAgentsButton: "ntm-members-menubar-deactivated-block",
2763
- activatedMembersButton: "ntm-members-menubar-active-block",
2764
- columnCheckBox: "neeto-ui-columns-checkbox",
2765
- roleLabel: (role) => `${joinHyphenCase(role)}-radio-label`,
2766
- teamMembersTable: "ntm-members-table",
2767
- dropDownIcon: "ntm-members-table-row-dropdown-button",
2768
- editButton: "ntm-edit-member-button",
2769
- menuBarHeading: "ntm-members-menubar-heading",
2770
- removeMember: "ntm-deactivate-member-button",
2771
- columnsButton: "columns-dropdown-button",
2772
- columnsDropdownContainer: "columns-dropdown-container",
2773
- emailDropdownItemLabel: "email-checkbox-label",
2774
- roleDropdownItemLabel: "role-checkbox-label",
2775
- inviteStatusDropdownItemLabel: "invite-status-checkbox-label",
2776
- heading: "ntm-manage-members-pane-header",
2777
- activateButton: "ntm-activate-members-button",
2778
- deactivateButton: "ntm-deactivate-members-button",
2779
- rolesButton: "ntm-manage-member-roles-button",
2780
- statusTag: "ntm-member-status-tag",
2781
- exportMemberHeading: "export-member-heading",
2782
- downloadAsRadioItem: (fileType) => `download-as-${fileType}-radio-item`,
2783
- exportSubmitBtn: "export-submit-button",
2784
- exportCancelBtn: "export-cancel-button",
2785
- downloadButton: "download-button",
2786
- manageAppListChk: "ntm-manage-members-app-list-checkbox",
2787
- takeActionDropdown: "ntm-members-take-action-dropdown-button",
2788
- menubarSubLink: (sublink) => `members-${sublink}-block-sub-link`,
2789
- takeActionStateOption: (option = "") => `ntm-${hyphenate(option)}-members-button`,
2790
- checkboxLabel: (label) => `${hyphenate(label)}-checkbox-label`,
2791
- subscriptionPlanTag: "ntm-member-subscription-plan-tag",
2792
- memberNameCell: (nameOrEmail) => `ntm-member-name-${hyphenate(nameOrEmail)}`,
2793
- };
2794
- const MEMBER_FORM_SELECTORS = {
2795
- emailTextField: "email-select-input-field",
2796
- firstNameTextField: "ntm-edit-member-first-name-text-field",
2797
- lastNameTextField: "ntm-edit-member-last-name-text-field",
2798
- emailInput: "ntm-manage-member-email-input",
2799
- emailErrorField: "emails-input-error",
2800
- cancelButton: "ntm-manage-member-cancel-button",
2801
- };
2802
-
2803
2635
  const ONBOARDING_SELECTORS = {
2804
2636
  welcomeTitle: "onboarding-welcome-title",
2805
2637
  welcomeDescription: "onboarding-welcome-description",
@@ -2857,33 +2689,6 @@ const PROFILE_SECTION_SELECTORS = {
2857
2689
  imageRemoveBtn: "profile-image-remove-button",
2858
2690
  };
2859
2691
 
2860
- const ROLES_SELECTORS = {
2861
- newButton: "ntm-add-role-button",
2862
- proceedButton: "ntm-add-role-submit-button",
2863
- cancelButton: "ntm-add-role-cancel-button",
2864
- tableHeaderRoleName: "ntm-roles-table-role-header",
2865
- nameTextField: "ntm-add-role-name-text-field",
2866
- searchTextField: "ntm-search-roles-input",
2867
- updateRolePaneHeading: "ntm-add-role-title",
2868
- updateRoleCancelButton: "ntm-add-role-cancel-button",
2869
- descriptionTextField: "ntm-add-role-description-text-field",
2870
- permissionCategoryTitle: "ntm-roles-permission-category-title",
2871
- headerColumn: "ntm-roles-table-header",
2872
- dropDownIcon: "ntm-roles-table-header-role-dropdown-button",
2873
- tableHeaderRoleTitle: "ntm-roles-table-header-role-title",
2874
- permissionCheckbox: (name) => `ntm-roles-permission-checkbox-${hyphenate(name)}`,
2875
- editRoleButton: "ntm-roles-table-edit-role-button",
2876
- deleteRoleButton: "ntm-roles-table-delete-role-button",
2877
- permissionCard: "ntm-roles-permission-card",
2878
- searchPermissionsInput: "ntm-search-permissions-input",
2879
- permissionDescription: "ntm-permission-category-description",
2880
- rolesEditButton: "ntm-roles-table-edit-role-button",
2881
- roleCell: (roleName) => `${hyphenate(roleName)}-role-cell`,
2882
- tablePermissionCheckbox: "ntm-roles-table-permission-checkbox",
2883
- descriptionInputError: "description-input-error",
2884
- permissionSubCategoryCard: (index) => `ntm-roles-permission-sub-category-card-${index}`,
2885
- };
2886
-
2887
2692
  const NEETO_SEO_SELECTORS = {
2888
2693
  configureButton: "neeto-seo-configure-button",
2889
2694
  };
@@ -2929,37 +2734,6 @@ const TABLE_SELECTORS = {
2929
2734
  moveColumnBtn: (position) => `move-column-${position}-menu-button`,
2930
2735
  };
2931
2736
 
2932
- const TAGS_SELECTORS = {
2933
- newTagButton: "add-new-tag-button",
2934
- tagNameTextField: "tag-name-text-field",
2935
- editButton: "tags-edit-button",
2936
- deleteButton: "tags-delete-button",
2937
- cancelButton: "neeto-tags-manage-tag-cancel-button",
2938
- submitButton: "neeto-tags-manage-tag-submit-button",
2939
- searchTextField: "neeto-tags-search-text-input-field",
2940
- descriptionTextArea: "tag-description-text-area",
2941
- addTagButton: "neeto-tags-add-tag-button",
2942
- tagSearchField: "select-tag-container",
2943
- deleteTagButton: "tag-close-icon",
2944
- metaDataCard: "metadata-card",
2945
- metaDataBlock: "metadata-block",
2946
- tagContainer: "tag-container",
2947
- tagsCount: "neeto-tags-filtered-tags-count-text",
2948
- };
2949
- const MERGE_TAGS_SELECTORS = {
2950
- mergeTagsButton: "neeto-tags-merge-tags-button",
2951
- mergeButton: "neeto-tags-merge-button",
2952
- sourceSearchTextField: "neeto-tags-merge-source-search-text-input-field",
2953
- sourceTagsList: "neeto-tags-merge-source-tags-list",
2954
- destinationTagsList: "neeto-tags-merge-destination-tags-list",
2955
- destinationSearchTextField: "neeto-tags-merge-destination-search-text-input-field",
2956
- cancelButton: "neeto-tags-merge-cancel-button",
2957
- proceedButton: "neeto-tags-merge-proceed-button",
2958
- disabledTag: ".neeto-ui-cursor-not-allowed",
2959
- sourceTagRow: "neeto-tags-merge-source-tags",
2960
- destinationTagRow: "neeto-tags-merge-destination-tags",
2961
- };
2962
-
2963
2737
  const THEMES_SELECTORS = {
2964
2738
  colorPickerDropdownContainer: (colorHex) => `${colorHex}-dropdown-container`,
2965
2739
  baseThemeStyle: (styleType) => `theme-style-${hyphenate(styleType)}`,
@@ -3031,10 +2805,9 @@ const generateRandomFile = ({ sizeInKB, fileType, fileName = `sample.${fileType}
3031
2805
  const file = new File([byteArray], fileName, { type: mimeType });
3032
2806
  return { file, fileName };
3033
2807
  };
3034
- const readFileAsBrowserFile = ({ filePath, mimeType, }) => {
3035
- const buffer = new Uint8Array(readFileSync(filePath));
3036
- return new File([buffer], path__default.basename(filePath), { type: mimeType });
3037
- };
2808
+ const readFileAsBrowserFile = ({ filePath, mimeType, }) => new File([readFileSync(filePath)], path__default.basename(filePath), {
2809
+ type: mimeType,
2810
+ });
3038
2811
 
3039
2812
  const getImagePathAndName = (localImagePath) => {
3040
2813
  const imagePath = path__default.join(import.meta.dirname, localImagePath);
@@ -3074,7 +2847,7 @@ class CustomCommands {
3074
2847
  this.blockNonEssentialResourceTypes(page),
3075
2848
  ...ALL_RESOURCES.map(pattern => page.context().route(pattern, route => route.abort())),
3076
2849
  ]);
3077
- 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 });
3078
2851
  interceptMultipleResponses = ({ responseUrl = "", responseStatus = 200, times = 1, baseUrl, customPageContext = this.page, timeout = 35_000, } = {}) => Promise.all([...new Array(times)].map(() => customPageContext.waitForResponse((response) => {
3079
2852
  if (response.request().resourceType() === "xhr" &&
3080
2853
  response.status() === responseStatus &&
@@ -3102,38 +2875,7 @@ class CustomCommands {
3102
2875
  const startTime = Date.now();
3103
2876
  return await this.recursiveMethod(callback, condition, timeout, startTime, 1);
3104
2877
  };
3105
- /**
3106
- * @deprecated Targets the react-toastify-based Toastr from
3107
- * @bigbinary/neetoui. Use verifyToastV2 instead for apps whose Toastr
3108
- * comes from @bigbinary/neeto-atoms (sonner-based, e.g. neeto-engage-web).
3109
- * Kept only for apps still on the legacy neetoui Toastr.
3110
- */
3111
2878
  verifyToast = async ({ message = "", toastType = "success", closeAfterVerification = true, timeout = 10_000, toastCloseTimeout = 10_000, customPageContext = this.page, } = {}) => {
3112
- const toastrLocator = customPageContext
3113
- .locator(COMMON_SELECTORS.neetoUiToastr)
3114
- .filter({
3115
- has: customPageContext.getByTestId(COMMON_SELECTORS.toastMessage(toastType)),
3116
- });
3117
- const filteredToastrLocator = (isEmpty(message)
3118
- ? toastrLocator
3119
- : toastrLocator.filter({ hasText: message }))
3120
- // eslint-disable-next-line playwright/no-nth-methods
3121
- .first();
3122
- await expect(filteredToastrLocator).toContainText(isEmpty(message) ? TOAST_DEFAULT_MESSAGE : message, { timeout });
3123
- if (!closeAfterVerification)
3124
- return;
3125
- const toastrCloseButton = filteredToastrLocator.getByTestId(COMMON_SELECTORS.toastCloseButton);
3126
- const buttonHandle = await toastrCloseButton.elementHandle();
3127
- if (buttonHandle) {
3128
- await customPageContext.evaluate(button => {
3129
- button.dispatchEvent(new Event("click", { bubbles: true }));
3130
- }, buttonHandle);
3131
- await expect(toastrCloseButton).toBeHidden({
3132
- timeout: toastCloseTimeout,
3133
- });
3134
- }
3135
- };
3136
- verifyToastV2 = async ({ message = "", toastType = "success", closeAfterVerification = true, timeout = 10_000, toastCloseTimeout = 10_000, customPageContext = this.page, } = {}) => {
3137
2879
  const toastLocator = customPageContext.getByTestId(COMMON_SELECTORS.toastMessage(toastType));
3138
2880
  const filteredToastLocator = (isEmpty(message)
3139
2881
  ? toastLocator
@@ -3168,13 +2910,6 @@ class CustomCommands {
3168
2910
  }
3169
2911
  await Promise.all(loaders.map(loader => expect(loader).toHaveCount(0, { timeout: visibilityTimeout })));
3170
2912
  };
3171
- waitForPaneToLoad = async ({ visibilityTimeout = 35_000, customPageContext = this.page, } = {}) => {
3172
- const pane = customPageContext.getByTestId(COMMON_SELECTORS.paneBody);
3173
- await expect(pane).toBeVisible({ timeout: visibilityTimeout });
3174
- await expect(pane.getByTestId(COMMON_SELECTORS.uiSpinner)).toHaveCount(0, {
3175
- timeout: visibilityTimeout,
3176
- });
3177
- };
3178
2913
  apiRequest = async ({ url, failOnStatusCode = true, headers: additionalHeaders, body: data, method = "get", params = {}, timeout = 30_000, ...otherOptions }) => {
3179
2914
  const csrfToken = this.csrfToken ?? (await this.initializeCsrfToken());
3180
2915
  const requestOptions = {
@@ -3197,54 +2932,28 @@ class CustomCommands {
3197
2932
  })}`;
3198
2933
  return await this.request[method](formattedUrl, requestOptions);
3199
2934
  };
3200
- selectOptionFromDropdown = async ({ label = "nui", value, page = this.page, options = {}, }) => {
3201
- IS_SHADCN_UI
3202
- ? await this.selectOptionFromDropdownV2({ label, value, page, options })
3203
- : await this.selectOptionFromDropdownV1({ label, value, page, options });
3204
- };
3205
- selectOptionFromDropdownV1 = async ({ label = "nui", value, page = this.page, options = {}, }) => {
3206
- Object.assign({
3207
- visibilityTimeout: 2_000,
3208
- textAssertionTimeout: 1_000,
3209
- retryTimeout: 20_000,
3210
- }, options);
2935
+ selectOptionFromDropdown = async ({ label = "nui", value, page = this.page, options: { visibilityTimeout = 5_000, textAssertionTimeout = 5_000, retryTimeout = 60_000, } = {}, }) => {
3211
2936
  const menu = page.getByTestId(COMMON_SELECTORS.customDropDownMenu(label));
3212
- const container = page.getByTestId(COMMON_SELECTORS.customSelectValueContainer(label));
2937
+ const optionByName = menu.getByRole("option", { name: value, exact: true });
2938
+ const container = page.getByTestId(COMMON_SELECTORS.customSelectContainer(label));
3213
2939
  await expect(async () => {
3214
2940
  await container.click();
3215
- await expect(menu).toBeVisible({
3216
- timeout: options.visibilityTimeout,
3217
- });
2941
+ await expect(menu).toBeVisible({ timeout: visibilityTimeout });
3218
2942
  await page.keyboard.type(value);
3219
- await menu.getByText(value, { exact: true }).click();
2943
+ const option = (await optionByName.count()) > 0
2944
+ ? optionByName
2945
+ : menu.getByText(value, { exact: true });
2946
+ await option.click();
3220
2947
  await expect(container).toContainText(value, {
3221
- timeout: options.textAssertionTimeout,
2948
+ timeout: textAssertionTimeout,
3222
2949
  });
3223
- }).toPass({ timeout: options.retryTimeout });
2950
+ }).toPass({ timeout: retryTimeout });
3224
2951
  };
3225
2952
  waitForSheetOpen = () => expect(this.page.getByTestId(COMMON_SELECTORS.sheetHeader)).toBeInViewport({
3226
2953
  timeout: 10_000,
3227
2954
  ratio: 1,
3228
2955
  });
3229
2956
  waitForSheetClose = () => expect(this.page.getByTestId(COMMON_SELECTORS.sheetWrapper)).toHaveCount(0, { timeout: 10_000 });
3230
- selectOptionFromDropdownV2 = async ({ label = "nui", value, page = this.page, options = {}, }) => {
3231
- Object.assign({
3232
- visibilityTimeout: 2_000,
3233
- textAssertionTimeout: 1_000,
3234
- retryTimeout: 20_000,
3235
- }, options);
3236
- const menu = page.getByTestId(COMMON_SELECTORS.customDropDownMenu(label));
3237
- const container = page.getByTestId(COMMON_SELECTORS.customSelectContainer(label));
3238
- await expect(async () => {
3239
- await container.click();
3240
- await expect(menu).toBeVisible({ timeout: options.visibilityTimeout });
3241
- await page.keyboard.type(value);
3242
- await menu.getByRole("option", { name: value, exact: true }).click();
3243
- await expect(container).toContainText(value, {
3244
- timeout: options.textAssertionTimeout,
3245
- });
3246
- }).toPass({ timeout: options.retryTimeout });
3247
- };
3248
2957
  verifyFieldValue = values => {
3249
2958
  const verifyEachFieldValue = ({ field, value, }) => expect(this.page.getByTestId(field)).toHaveValue(value);
3250
2959
  return Array.isArray(values)
@@ -3298,31 +3007,43 @@ class CustomCommands {
3298
3007
  await this.hideTooltip(triggerElement, customPageContext);
3299
3008
  };
3300
3009
  verifyHelpPopover = async ({ triggerElement = this.page.getByTestId(COMMON_SELECTORS.helpPopoverButton), title, content, helpURL, customPageContext = this.page, }) => {
3301
- const tooltipBox = customPageContext.getByTestId(COMMON_SELECTORS.tooltip);
3302
3010
  await triggerElement.hover();
3303
- title &&
3304
- (await expect(tooltipBox.getByRole("heading", { name: title })).toBeVisible());
3305
- content && (await expect(tooltipBox).toContainText(content));
3011
+ const titleLocator = customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverTitle);
3012
+ const descLocator = customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverDesc);
3013
+ const linkLocator = customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverLinkButton);
3014
+ const popoverContentLocator = title
3015
+ ? titleLocator
3016
+ : content
3017
+ ? descLocator
3018
+ : linkLocator;
3019
+ title && (await expect(titleLocator).toHaveText(title));
3020
+ content && (await expect(descLocator).toContainText(content));
3306
3021
  helpURL &&
3307
3022
  (await Promise.all([
3308
3023
  this.assertHelpURLIsValid(helpURL),
3309
- expect(tooltipBox.getByTestId(COMMON_SELECTORS.helpPopoverLinkButton)).toHaveAttribute("href", new RegExp(helpURL, "i")),
3024
+ expect(linkLocator).toHaveAttribute("href", new RegExp(helpURL, "i")),
3310
3025
  ]));
3311
- await this.hideTooltip(triggerElement, customPageContext);
3026
+ await this.hidePopoverContent(popoverContentLocator, customPageContext);
3312
3027
  };
3313
- assertHelpURLIsValid = async (helpURL) => {
3314
- const response = await this.request.get(helpURL);
3028
+ assertHelpURLIsValid = (helpURL) => expect(async () => {
3029
+ const response = await this.request.get(helpURL, { timeout: 15_000 });
3315
3030
  await expect(response).toBeOK();
3316
- };
3031
+ }).toPass({ timeout: 45_000, intervals: [3_000] });
3317
3032
  verifyHelpText = async (helpURL) => {
3318
3033
  const isNoDataTitleHidden = await this.page
3319
- .getByTestId(COMMON_SELECTORS.noDataTitle)
3034
+ .getByTestId(COMMON_SELECTORS.noDataTitleV2)
3320
3035
  .isHidden();
3321
3036
  if (isNoDataTitleHidden)
3322
3037
  return;
3038
+ const helpLink = this.page
3039
+ .getByTestId(COMMON_SELECTORS.noDataHelpTextV2)
3040
+ .getByRole("link")
3041
+ .or(this.page
3042
+ .getByTestId(COMMON_SELECTORS.noDataDescriptionV2)
3043
+ .getByRole("link"));
3323
3044
  await Promise.all([
3324
3045
  this.assertHelpURLIsValid(helpURL),
3325
- expect(this.page.getByTestId(COMMON_SELECTORS.noDataHelpText).getByRole("link")).toHaveAttribute("href", new RegExp(helpURL, "i")),
3046
+ expect(helpLink).toHaveAttribute("href", new RegExp(helpURL, "i")),
3326
3047
  ]);
3327
3048
  };
3328
3049
  verifySearchTermBlock = async (searchTerm) => {
@@ -3341,7 +3062,7 @@ class CustomCommands {
3341
3062
  }
3342
3063
  };
3343
3064
  saveChanges = ({ isPane = false, customPageContext = this.page, closeAfterVerification = true, toastMessage = "", } = {}) => {
3344
- const pane = customPageContext.getByTestId(COMMON_SELECTORS.backdrop);
3065
+ const pane = customPageContext.getByTestId(COMMON_SELECTORS.sheetWrapper);
3345
3066
  const baseLocator = isPane ? pane : customPageContext;
3346
3067
  return Promise.all([
3347
3068
  this.clickButtonAndAwaitLoad({
@@ -3374,13 +3095,16 @@ class CustomCommands {
3374
3095
  await expect(async () => {
3375
3096
  for (const [moveX, moveY] of moves) {
3376
3097
  await customPageContext.mouse.move(moveX, moveY);
3377
- const tooltipCount = await tooltip.count();
3378
- if (tooltipCount === 0)
3098
+ if ((await tooltip.count()) === 0)
3379
3099
  break;
3380
3100
  }
3381
3101
  await expect(tooltip).toHaveCount(0);
3382
3102
  }).toPass({ timeout: 30_000 });
3383
3103
  };
3104
+ hidePopoverContent = async (contentLocator, customPageContext = this.page) => {
3105
+ await customPageContext.mouse.move(0, 0);
3106
+ await expect(contentLocator).toBeHidden();
3107
+ };
3384
3108
  verifyBreadcrumbs = async (titlesAndRoutes) => {
3385
3109
  const header = this.page.getByTestId(COMMON_SELECTORS.breadcrumbHeader);
3386
3110
  const titles = pluck("title", titlesAndRoutes);
@@ -3388,23 +3112,25 @@ class CustomCommands {
3388
3112
  await Promise.all([
3389
3113
  expect(header).toContainText(titles),
3390
3114
  expect(header).toHaveCount(titlesAndRoutes.length),
3391
- expect(header.getByRole("link", { name: last?.title, exact: true })).toHaveCount(0),
3115
+ expect(header.getByRole("link", { name: last?.title, exact: true })).toHaveAttribute("aria-disabled", "true"),
3392
3116
  ...links.map(({ title, route }) => expect(header.getByRole("link", { name: title, exact: true })).toHaveAttribute("href", route)),
3393
3117
  ]);
3394
3118
  };
3395
3119
  uploadFileViaDispatchV2 = async ({ droppableZone = this.page.getByTestId(COMMON_SELECTORS.fileUploadBody), dispatchEvent = "drop", timeout = 45_000, file, }) => {
3396
3120
  const serializedFile = await serializeFileForBrowser(file);
3397
- const dataTransfer = await Promise.race([
3398
- droppableZone.evaluateHandle(async (_, { name, type, buffer, lastModified }) => {
3399
- const uint8Array = new Uint8Array(buffer);
3400
- const file = new File([uint8Array], name, { type, lastModified });
3401
- const dataTransfer = new DataTransfer();
3402
- dataTransfer.items.add(file);
3403
- return dataTransfer;
3404
- }, serializedFile),
3405
- new Promise((_, reject) => setTimeout(() => reject(new Error("File injection timed out")), timeout)),
3406
- ]);
3407
- await droppableZone.dispatchEvent(dispatchEvent, { dataTransfer });
3121
+ const dataTransfer = await droppableZone.evaluateHandle((_, { name, type, buffer, lastModified }) => {
3122
+ const uint8Array = new Uint8Array(buffer);
3123
+ const file = new File([uint8Array], name, { type, lastModified });
3124
+ const dataTransfer = new DataTransfer();
3125
+ dataTransfer.items.add(file);
3126
+ return dataTransfer;
3127
+ }, serializedFile, { timeout });
3128
+ try {
3129
+ await droppableZone.dispatchEvent(dispatchEvent, { dataTransfer });
3130
+ }
3131
+ finally {
3132
+ await dataTransfer.dispose();
3133
+ }
3408
3134
  };
3409
3135
  verifyUnsavedChangesModal = async (shouldLeavePage = false) => {
3410
3136
  const alertBox = this.page.getByTestId(COMMON_SELECTORS.alertBox);
@@ -3423,7 +3149,8 @@ class CustomCommands {
3423
3149
  await expect(alertBox).toBeHidden();
3424
3150
  };
3425
3151
  setSliderValue = async ({ parentLocator = this.page, valueAsPercent, startFromCenter = false, }) => {
3426
- const sliderLocator = parentLocator.locator(COMMON_SELECTORS.antdSliderRail);
3152
+ const sliderLocator = parentLocator.locator(COMMON_SELECTORS.slider);
3153
+ await expect(sliderLocator).toBeVisible();
3427
3154
  await sliderLocator.evaluate(node => node.scrollIntoView({ behavior: "instant", block: "center" }));
3428
3155
  const sliderBoundingBox = await sliderLocator.boundingBox();
3429
3156
  let targetX = sliderBoundingBox.width * valueAsPercent;
@@ -3462,9 +3189,13 @@ class CustomCommands {
3462
3189
  });
3463
3190
  };
3464
3191
  toggleElement = ({ locator, shouldBeChecked = true }) => expect(async () => {
3465
- const isChecked = await locator.isChecked();
3466
- isChecked !== shouldBeChecked && (await locator.click());
3467
- await expect(locator).toBeChecked({ checked: shouldBeChecked });
3192
+ // Callers often pass an atoms Switch's wrapper (`<prefix>-switch`); the checkable control is the nested `nui-switch-item`.
3193
+ const switchItem = locator.getByTestId(COMMON_SELECTORS.switchLabel);
3194
+ const target =
3195
+ // eslint-disable-next-line playwright/no-nth-methods
3196
+ (await switchItem.count()) > 0 ? switchItem.first() : locator;
3197
+ (await target.isChecked()) !== shouldBeChecked && (await target.click());
3198
+ await expect(target).toBeChecked({ checked: shouldBeChecked });
3468
3199
  }).toPass({ timeout: 15_000 });
3469
3200
  // Polls the editor's own state, which is what the next key press acts on.
3470
3201
  // The DOM selection is not proof: ProseMirror re-applies its stored
@@ -3497,127 +3228,26 @@ class CustomCommands {
3497
3228
  await this.page.keyboard.press("Enter");
3498
3229
  };
3499
3230
  }
3500
- class CustomCommandsV2 extends CustomCommands {
3501
- selectOptionFromDropdown = async ({ label = "nui", value, page = this.page, options = {}, }) => {
3502
- Object.assign({
3503
- visibilityTimeout: 2_000,
3504
- textAssertionTimeout: 1_000,
3505
- retryTimeout: 20_000,
3506
- }, options);
3507
- const menu = page.getByTestId(COMMON_SELECTORS.customDropDownMenu(label));
3508
- const container = page.getByTestId(COMMON_SELECTORS.customSelectContainer(label));
3509
- await expect(async () => {
3510
- await container.click();
3511
- await expect(menu).toBeVisible({
3512
- timeout: options.visibilityTimeout,
3513
- });
3514
- await page.keyboard.type(value);
3515
- await menu.getByText(value, { exact: true }).click();
3516
- await expect(container).toContainText(value, {
3517
- timeout: options.textAssertionTimeout,
3518
- });
3519
- }).toPass({ timeout: options.retryTimeout });
3520
- };
3521
- verifyHelpPopover = async ({ triggerElement = this.page.getByTestId(COMMON_SELECTORS.helpPopoverButton), title, content, helpURL, customPageContext = this.page, }) => {
3522
- await triggerElement.hover();
3523
- const getPopoverContentLocator = () => {
3524
- if (title) {
3525
- return customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverTitle);
3526
- }
3527
- if (content) {
3528
- return customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverDesc);
3529
- }
3530
- return customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverLinkButton);
3531
- };
3532
- const popoverContentLocator = getPopoverContentLocator();
3533
- title && (await expect(popoverContentLocator).toHaveText(title));
3534
- content &&
3535
- (await expect(customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverDesc)).toContainText(content));
3536
- helpURL &&
3537
- (await Promise.all([
3538
- this.assertHelpURLIsValid(helpURL),
3539
- expect(customPageContext.getByTestId(COMMON_SELECTORS.helpPopoverLinkButton)).toHaveAttribute("href", new RegExp(helpURL, "i")),
3540
- ]));
3541
- await this.hidePopoverContent(triggerElement, popoverContentLocator, customPageContext);
3542
- };
3543
- verifyHelpText = async (helpURL) => {
3544
- const isNoDataTitleHidden = await this.page
3545
- .getByTestId(COMMON_SELECTORS.noDataTitleV2)
3546
- .isHidden();
3547
- if (isNoDataTitleHidden)
3548
- return;
3549
- const helpLink = this.page
3550
- .getByTestId(COMMON_SELECTORS.noDataHelpTextV2)
3551
- .getByRole("link")
3552
- .or(this.page
3553
- .getByTestId(COMMON_SELECTORS.noDataDescriptionV2)
3554
- .getByRole("link"));
3555
- await Promise.all([
3556
- this.assertHelpURLIsValid(helpURL),
3557
- expect(helpLink).toHaveAttribute("href", new RegExp(helpURL, "i")),
3558
- ]);
3559
- };
3560
- verifyBreadcrumbs = async (titlesAndRoutes) => {
3561
- const header = this.page.getByTestId(COMMON_SELECTORS.breadcrumbHeader);
3562
- const titles = pluck("title", titlesAndRoutes);
3563
- const [last, ...links] = titlesAndRoutes.toReversed();
3564
- await Promise.all([
3565
- expect(header).toContainText(titles),
3566
- expect(header).toHaveCount(titlesAndRoutes.length),
3567
- expect(header.getByRole("link", { name: last?.title, exact: true })).toHaveAttribute("aria-disabled", "true"),
3568
- ...links.map(({ title, route }) => expect(header.getByRole("link", { name: title, exact: true })).toHaveAttribute("href", route)),
3569
- ]);
3570
- };
3571
- hidePopoverContent = async (triggerElement, contentLocator, customPageContext = this.page) => {
3572
- const boundingBox = await triggerElement.boundingBox();
3573
- if (!boundingBox) {
3574
- throw new Error("Trigger element bounding box not found");
3575
- }
3576
- const { x, y, width, height } = boundingBox;
3577
- const moves = [
3578
- [x + width + 10, y],
3579
- [x, y + height + 10],
3580
- [x - 10, y],
3581
- [x, y - 10],
3582
- ];
3583
- await expect(async () => {
3584
- for (const [moveX, moveY] of moves) {
3585
- await customPageContext.mouse.move(moveX, moveY);
3586
- const isHidden = await contentLocator.isHidden();
3587
- if (isHidden)
3588
- break;
3589
- }
3590
- await expect(contentLocator).toBeHidden();
3591
- }).toPass({ timeout: 30_000 });
3592
- };
3593
- }
3594
3231
 
3595
3232
  class Health {
3596
3233
  page;
3597
3234
  neetoPlaywrightUtilities;
3598
- email = process.env.PLAYWRIGHT_PRODUCTION_EMAIL;
3235
+ email;
3599
3236
  loginPage;
3600
3237
  constructor(page, neetoPlaywrightUtilities) {
3601
3238
  this.page = page;
3602
3239
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
3603
- if (!process.env.PLAYWRIGHT_PRODUCTION_EMAIL ||
3604
- !process.env.PLAYWRIGHT_PRODUCTION_2FA_SECRET_KEY) {
3605
- throw new Error("One or more required env variables are missing: PLAYWRIGHT_PRODUCTION_EMAIL, PLAYWRIGHT_PRODUCTION_2FA_SECRET_KEY");
3606
- }
3240
+ const env = requireEnv("PLAYWRIGHT_PRODUCTION_EMAIL", "PLAYWRIGHT_PRODUCTION_2FA_SECRET_KEY");
3241
+ this.email = env.PLAYWRIGHT_PRODUCTION_EMAIL;
3607
3242
  this.loginPage = new OrganizationPage(page, neetoPlaywrightUtilities);
3608
3243
  }
3609
- getProductSpecificRolesRoute = () => {
3610
- const { hostname } = new URL(process.env.PLAYWRIGHT_PRODUCTION_BASE_URL);
3611
- const domain = hostname
3612
- .split(".")
3613
- .find(domain => domain.startsWith("neeto"));
3614
- const product = domain.replace(/^neeto/, "").toLowerCase();
3615
- return PRODUCT_ROLES_ROUTE_MAP[product] ?? ROUTES.adminPanel.roles;
3616
- };
3617
3244
  loginToApp = async (route = ROUTES.adminPanel.index) => {
3618
3245
  await this.page.goto(route);
3619
3246
  await this.neetoPlaywrightUtilities.waitForPageLoad();
3620
- await this.loginPage.loginViaAuthenticatorApp(this.email);
3247
+ await this.loginPage.login({
3248
+ email: this.email,
3249
+ via: "authenticatorApp",
3250
+ });
3621
3251
  };
3622
3252
  verifyAppUI = async () => {
3623
3253
  await this.neetoPlaywrightUtilities.waitForFloatingMenu();
@@ -3627,82 +3257,10 @@ class Health {
3627
3257
  verifyAppIsLive = async (customSteps) => {
3628
3258
  await test.step("1: Login to the application", () => this.loginToApp());
3629
3259
  await test.step("2: Verify application UI", this.verifyAppUI);
3630
- await test.step("3: Navigate to roles page", async () => {
3631
- await this.page.goto(this.getProductSpecificRolesRoute());
3632
- await this.neetoPlaywrightUtilities.waitForFloatingMenu();
3633
- await this.neetoPlaywrightUtilities.waitForPageLoad();
3634
- });
3635
- await test.step("4: Verify adding & removing roles", async () => {
3636
- const roleName = faker.string.alphanumeric(8);
3637
- await this.page.getByTestId(ROLES_SELECTORS.newButton).click();
3638
- await this.page.getByTestId(ROLES_SELECTORS.nameTextField).fill(roleName);
3639
- await this.neetoPlaywrightUtilities.clickButtonAndAwaitLoad({
3640
- locator: this.page.getByTestId(ROLES_SELECTORS.proceedButton),
3641
- });
3642
- await this.neetoPlaywrightUtilities.verifyToast();
3643
- const roleHeaderDropDown = this.page
3644
- .getByTestId(ROLES_SELECTORS.tableHeaderRoleName)
3645
- .filter({ hasText: roleName })
3646
- .getByTestId(ROLES_SELECTORS.dropDownIcon);
3647
- await roleHeaderDropDown.click();
3648
- await this.page.getByTestId(ROLES_SELECTORS.deleteRoleButton).click();
3649
- await this.neetoPlaywrightUtilities.clickButtonAndAwaitLoad({
3650
- locator: this.page.getByTestId(COMMON_SELECTORS.alertModalSubmitButton),
3651
- });
3652
- await this.neetoPlaywrightUtilities.verifyToast();
3653
- await expect(roleHeaderDropDown).toBeHidden({ timeout: 10_000 });
3654
- });
3655
3260
  await customSteps?.();
3656
3261
  };
3657
3262
  }
3658
3263
 
3659
- class FastmailApi {
3660
- neetoPlaywrightUtilities;
3661
- headers;
3662
- accountId;
3663
- constructor(neetoPlaywrightUtilities) {
3664
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
3665
- this.headers = {
3666
- "Content-Type": "application/json",
3667
- Authorization: `Bearer ${process.env.NEETO_AUTOMATION_FASTMAIL_API_KEY}`,
3668
- };
3669
- }
3670
- assertApiKey = () => {
3671
- if (!process.env.NEETO_AUTOMATION_FASTMAIL_API_KEY)
3672
- 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.");
3673
- };
3674
- authorizeAndSetAccountId = async () => {
3675
- if (IS_DEV_ENV)
3676
- return;
3677
- this.assertApiKey();
3678
- const response = await this.neetoPlaywrightUtilities.apiRequest({
3679
- method: "get",
3680
- url: "https://api.fastmail.com/.well-known/jmap",
3681
- headers: this.headers,
3682
- });
3683
- const { primaryAccounts: { "urn:ietf:params:jmap:mail": accountId }, } = await response.json();
3684
- this.accountId = accountId;
3685
- };
3686
- apiRequest = async (method, body) => {
3687
- this.assertApiKey();
3688
- const response = await this.neetoPlaywrightUtilities.apiRequest({
3689
- method: "post",
3690
- url: "https://api.fastmail.com/jmap/api/",
3691
- headers: this.headers,
3692
- timeout: 2_000,
3693
- data: {
3694
- using: ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
3695
- methodCalls: [[method, { accountId: this.accountId, ...body }, "0"]],
3696
- },
3697
- });
3698
- return response?.json();
3699
- };
3700
- fetchAttachments = (blobId, attachmentName) => this.neetoPlaywrightUtilities.apiRequest({
3701
- url: `https://www.fastmailusercontent.com/jmap/download/${this.accountId}/${blobId}/${attachmentName}`,
3702
- headers: this.headers,
3703
- });
3704
- }
3705
-
3706
3264
  const basicHTMLContent = (content) => `
3707
3265
  <!DOCTYPE html>
3708
3266
  <html lang="en">
@@ -3918,39 +3476,13 @@ const toMailpitSearchTerm = (value) => `"${value.replace(/"/g, "")}"`;
3918
3476
  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}.`);
3919
3477
  class MailerUtils {
3920
3478
  neetoPlaywrightUtilities;
3921
- accountId;
3922
- fastmailApi;
3923
3479
  mailpitApi;
3924
3480
  railsEmailUtils;
3925
3481
  constructor(neetoPlaywrightUtilities) {
3926
3482
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
3927
- this.fastmailApi = new FastmailApi(neetoPlaywrightUtilities);
3928
3483
  this.mailpitApi = new MailpitApi(neetoPlaywrightUtilities);
3929
3484
  this.railsEmailUtils = new RailsEmailUtils(neetoPlaywrightUtilities);
3930
3485
  }
3931
- queryEmail = async (messageSearchCriteria, { receivedAfter = dateTimeOneHourAgo(), page = 1, itemsPerPage = 50, }) => {
3932
- const limit = itemsPerPage;
3933
- const position = (page - 1) * itemsPerPage;
3934
- if (itemsPerPage > 100 || itemsPerPage < 1)
3935
- throw new Error("itemsPerPage should be in the range of 1-100");
3936
- const body = {
3937
- filter: { ...messageSearchCriteria, after: receivedAfter.toISOString() },
3938
- sort: [{ property: "receivedAt", isAscending: false }],
3939
- limit,
3940
- position,
3941
- };
3942
- let ids = [], total = 0;
3943
- try {
3944
- ({
3945
- methodResponses: [[, { ids, total }]],
3946
- } = await this.fastmailApi.apiRequest("Email/query", body));
3947
- }
3948
- catch {
3949
- ids = [];
3950
- total = 0;
3951
- }
3952
- return { ids, total };
3953
- };
3954
3486
  buildMessageBodies = (emailBody, { stripInjectedLinks = false } = {}) => {
3955
3487
  const LINK_REGEX = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])/g;
3956
3488
  const CODE_REGEX = /(?<![#/])\b\d{4,}\b/g;
@@ -3973,67 +3505,6 @@ class MailerUtils {
3973
3505
  const text = { body: textBody, ...contentRecognitions };
3974
3506
  return { html, text };
3975
3507
  };
3976
- getEmails = async (ids) => {
3977
- const messageDetailsBody = {
3978
- ids,
3979
- bodyProperties: ["type", "name"],
3980
- fetchHTMLBodyValues: true,
3981
- };
3982
- const { methodResponses: [[, { list }]], } = await this.fastmailApi.apiRequest("Email/get", messageDetailsBody);
3983
- const formattedList = list.map((listItem) => {
3984
- const { id, from, to, bodyValues, cc, bcc, replyTo, receivedAt, subject, messageId, attachments, blobId, } = listItem;
3985
- const emailBody = Object.values(pluck("value", bodyValues)).join(" ");
3986
- const { html, text } = this.buildMessageBodies(emailBody, {
3987
- stripInjectedLinks: true,
3988
- });
3989
- return {
3990
- html,
3991
- text,
3992
- id,
3993
- from,
3994
- to,
3995
- cc,
3996
- bcc,
3997
- replyTo,
3998
- received: new Date(receivedAt),
3999
- subject,
4000
- attachments,
4001
- blobId,
4002
- ...(messageId?.[0] && { messageId: messageId[0] }),
4003
- };
4004
- });
4005
- return formattedList;
4006
- };
4007
- listMessages = async (messageSearchCriteria = {}, listMessagesFilterCriteria = {}) => {
4008
- if (IS_DEV_ENV) {
4009
- return this.railsEmailUtils.listMessages(messageSearchCriteria, listMessagesFilterCriteria);
4010
- }
4011
- const { ids } = await this.queryEmail(messageSearchCriteria, listMessagesFilterCriteria);
4012
- return this.getEmails(ids);
4013
- };
4014
- getEmailIds = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4015
- const ids = (await this.neetoPlaywrightUtilities.executeRecursively({
4016
- callback: async () => {
4017
- const { ids } = await this.queryEmail(messageSearchCriteria, {
4018
- receivedAfter,
4019
- });
4020
- return ids;
4021
- },
4022
- condition: async () => {
4023
- const { ids } = await this.queryEmail(messageSearchCriteria, {
4024
- receivedAfter,
4025
- });
4026
- return ids.length >= expectedEmailCount;
4027
- },
4028
- timeout,
4029
- }));
4030
- if (!ids) {
4031
- if (shouldThrowErrorOnTimeout)
4032
- throw new Error("Timed out waiting for matching message");
4033
- return [];
4034
- }
4035
- return ids;
4036
- };
4037
3508
  matchesCriteria(email, criteria) {
4038
3509
  const { to, from, subject, body } = criteria;
4039
3510
  if (to && !email.to.some(r => r.email.toLowerCase() === to.toLowerCase())) {
@@ -4054,93 +3525,6 @@ class MailerUtils {
4054
3525
  }
4055
3526
  return true;
4056
3527
  }
4057
- findMessage = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4058
- if (IS_DEV_ENV) {
4059
- return this.railsEmailUtils.findMessage(messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
4060
- }
4061
- const ids = await this.getEmailIds(messageSearchCriteria, { expectedEmailCount, receivedAfter, timeout }, shouldThrowErrorOnTimeout);
4062
- const emails = await this.getEmails(ids);
4063
- const filteredEmails = emails.filter(email => this.matchesCriteria(email, messageSearchCriteria));
4064
- return filteredEmails[0] || {};
4065
- };
4066
- findOtpFromEmail = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 2 * 60 * 1000, receivedAfter = new Date(Date.now() - 3000), expectedEmailCount = 1, }) => {
4067
- if (IS_DEV_ENV) {
4068
- return this.railsEmailUtils.findOtpFromEmail({
4069
- email,
4070
- subjectSubstring,
4071
- receivedAfter,
4072
- expectedEmailCount,
4073
- timeout: timeout / 3,
4074
- });
4075
- }
4076
- if (!this.accountId) {
4077
- await this.fastmailApi.authorizeAndSetAccountId();
4078
- }
4079
- const { html: { codes }, } = await this.findMessage({ to: email, subject: subjectSubstring }, { timeout, receivedAfter, expectedEmailCount });
4080
- return codes?.[0];
4081
- };
4082
- generateRandomEmail = () => faker.internet.email({ provider: process.env.FASTMAIL_DOMAIN_NAME });
4083
- getLatestMessageId = async (subject, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), } = {}) => {
4084
- if (IS_DEV_ENV) {
4085
- return this.railsEmailUtils.getLatestMessageId(subject, {
4086
- timeout: timeout / 3,
4087
- receivedAfter,
4088
- });
4089
- }
4090
- if (!this.accountId) {
4091
- await this.fastmailApi.authorizeAndSetAccountId();
4092
- }
4093
- const messageId = (await this.neetoPlaywrightUtilities.executeRecursively({
4094
- callback: async () => {
4095
- const { methodResponses: [[, { ids }]], } = await this.fastmailApi.apiRequest("Email/query", {
4096
- filter: { subject, after: receivedAfter.toISOString() },
4097
- sort: [{ property: "receivedAt", isAscending: false }],
4098
- limit: 1,
4099
- });
4100
- const emailId = ids?.[0];
4101
- if (!emailId)
4102
- return null;
4103
- const { methodResponses: [[, { list }]], } = await this.fastmailApi.apiRequest("Email/get", {
4104
- ids: [emailId],
4105
- properties: ["messageId"],
4106
- });
4107
- const rawMessageId = list?.[0]?.messageId?.[0];
4108
- if (!rawMessageId)
4109
- return null;
4110
- return rawMessageId.replace(/^<|>$/g, "");
4111
- },
4112
- condition: async () => {
4113
- const { methodResponses: [[, { ids }]], } = await this.fastmailApi.apiRequest("Email/query", {
4114
- filter: { subject, after: receivedAfter.toISOString() },
4115
- limit: 1,
4116
- });
4117
- return ids.length >= 1;
4118
- },
4119
- timeout,
4120
- }));
4121
- return messageId || undefined;
4122
- };
4123
- getEmailAttachment = async ({ name, type }, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4124
- if (IS_DEV_ENV)
4125
- return this.railsEmailUtils.getEmailAttachment({ name, type }, messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
4126
- const { blobId, attachments: attachmentNameAndTypes } = await this.findMessage(messageSearchCriteria, { expectedEmailCount, receivedAfter, timeout }, shouldThrowErrorOnTimeout);
4127
- const attachment = attachmentNameAndTypes.find(att => {
4128
- const matchesName = name ? att.name?.includes(name) : true;
4129
- const matchesType = type ? att.type?.startsWith(type) : true;
4130
- return matchesName && matchesType;
4131
- });
4132
- if (!attachment)
4133
- throw new Error("No such attachment exists");
4134
- const emailAttachment = await this.fastmailApi.fetchAttachments(blobId, attachment.name);
4135
- const buffer = await emailAttachment.body();
4136
- const parsedEmail = await simpleParser(buffer);
4137
- const attachments = parsedEmail.attachments;
4138
- return attachments.find(att => {
4139
- const matchesName = name ? att.filename?.includes(name) : true;
4140
- const matchesType = type ? att.contentType?.startsWith(type) : true;
4141
- return matchesName && matchesType;
4142
- });
4143
- };
4144
3528
  toIdentifiers = (addresses) => {
4145
3529
  if (!addresses)
4146
3530
  return [];
@@ -4190,7 +3574,7 @@ class MailerUtils {
4190
3574
  warnOnNonMailpitRecipient = ({ to, }) => {
4191
3575
  const domain = mailpitDomainName().toLowerCase();
4192
3576
  if (to && !to.toLowerCase().endsWith(`@${domain}`))
4193
- 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().`);
3577
+ 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().`);
4194
3578
  };
4195
3579
  queryMailpitEmails = async (messageSearchCriteria, { receivedAfter = dateTimeOneHourAgo(), page = 1, itemsPerPage = 50, }) => {
4196
3580
  if (itemsPerPage > 100 || itemsPerPage < 1)
@@ -4209,7 +3593,7 @@ class MailerUtils {
4209
3593
  return messages.filter(summary => new Date(summary.Created).valueOf() >= receivedAfter.valueOf() &&
4210
3594
  this.matchesSummaryCriteria(summary, messageSearchCriteria));
4211
3595
  };
4212
- getEmailsV2 = async (summaries) => {
3596
+ getEmails = async (summaries) => {
4213
3597
  const emails = await Promise.all(summaries.map(async (summary) => {
4214
3598
  const message = await this.mailpitApi.getMessage(summary.ID);
4215
3599
  return message && this.toFormattedList(summary, message);
@@ -4224,7 +3608,7 @@ class MailerUtils {
4224
3608
  condition: async () => {
4225
3609
  const candidates = await this.queryMailpitEmails(messageSearchCriteria, { receivedAfter });
4226
3610
  if (requiresBodyMatch) {
4227
- const emails = await this.getEmailsV2(candidates);
3611
+ const emails = await this.getEmails(candidates);
4228
3612
  const matchedIds = new Set(emails
4229
3613
  .filter(email => this.matchesCriteria(email, messageSearchCriteria))
4230
3614
  .map(({ id }) => id));
@@ -4239,16 +3623,16 @@ class MailerUtils {
4239
3623
  });
4240
3624
  return summaries === false ? null : summaries;
4241
3625
  };
4242
- listMessagesV2 = async (messageSearchCriteria = {}, listMessagesFilterCriteria = {}) => {
3626
+ listMessages = async (messageSearchCriteria = {}, listMessagesFilterCriteria = {}) => {
4243
3627
  if (IS_DEV_ENV) {
4244
3628
  return this.railsEmailUtils.listMessages(messageSearchCriteria, listMessagesFilterCriteria);
4245
3629
  }
4246
3630
  this.warnOnNonMailpitRecipient(messageSearchCriteria);
4247
3631
  const summaries = await this.queryMailpitEmails(messageSearchCriteria, listMessagesFilterCriteria);
4248
- const emails = await this.getEmailsV2(summaries);
3632
+ const emails = await this.getEmails(summaries);
4249
3633
  return emails.filter(email => this.matchesCriteria(email, messageSearchCriteria));
4250
3634
  };
4251
- getEmailIdsV2 = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
3635
+ getEmailIds = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4252
3636
  if (IS_DEV_ENV) {
4253
3637
  const emails = await this.railsEmailUtils.listMessages(messageSearchCriteria, { receivedAfter });
4254
3638
  return emails.map(({ id }) => id);
@@ -4262,7 +3646,7 @@ class MailerUtils {
4262
3646
  }
4263
3647
  return summaries.map(({ ID }) => ID);
4264
3648
  };
4265
- findMessageV2 = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
3649
+ findMessage = async (messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4266
3650
  if (IS_DEV_ENV) {
4267
3651
  return this.railsEmailUtils.findMessage(messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
4268
3652
  }
@@ -4273,11 +3657,11 @@ class MailerUtils {
4273
3657
  throw mailpitTimeoutError(messageSearchCriteria, receivedAfter, expectedEmailCount);
4274
3658
  return {};
4275
3659
  }
4276
- const emails = await this.getEmailsV2(summaries);
3660
+ const emails = await this.getEmails(summaries);
4277
3661
  const filteredEmails = emails.filter(email => this.matchesCriteria(email, messageSearchCriteria));
4278
3662
  return filteredEmails[0] || {};
4279
3663
  };
4280
- findOtpFromEmailV2 = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 2 * 60 * 1000, receivedAfter = new Date(Date.now() - 3000), expectedEmailCount = 1, }) => {
3664
+ findOtpFromEmail = async ({ email, subjectSubstring = OTP_EMAIL_PATTERN, timeout = 2 * 60 * 1000, receivedAfter = new Date(Date.now() - 3000), expectedEmailCount = 1, }) => {
4281
3665
  if (IS_DEV_ENV) {
4282
3666
  return this.railsEmailUtils.findOtpFromEmail({
4283
3667
  email,
@@ -4287,17 +3671,17 @@ class MailerUtils {
4287
3671
  timeout: timeout / 3,
4288
3672
  });
4289
3673
  }
4290
- const message = await this.findMessageV2({ to: email, subject: subjectSubstring }, { timeout, receivedAfter, expectedEmailCount });
3674
+ const message = await this.findMessage({ to: email, subject: subjectSubstring }, { timeout, receivedAfter, expectedEmailCount });
4291
3675
  return message.html?.codes?.[0];
4292
3676
  };
4293
- generateRandomEmailV2 = () => {
3677
+ generateRandomEmail = () => {
4294
3678
  const domain = mailpitDomainName();
4295
3679
  const [localPart] = faker.internet
4296
3680
  .email({ provider: domain, allowSpecialCharacters: false })
4297
3681
  .split("@");
4298
3682
  return `${localPart}.${faker.string.alpha(8).toLowerCase()}@${domain}`;
4299
3683
  };
4300
- getLatestMessageIdV2 = async (subject, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), } = {}) => {
3684
+ getLatestMessageId = async (subject, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), } = {}) => {
4301
3685
  if (IS_DEV_ENV) {
4302
3686
  return this.railsEmailUtils.getLatestMessageId(subject, {
4303
3687
  timeout: timeout / 3,
@@ -4308,10 +3692,10 @@ class MailerUtils {
4308
3692
  const messageId = summaries?.[0]?.MessageID;
4309
3693
  return messageId ? messageId.replace(/^<|>$/g, "") : undefined;
4310
3694
  };
4311
- getEmailAttachmentV2 = async ({ name, type }, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
3695
+ getEmailAttachment = async ({ name, type }, messageSearchCriteria = {}, { timeout = 10_000, receivedAfter = dateTimeOneHourAgo(), expectedEmailCount = 1, } = {}, shouldThrowErrorOnTimeout = true) => {
4312
3696
  if (IS_DEV_ENV)
4313
3697
  return this.railsEmailUtils.getEmailAttachment({ name, type }, messageSearchCriteria, { receivedAfter, expectedEmailCount, timeout: timeout / 3 }, shouldThrowErrorOnTimeout);
4314
- const { id } = await this.findMessageV2(messageSearchCriteria, { expectedEmailCount, receivedAfter, timeout }, shouldThrowErrorOnTimeout);
3698
+ const { id } = await this.findMessage(messageSearchCriteria, { expectedEmailCount, receivedAfter, timeout }, shouldThrowErrorOnTimeout);
4315
3699
  const rawMessage = id ? await this.mailpitApi.fetchRawMessage(id) : null;
4316
3700
  if (!rawMessage)
4317
3701
  throw new Error("No such attachment exists");
@@ -4478,74 +3862,11 @@ class ColorPickerUtils {
4478
3862
  await expect(colorPickerInput).toBeHidden();
4479
3863
  }).toPass({ timeout: 40_000 });
4480
3864
  };
4481
- hexToRGBA = (hex) => {
4482
- let r = 0, g = 0, b = 0, a = 1;
4483
- if (hex.length === 5) {
4484
- r = parseInt(`${hex[1]}${hex[1]}`, 16);
4485
- g = parseInt(`${hex[2]}${hex[2]}`, 16);
4486
- b = parseInt(`${hex[3]}${hex[3]}`, 16);
4487
- a = parseInt(`${hex[4]}${hex[4]}`, 16) / 255;
4488
- }
4489
- else if (hex.length === 9) {
4490
- r = parseInt(`${hex[1]}${hex[2]}`, 16);
4491
- g = parseInt(`${hex[3]}${hex[4]}`, 16);
4492
- b = parseInt(`${hex[5]}${hex[6]}`, 16);
4493
- a = parseInt(`${hex[7]}${hex[8]}`, 16) / 255;
4494
- }
4495
- return `rgba(${r}, ${g}, ${b}, ${a.toFixed(2)})`;
4496
- };
3865
+ hexToRGBA = hexToRGBA;
4497
3866
  }
4498
3867
 
4499
- const STATIC_ASSET_PATTERN = /\.(js|css|woff2?|ttf|eot|png|svg|ico|gif|webp)(\?.*)?$/;
4500
- const EXCLUDED_RESPONSE_HEADERS = [
4501
- "content-encoding",
4502
- "content-length",
4503
- "transfer-encoding",
4504
- ];
4505
- const assetCache = new Map();
4506
3868
  const commands = {
4507
- context: async ({ context }, use) => {
4508
- if (IS_DEV_ENV && IS_CI && !IS_PLAYWRIGHT_RUN) {
4509
- await context.route(STATIC_ASSET_PATTERN, async (route) => {
4510
- const url = route.request().url();
4511
- const hit = assetCache.get(url);
4512
- if (hit)
4513
- return route.fulfill(hit);
4514
- try {
4515
- // Use Node's native fetch instead of route.fetch() to keep these
4516
- // requests out of the Playwright trace's Actions tab. Forward the
4517
- // browser's request headers so cookie/session-scoped assets still
4518
- // resolve; drop accept-encoding so we only get encodings Node can
4519
- // decode, and HTTP/2 pseudo-headers which fetch rejects.
4520
- const requestHeaders = Object.entries(await route.request().allHeaders()).filter(([name]) => name !== "accept-encoding" && !name.startsWith(":"));
4521
- const response = await fetch(url, {
4522
- headers: Object.fromEntries(requestHeaders),
4523
- });
4524
- const body = Buffer.from(await response.arrayBuffer());
4525
- // Node's fetch decompresses the body but keeps the original
4526
- // content-encoding/content-length headers; drop them so the
4527
- // browser doesn't try to decode the already-decoded body.
4528
- const headers = {};
4529
- response.headers.forEach((value, key) => {
4530
- if (!EXCLUDED_RESPONSE_HEADERS.includes(key))
4531
- headers[key] = value;
4532
- });
4533
- const entry = { body, status: response.status, headers };
4534
- if (response.ok)
4535
- assetCache.set(url, entry);
4536
- return route.fulfill(entry);
4537
- }
4538
- catch {
4539
- return route.continue();
4540
- }
4541
- });
4542
- }
4543
- await use(context);
4544
- },
4545
- neetoPlaywrightUtilities: async ({ page, request, baseURL }, use) => {
4546
- const commands = new CustomCommands(page, request, baseURL);
4547
- await use(commands);
4548
- },
3869
+ neetoPlaywrightUtilities: ({ page, request, baseURL }, use) => use(new CustomCommands(page, request, baseURL)),
4549
3870
  page: async ({ page }, use) => {
4550
3871
  await page.goto("/");
4551
3872
  await page.waitForLoadState();
@@ -4553,8 +3874,6 @@ const commands = {
4553
3874
  },
4554
3875
  mailerUtils: async ({ neetoPlaywrightUtilities }, use) => {
4555
3876
  const mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
4556
- if (!IS_MAILPIT_ENABLED)
4557
- await mailerUtils.fastmailApi.authorizeAndSetAccountId();
4558
3877
  await use(mailerUtils);
4559
3878
  IS_DEV_ENV && (await mailerUtils.railsEmailUtils.clearStaleEmails());
4560
3879
  },
@@ -4571,18 +3890,9 @@ const commands = {
4571
3890
  }
4572
3891
  }
4573
3892
  },
4574
- colorPicker: async ({ page }, use) => {
4575
- const colorPicker = new ColorPickerUtils(page);
4576
- await use(colorPicker);
4577
- },
4578
- qrCodeUtils: async ({ page }, use) => {
4579
- const qrCodeUtils = new QRCodeUtils(page);
4580
- await use(qrCodeUtils);
4581
- },
4582
- health: async ({ page, neetoPlaywrightUtilities }, use) => {
4583
- const health = new Health(page, neetoPlaywrightUtilities);
4584
- await use(health);
4585
- },
3893
+ colorPicker: ({ page }, use) => use(new ColorPickerUtils(page)),
3894
+ qrCodeUtils: ({ page }, use) => use(new QRCodeUtils(page)),
3895
+ health: ({ page, neetoPlaywrightUtilities }, use) => use(new Health(page, neetoPlaywrightUtilities)),
4586
3896
  };
4587
3897
 
4588
3898
  const loadPlaywrightExtra = () => import('playwright-extra');
@@ -4913,8 +4223,8 @@ class EmbedBase {
4913
4223
  const showIconCheckbox = this.page.getByTestId(EMBED_SELECTORS.showIconCheckbox);
4914
4224
  if (isPresent(customizationOptions.showIcon)) {
4915
4225
  const shouldShowIcon = customizationOptions.showIcon;
4916
- const showIconAction = shouldShowIcon ? "check" : "uncheck";
4917
- await showIconCheckbox[showIconAction]();
4226
+ (await showIconCheckbox.isChecked()) !== shouldShowIcon &&
4227
+ (await showIconCheckbox.click());
4918
4228
  await expect(this.codeBlock).toContainText(`showIcon: ${shouldShowIcon}`);
4919
4229
  }
4920
4230
  await this.expectMultipleTextsInCodeblock([
@@ -4927,9 +4237,11 @@ class EmbedBase {
4927
4237
  const floatingButton = this.page.getByRole("button", {
4928
4238
  name: customizationOptions.buttonText,
4929
4239
  });
4930
- const classRegExp = customizationOptions.buttonPosition
4931
- .toLocaleLowerCase()
4932
- .replace(" ", ".*");
4240
+ const [vertical, horizontal] = customizationOptions.buttonPosition
4241
+ .toLowerCase()
4242
+ .split(" ");
4243
+ const logicalSide = horizontal === "left" ? "start" : "end";
4244
+ const classRegExp = `${vertical}-0.*${logicalSide}-0|${vertical}.*${horizontal}`;
4933
4245
  await Promise.all([
4934
4246
  expect(floatingButton).toHaveClass(RegExp(classRegExp)),
4935
4247
  expect(floatingButton).toHaveCSS("background-color", hexToRGB(customizationOptions.buttonColorHex)),
@@ -4997,7 +4309,7 @@ class HelpAndProfilePage {
4997
4309
  const floatingActionMenuBtn = this.page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton);
4998
4310
  await expect(async () => {
4999
4311
  await floatingActionMenuBtn.scrollIntoViewIfNeeded();
5000
- await floatingActionMenuBtn.hover();
4312
+ await floatingActionMenuBtn.click();
5001
4313
  await expect(this.helpMenuBtn).toBeVisible();
5002
4314
  }).toPass({ timeout: 60_000 });
5003
4315
  };
@@ -5083,28 +4395,28 @@ class HelpAndProfilePage {
5083
4395
  await this.page
5084
4396
  .getByTestId(HELP_CENTER_SELECTORS.keyboardShortcutButton)
5085
4397
  .click();
5086
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "1px");
4398
+ await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5087
4399
  await this.page
5088
4400
  .getByTestId(KEYBOARD_SHORTCUTS_SELECTORS.closePaneButton)
5089
4401
  .click();
5090
- await expect(keyboardShortcutsPane).toHaveCSS("width", "1px");
4402
+ await expect(keyboardShortcutsPane).toHaveCSS("width", "0px");
5091
4403
  });
5092
4404
  await test.step("3: Open and close keyboard shortcuts through shortcut", async () => {
5093
4405
  await this.page.keyboard.press(openKeyboardShortcut);
5094
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "1px");
4406
+ await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5095
4407
  await this.page.keyboard.press("Escape");
5096
- await expect(keyboardShortcutsPane).toHaveCSS("width", "1px");
4408
+ await expect(keyboardShortcutsPane).toHaveCSS("width", "0px");
5097
4409
  });
5098
4410
  await test.step("4: Verify all displayed keyboard shortcuts", async () => {
5099
4411
  await this.page.keyboard.press(openKeyboardShortcut);
5100
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "1px");
4412
+ await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5101
4413
  await Promise.all([
5102
- expect(keyItem.locator("p")).toHaveText(shortcuts.map(shortcut => shortcut.description)),
4414
+ expect(keyItem.getByTestId(COMMON_SELECTORS.hotkeyDescription)).toHaveText(shortcuts.map(shortcut => shortcut.description)),
5103
4415
  expect(keyItem.locator("div")).toHaveText(formattedSequences),
5104
4416
  ]);
5105
4417
  });
5106
4418
  };
5107
- openAppSwitcher = () => this.page.getByTestId(COMMON_SELECTORS.appSwitcherButton).hover();
4419
+ openAppSwitcher = () => this.page.getByTestId(COMMON_SELECTORS.appSwitcherButton).click();
5108
4420
  openAppSwitcherAndVerify = async () => {
5109
4421
  const productName = "Cal";
5110
4422
  const searchQueryPartial = productName.slice(0, 1).toLowerCase();
@@ -5144,18 +4456,21 @@ class HelpAndProfilePage {
5144
4456
  });
5145
4457
  });
5146
4458
  };
5147
- openAuthLinkAndVerify = async ({ linkTestId, redirectLink, }) => {
5148
- await this.page
5149
- .getByTestId(COMMON_SELECTORS.pane)
5150
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
5151
- .click();
4459
+ openAuthLinkAndVerify = async ({ linkTestId, redirectLink, appPath, }) => {
5152
4460
  await this.page
5153
- .getByTestId(COMMON_SELECTORS.dropdownContainer)
5154
- .getByTestId(linkTestId)
4461
+ .getByTestId(PROFILE_SECTION_SELECTORS.profileMoreDropdownButton)
5155
4462
  .click();
5156
- await expect(this.page).toHaveURL(new RegExp(NEETO_AUTH_BASE_URL(readFileSyncIfExists()?.user?.subdomainName)));
5157
- await expect(this.page).toHaveURL(new RegExp(redirectLink));
5158
- await this.page.goBack();
4463
+ const appUrl = this.page.url();
4464
+ await Promise.all([
4465
+ this.page.waitForRequest(request => new URL(request.url()).pathname === appPath),
4466
+ this.page.getByTestId(linkTestId).click(),
4467
+ ]);
4468
+ // NeetoAuth runs only on staging
4469
+ if (IS_STAGING_ENV) {
4470
+ await expect(this.page).toHaveURL(new RegExp(NEETO_AUTH_BASE_URL(readFileSyncIfExists()?.user?.subdomainName)));
4471
+ await expect(this.page).toHaveURL(new RegExp(redirectLink));
4472
+ }
4473
+ await this.page.goto(appUrl);
5159
4474
  };
5160
4475
  fillTextFields = async ({ firstName, lastName, phoneNumber, }) => {
5161
4476
  const firstNameField = this.page.getByTestId(PROFILE_SECTION_SELECTORS.firstNameTextField);
@@ -5196,9 +4511,10 @@ class HelpAndProfilePage {
5196
4511
  });
5197
4512
  };
5198
4513
  uploadImage = async (imageName) => {
4514
+ if (!IS_STAGING_ENV)
4515
+ return; // Image upload needs ImageKit, which is configured only on staging
5199
4516
  await this.page
5200
- .getByTestId(COMMON_SELECTORS.paneBody)
5201
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
4517
+ .getByTestId(PROFILE_SECTION_SELECTORS.profileImageDropdownButton)
5202
4518
  .click();
5203
4519
  await this.page
5204
4520
  .getByTestId(PROFILE_SECTION_SELECTORS.imageUploadBtn)
@@ -5207,12 +4523,12 @@ class HelpAndProfilePage {
5207
4523
  fileNameWithType: `images/${imageName}`,
5208
4524
  droppableZone: this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.fileInput),
5209
4525
  });
5210
- await expect(this.page.getByTestId(COMMON_SELECTORS.modalHeader)).toBeHidden({ timeout: 10_000 });
4526
+ await expect(this.page.getByTestId(COMMON_SELECTORS.dialogHeader)).toBeHidden({ timeout: 10_000 });
5211
4527
  await expect(this.page.getByTestId(COMMON_SELECTORS.avatar).locator("img")).toHaveAttribute("src", imageRegex(imageName));
5212
4528
  };
5213
4529
  updateBasicInfo = async ({ contact, settings, imageName, }) => {
5214
4530
  await expect(this.page
5215
- .getByTestId(COMMON_SELECTORS.pane)
4531
+ .getByTestId(COMMON_SELECTORS.sheetBody)
5216
4532
  .getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden();
5217
4533
  await this.uploadImage(imageName);
5218
4534
  await this.fillTextFields(contact);
@@ -5222,7 +4538,7 @@ class HelpAndProfilePage {
5222
4538
  .or(this.page.getByTestId(PROFILE_SECTION_SELECTORS.profileSubmitBtn))
5223
4539
  .click();
5224
4540
  await this.neetoPlaywrightUtilities.waitForPageLoad();
5225
- await expect(this.page.getByTestId(COMMON_SELECTORS.paneModalCrossIcon)).toBeHidden();
4541
+ await expect(this.page.getByTestId(COMMON_SELECTORS.sheetCloseButton)).toBeHidden();
5226
4542
  };
5227
4543
  openProfile = async () => {
5228
4544
  await this.openHelpCenter();
@@ -5232,7 +4548,7 @@ class HelpAndProfilePage {
5232
4548
  await this.page
5233
4549
  .getByTestId(PROFILE_SECTION_SELECTORS.myProfileButton)
5234
4550
  .click();
5235
- await expect(this.page.getByTestId(COMMON_SELECTORS.paneHeader)).toContainText(this.t("neetoTeamMembers.profile.common.myProfile"));
4551
+ await expect(this.page.getByTestId(COMMON_SELECTORS.sheetHeader)).toContainText(this.t("neetoTeamMembers.profile.common.myProfile"));
5236
4552
  };
5237
4553
  verifyProfileSidePane = async ({ contact, settings, imageName, }) => {
5238
4554
  const timeZone = settings?.timeZone;
@@ -5280,8 +4596,7 @@ class HelpAndProfilePage {
5280
4596
  await test.step("3: Verify basic info", async () => {
5281
4597
  await this.openProfile();
5282
4598
  await this.page
5283
- .getByTestId(COMMON_SELECTORS.pane)
5284
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
4599
+ .getByTestId(PROFILE_SECTION_SELECTORS.profileMoreDropdownButton)
5285
4600
  .click();
5286
4601
  await this.page
5287
4602
  .getByTestId(PROFILE_SECTION_SELECTORS.editBasicInfoMenuBtn)
@@ -5314,26 +4629,6 @@ class HelpAndProfilePage {
5314
4629
  await workspacePage.close();
5315
4630
  });
5316
4631
  };
5317
- /**
5318
- * @deprecated This method is deprecated. Use verifyWorkspace instead.
5319
- */
5320
- verifyProfileAndOrganizationLinks = async () => {
5321
- await test.step("1: Open Help center and verify", this.openHelpCenter);
5322
- await test.step("2: Open My organization link and verify", async () => {
5323
- await this.page
5324
- .getByTestId(PROFILE_SECTION_SELECTORS.workspaceDisplay)
5325
- .click();
5326
- const [workspacePage] = await Promise.all([
5327
- this.page.waitForEvent("popup"),
5328
- this.page
5329
- .getByTestId(PROFILE_SECTION_SELECTORS.profileOrganizationSettingsButton)
5330
- .click(),
5331
- ]);
5332
- await workspacePage.waitForLoadState();
5333
- await expect(workspacePage).toHaveURL(new RegExp(ROUTES.auth.adminPanel));
5334
- await workspacePage.close();
5335
- });
5336
- };
5337
4632
  openAndVerifyStatus = async () => {
5338
4633
  await test.step("1: Open Help Center links", this.openHelpCenter);
5339
4634
  await test.step("2: Open and verify status page", async () => {
@@ -5416,208 +4711,74 @@ class HelpAndProfilePage {
5416
4711
  });
5417
4712
  };
5418
4713
  }
5419
- class HelpAndProfilePageV2 extends HelpAndProfilePage {
5420
- openAppSwitcher = () => this.page.getByTestId(COMMON_SELECTORS.appSwitcherButton).click();
5421
- openHelpCenter = async () => {
5422
- const floatingActionMenuBtn = this.page.getByTestId(COMMON_SELECTORS.floatingActionMenuButton);
5423
- await expect(async () => {
5424
- await floatingActionMenuBtn.scrollIntoViewIfNeeded();
5425
- await floatingActionMenuBtn.click();
5426
- await expect(this.helpMenuBtn).toBeVisible();
5427
- }).toPass({ timeout: 60_000 });
5428
- };
5429
- openAndVerifyKeyboardShortcutsPane = async (productShortcuts, osPlatform = "windows") => {
5430
- const keyboardShortcutsPane = this.page.getByTestId(KEYBOARD_SHORTCUTS_SELECTORS.keyboardShortcutsPane);
5431
- const keyItem = this.page.getByTestId(KEYBOARD_SHORTCUTS_SELECTORS.hotKeyItem);
5432
- const openKeyboardShortcut = osPlatform === "mac" ? "Meta+/" : "Control+/";
5433
- const shortcuts = [...globalShortcuts(this.t), ...productShortcuts];
5434
- const formattedSequences = shortcuts.map(shortcut => this.formatKeyboardShortcut(shortcut.sequence, osPlatform));
5435
- await test.step("1: Open Help Center", this.openHelpCenter);
5436
- await test.step("2: Open and close keyboard shortcuts from UI", async () => {
5437
- await this.page
5438
- .getByTestId(HELP_CENTER_SELECTORS.keyboardShortcutButton)
5439
- .click();
5440
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5441
- await this.page
5442
- .getByTestId(KEYBOARD_SHORTCUTS_SELECTORS.closePaneButton)
5443
- .click();
5444
- await expect(keyboardShortcutsPane).toHaveCSS("width", "0px");
5445
- });
5446
- await test.step("3: Open and close keyboard shortcuts through shortcut", async () => {
5447
- await this.page.keyboard.press(openKeyboardShortcut);
5448
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5449
- await this.page.keyboard.press("Escape");
5450
- await expect(keyboardShortcutsPane).toHaveCSS("width", "0px");
4714
+
4715
+ class MicrosoftPage extends IntegrationBase {
4716
+ totp;
4717
+ mailerUtils;
4718
+ constructor({ page, neetoPlaywrightUtilities, integrationRouteIndex, integration = "", }) {
4719
+ super({
4720
+ page,
4721
+ neetoPlaywrightUtilities,
4722
+ integrationRouteIndex,
4723
+ integration,
5451
4724
  });
5452
- await test.step("4: Verify all displayed keyboard shortcuts", async () => {
5453
- await this.page.keyboard.press(openKeyboardShortcut);
5454
- await expect(keyboardShortcutsPane).not.toHaveCSS("width", "0px");
5455
- await Promise.all([
5456
- expect(keyItem.getByTestId(COMMON_SELECTORS.hotkeyDescription)).toHaveText(shortcuts.map(shortcut => shortcut.description)),
5457
- expect(keyItem.locator("div")).toHaveText(formattedSequences),
5458
- ]);
4725
+ this.mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
4726
+ this.totp = initializeTotp({
4727
+ issuer: "Microsoft",
4728
+ secret: process.env.MICROSOFT_2FA_SECRET_KEY,
5459
4729
  });
5460
- };
5461
- openAuthLinkAndVerify = async ({ linkTestId, redirectLink, appPath, }) => {
4730
+ }
4731
+ stagingConsentFlow = async (abortFlow = false) => {
4732
+ await this.page.waitForLoadState("load", { timeout: 25_000 });
4733
+ await expect(this.page.getByRole("heading", {
4734
+ name: MICROSOFT_LOGIN_TEXTS.permissionsRequested,
4735
+ })).toBeVisible({ timeout: 20_000 });
5462
4736
  await this.page
5463
- .getByTestId(PROFILE_SECTION_SELECTORS.profileMoreDropdownButton)
4737
+ .locator(abortFlow
4738
+ ? MICROSOFT_LOGIN_SELECTORS.cancelButton
4739
+ : MICROSOFT_LOGIN_SELECTORS.acceptButton)
5464
4740
  .click();
5465
- const appUrl = this.page.url();
5466
- await Promise.all([
5467
- this.page.waitForRequest(request => new URL(request.url()).pathname === appPath),
5468
- this.page.getByTestId(linkTestId).click(),
5469
- ]);
5470
- // NeetoAuth runs only on staging
5471
- if (IS_STAGING_ENV) {
5472
- await expect(this.page).toHaveURL(new RegExp(NEETO_AUTH_BASE_URL(readFileSyncIfExists()?.user?.subdomainName)));
5473
- await expect(this.page).toHaveURL(new RegExp(redirectLink));
5474
- }
5475
- await this.page.goto(appUrl);
4741
+ await this.page.waitForLoadState("load", { timeout: 25_000 });
4742
+ await this.neetoPlaywrightUtilities.waitForFloatingMenu();
5476
4743
  };
5477
- uploadImage = async (imageName) => {
5478
- if (!IS_STAGING_ENV)
5479
- return; // Image upload needs ImageKit, which is configured only on staging
5480
- await this.page
5481
- .getByTestId(PROFILE_SECTION_SELECTORS.profileImageDropdownButton)
5482
- .click();
4744
+ enterEmail = async (email) => {
4745
+ await this.page.waitForLoadState("load", { timeout: 25_000 });
4746
+ await expect(this.page.getByRole("heading", { name: MICROSOFT_LOGIN_TEXTS.signIn })).toBeVisible({ timeout: 20_000 });
5483
4747
  await this.page
5484
- .getByTestId(PROFILE_SECTION_SELECTORS.imageUploadBtn)
5485
- .click();
5486
- await this.neetoPlaywrightUtilities.uploadFileViaDispatch({
5487
- fileNameWithType: `images/${imageName}`,
5488
- droppableZone: this.page.getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.fileInput),
5489
- });
5490
- await expect(this.page.getByTestId(COMMON_SELECTORS.dialogHeader)).toBeHidden({ timeout: 10_000 });
5491
- await expect(this.page.getByTestId(COMMON_SELECTORS.avatar).locator("img")).toHaveAttribute("src", imageRegex(imageName));
4748
+ .locator(MICROSOFT_LOGIN_SELECTORS.emailInput)
4749
+ .or(this.page.locator(MICROSOFT_LOGIN_SELECTORS.placeholder))
4750
+ .or(this.page.getByRole("textbox", {
4751
+ name: MICROSOFT_LOGIN_TEXTS.emailInput,
4752
+ }))
4753
+ .pressSequentially(email, { delay: 25 });
5492
4754
  };
5493
- updateBasicInfo = async ({ contact, settings, imageName, }) => {
5494
- await expect(this.page
5495
- .getByTestId(COMMON_SELECTORS.sheetBody)
5496
- .getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden();
5497
- await this.uploadImage(imageName);
5498
- await this.fillTextFields(contact);
5499
- await this.selectDropdownFields(settings);
4755
+ enterPassword = async (password) => {
4756
+ await this.page.waitForLoadState("load", { timeout: 25_000 });
4757
+ await expect(this.page.getByRole("heading", {
4758
+ name: MICROSOFT_LOGIN_TEXTS.enterPassword,
4759
+ })).toBeVisible({ timeout: 10_000 });
5500
4760
  await this.page
5501
- .getByTestId(PROFILE_SECTION_SELECTORS.submitButton)
5502
- .or(this.page.getByTestId(PROFILE_SECTION_SELECTORS.profileSubmitBtn))
5503
- .click();
5504
- await this.neetoPlaywrightUtilities.waitForPageLoad();
5505
- await expect(this.page.getByTestId(COMMON_SELECTORS.sheetCloseButton)).toBeHidden();
5506
- };
5507
- openProfile = async () => {
5508
- await this.openHelpCenter();
5509
- await this.page
5510
- .getByTestId(PROFILE_SECTION_SELECTORS.profileExpandMenuBtn)
5511
- .click();
5512
- await this.page
5513
- .getByTestId(PROFILE_SECTION_SELECTORS.myProfileButton)
5514
- .click();
5515
- await expect(this.page.getByTestId(COMMON_SELECTORS.sheetHeader)).toContainText(this.t("neetoTeamMembers.profile.common.myProfile"));
5516
- };
5517
- verifyProfile = async () => {
5518
- await test.step("1: Open Manage billing and subscriptions link and verify", async () => {
5519
- await this.openProfile();
5520
- await this.openAuthLinkAndVerify({
5521
- redirectLink: ROUTES.myProfile,
5522
- appPath: ROUTES.auth.editBilling,
5523
- linkTestId: PROFILE_SECTION_SELECTORS.manageBillingAndSubscriptionsButton,
5524
- });
5525
- });
5526
- await test.step("2: Open Update email link and verify", async () => {
5527
- await this.openProfile();
5528
- await this.openAuthLinkAndVerify({
5529
- redirectLink: ROUTES.updateEmail,
5530
- appPath: ROUTES.auth.editEmail,
5531
- linkTestId: PROFILE_SECTION_SELECTORS.updateEmailMenuBtn,
5532
- });
5533
- });
5534
- await test.step("3: Verify basic info", async () => {
5535
- await this.openProfile();
5536
- await this.page
5537
- .getByTestId(PROFILE_SECTION_SELECTORS.profileMoreDropdownButton)
5538
- .click();
5539
- await this.page
5540
- .getByTestId(PROFILE_SECTION_SELECTORS.editBasicInfoMenuBtn)
5541
- .click();
5542
- const basicInfoParams = getBasicInfoTestData();
5543
- await this.updateBasicInfo(basicInfoParams);
5544
- await this.openProfile();
5545
- await this.verifyProfileSidePane(basicInfoParams);
5546
- });
5547
- };
5548
- }
5549
-
5550
- class MicrosoftPage extends IntegrationBase {
5551
- totp;
5552
- mailerUtils;
5553
- constructor({ page, neetoPlaywrightUtilities, integrationRouteIndex, integration = "", }) {
5554
- super({
5555
- page,
5556
- neetoPlaywrightUtilities,
5557
- integrationRouteIndex,
5558
- integration,
5559
- });
5560
- this.mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
5561
- this.totp = initializeTotp({
5562
- issuer: "Microsoft",
5563
- secret: process.env.MICROSOFT_2FA_SECRET_KEY,
5564
- });
5565
- }
5566
- stagingConsentFlow = async (abortFlow = false) => {
5567
- await this.page.waitForLoadState("load", { timeout: 25_000 });
5568
- await expect(this.page.getByRole("heading", {
5569
- name: MICROSOFT_LOGIN_TEXTS.permissionsRequested,
5570
- })).toBeVisible({ timeout: 20_000 });
5571
- await this.page
5572
- .locator(abortFlow
5573
- ? MICROSOFT_LOGIN_SELECTORS.cancelButton
5574
- : MICROSOFT_LOGIN_SELECTORS.acceptButton)
5575
- .click();
5576
- await this.page.waitForLoadState("load", { timeout: 25_000 });
5577
- await this.neetoPlaywrightUtilities.waitForFloatingMenu();
5578
- };
5579
- enterEmail = async () => {
5580
- await this.page.waitForLoadState("load", { timeout: 25_000 });
5581
- await expect(this.page.getByRole("heading", { name: MICROSOFT_LOGIN_TEXTS.signIn })).toBeVisible({ timeout: 20_000 });
5582
- await this.page
5583
- .locator(MICROSOFT_LOGIN_SELECTORS.emailInput)
5584
- .or(this.page.locator(MICROSOFT_LOGIN_SELECTORS.placeholder))
5585
- .or(this.page.getByRole("textbox", {
5586
- name: MICROSOFT_LOGIN_TEXTS.emailInput,
5587
- }))
5588
- .pressSequentially(process.env.MICROSOFT_LOGIN_EMAIL, { delay: 25 });
5589
- };
5590
- enterPassword = async () => {
5591
- await this.page.waitForLoadState("load", { timeout: 25_000 });
5592
- await expect(this.page.getByRole("heading", {
5593
- name: MICROSOFT_LOGIN_TEXTS.enterPassword,
5594
- })).toBeVisible({ timeout: 10_000 });
5595
- await this.page
5596
- .getByPlaceholder(MICROSOFT_LOGIN_TEXTS.password)
5597
- .or(this.page.locator(MICROSOFT_LOGIN_SELECTORS.placeholder))
5598
- .or(this.page.getByRole("textbox", {
5599
- name: MICROSOFT_LOGIN_TEXTS.passwordInput,
5600
- }))
5601
- .pressSequentially(process.env.MICROSOFT_LOGIN_PASSWORD, { delay: 15 });
4761
+ .getByPlaceholder(MICROSOFT_LOGIN_TEXTS.password)
4762
+ .or(this.page.locator(MICROSOFT_LOGIN_SELECTORS.placeholder))
4763
+ .or(this.page.getByRole("textbox", {
4764
+ name: MICROSOFT_LOGIN_TEXTS.passwordInput,
4765
+ }))
4766
+ .pressSequentially(password, { delay: 15 });
5602
4767
  };
5603
4768
  loginToMicrosoft = async () => {
5604
4769
  if (IS_DEV_ENV)
5605
4770
  return;
5606
4771
  return withCookieCache("microsoft", this.page.context(), async () => {
5607
- if (isNil(process.env.MICROSOFT_LOGIN_EMAIL) ||
5608
- isNil(process.env.MICROSOFT_LOGIN_PASSWORD) ||
5609
- isNil(process.env.MICROSOFT_2FA_SECRET_KEY)) {
5610
- throw new Error("ENV variable MICROSOFT_LOGIN_EMAIL or MICROSOFT_LOGIN_PASSWORD or MICROSOFT_2FA_SECRET_KEY is not properly configured");
5611
- }
4772
+ const env = requireEnv("MICROSOFT_LOGIN_EMAIL", "MICROSOFT_LOGIN_PASSWORD", "MICROSOFT_2FA_SECRET_KEY");
5612
4773
  const useVerificationCodeButton = this.page.getByRole("button", {
5613
4774
  name: MICROSOFT_LOGIN_TEXTS.useVerificationCode,
5614
4775
  });
5615
4776
  await this.page.goto(THIRD_PARTY_ROUTES.microsoft.login);
5616
- await this.enterEmail();
4777
+ await this.enterEmail(env.MICROSOFT_LOGIN_EMAIL);
5617
4778
  await this.page
5618
4779
  .getByRole("button", { name: MICROSOFT_LOGIN_TEXTS.next })
5619
4780
  .click();
5620
- await this.enterPassword();
4781
+ await this.enterPassword(env.MICROSOFT_LOGIN_PASSWORD);
5621
4782
  const signInButton = this.page.getByRole("button", {
5622
4783
  name: MICROSOFT_LOGIN_TEXTS.signIn,
5623
4784
  });
@@ -5808,33 +4969,27 @@ class SlackPage extends IntegrationBase {
5808
4969
  loginToSlackWebapp = async (slackWebappPage, customCredentials) => {
5809
4970
  this.slackWebappPage = slackWebappPage;
5810
4971
  this.slackWebappPageDataQa = getByDataQA(this.slackWebappPage);
5811
- const slackWorkspace = customCredentials?.workspace || process.env.SLACK_WORKSPACE;
5812
- const slackLoginPassword = customCredentials?.loginPassword || process.env.SLACK_LOGIN_PASSWORD;
5813
- const slackLoginEmail = customCredentials?.loginEmail || process.env.SLACK_LOGIN_EMAIL;
5814
- if (isNotNil(slackWorkspace) &&
5815
- isNotNil(slackLoginPassword) &&
5816
- isNotNil(slackLoginEmail)) {
5817
- await slackWebappPage.goto(THIRD_PARTY_ROUTES.slack.loginWithPassword(slackWorkspace), { timeout: 20_000 });
5818
- await slackWebappPage.waitForLoadState("load", { timeout: 25_000 });
5819
- await slackWebappPage
5820
- .locator(SLACK_SELECTORS.loginEmail)
5821
- .pressSequentially(slackLoginEmail, { delay: 10 });
5822
- await slackWebappPage
5823
- .locator(SLACK_SELECTORS.loginPassword)
5824
- .pressSequentially(slackLoginPassword, { delay: 10 });
5825
- await slackWebappPage
5826
- .locator(SLACK_SELECTORS.signInButton)
5827
- .click({ timeout: 35_000 });
5828
- await slackWebappPage.waitForLoadState("domcontentloaded", {
5829
- timeout: 25_000,
5830
- });
5831
- const redirectOpenInBrowser = slackWebappPage.locator(SLACK_SELECTORS.redirectOpenInBrowser);
5832
- await expect(redirectOpenInBrowser).toBeVisible({ timeout: 25_000 });
5833
- await redirectOpenInBrowser.click();
5834
- await this.setupCloseHandlers(slackWebappPage);
5835
- return;
5836
- }
5837
- throw new Error("ENV variable SLACK_LOGIN_EMAIL or SLACK_LOGIN_PASSWORD or SLACK_WORKSPACE is not defined.");
4972
+ const slackWorkspace = customCredentials?.workspace || requireEnv("SLACK_WORKSPACE");
4973
+ const slackLoginPassword = customCredentials?.loginPassword || requireEnv("SLACK_LOGIN_PASSWORD");
4974
+ const slackLoginEmail = customCredentials?.loginEmail || requireEnv("SLACK_LOGIN_EMAIL");
4975
+ await slackWebappPage.goto(THIRD_PARTY_ROUTES.slack.loginWithPassword(slackWorkspace), { timeout: 20_000 });
4976
+ await slackWebappPage.waitForLoadState("load", { timeout: 25_000 });
4977
+ await slackWebappPage
4978
+ .locator(SLACK_SELECTORS.loginEmail)
4979
+ .pressSequentially(slackLoginEmail, { delay: 10 });
4980
+ await slackWebappPage
4981
+ .locator(SLACK_SELECTORS.loginPassword)
4982
+ .pressSequentially(slackLoginPassword, { delay: 10 });
4983
+ await slackWebappPage
4984
+ .locator(SLACK_SELECTORS.signInButton)
4985
+ .click({ timeout: 35_000 });
4986
+ await slackWebappPage.waitForLoadState("domcontentloaded", {
4987
+ timeout: 25_000,
4988
+ });
4989
+ const redirectOpenInBrowser = slackWebappPage.locator(SLACK_SELECTORS.redirectOpenInBrowser);
4990
+ await expect(redirectOpenInBrowser).toBeVisible({ timeout: 25_000 });
4991
+ await redirectOpenInBrowser.click();
4992
+ await this.setupCloseHandlers(slackWebappPage);
5838
4993
  };
5839
4994
  logoutFromSlackWebApp = async () => {
5840
4995
  await this.slackWebappPage
@@ -5877,73 +5032,6 @@ class SlackPage extends IntegrationBase {
5877
5032
  };
5878
5033
  }
5879
5034
 
5880
- class WebhooksPage {
5881
- page;
5882
- neetoPlaywrightUtilities;
5883
- webhookSiteApi;
5884
- t;
5885
- constructor({ page, neetoPlaywrightUtilities }) {
5886
- this.page = page;
5887
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
5888
- this.t = getI18nInstance().t;
5889
- this.webhookSiteApi = new WebhookSiteApi(page.request);
5890
- }
5891
- getTokenViaAPI = async () => {
5892
- let webhookToken = null;
5893
- await expect(async () => {
5894
- const response = await this.webhookSiteApi.create();
5895
- await expect(response).toBeOK();
5896
- webhookToken = (await response.json())?.uuid;
5897
- }).toPass({ timeout: 15_000 });
5898
- if (!webhookToken)
5899
- throw new Error("Failed to get webhook token");
5900
- return {
5901
- webhookToken,
5902
- webhookSiteURL: `${THIRD_PARTY_ROUTES.webhooks.site}${webhookToken}`,
5903
- };
5904
- };
5905
- addWebhook = async ({ webhookSiteURL }) => {
5906
- await this.page.getByTestId(WEBHOOK_SELECTORS.addNewWebhook).click();
5907
- await this.page
5908
- .getByTestId(WEBHOOK_SELECTORS.endpointInputField)
5909
- .fill(webhookSiteURL);
5910
- await Promise.all([
5911
- this.page.getByTestId(COMMON_SELECTORS.saveChangesButton).click(),
5912
- this.neetoPlaywrightUtilities.verifyToast({
5913
- message: this.t("resource.add", {
5914
- entity: "webhook",
5915
- count: 1,
5916
- }),
5917
- }),
5918
- ]);
5919
- await expect(this.page.getByRole("row", { name: webhookSiteURL })).toBeVisible();
5920
- };
5921
- verifyLatestWebhookResponse = ({ callback = () => { }, webhookToken, parseFullResponseContent = false, timeout = 20_000, ...otherParams }) => expect(async () => {
5922
- const response = await this.webhookSiteApi.fetch(webhookToken);
5923
- await expect(response).toBeOK();
5924
- const { content } = await response.json();
5925
- const parsedResponse = parseFullResponseContent
5926
- ? JSON.parse(content)
5927
- : JSON.parse(content).webhook;
5928
- callback({ parsedResponse, ...otherParams });
5929
- }).toPass({ timeout });
5930
- verifyWebhookDeliveries = async ({ callback = () => { }, ...otherParams }) => {
5931
- await expect(this.page.getByTestId(WEBHOOK_SELECTORS.deliveryResponseCode)).toHaveText("200");
5932
- const requestPayload = (await this.page
5933
- .getByTestId(WEBHOOK_SELECTORS.deliveryRequestPayload)
5934
- .textContent());
5935
- const parsedResponse = JSON.parse(requestPayload).webhook;
5936
- callback({ parsedResponse, ...otherParams });
5937
- };
5938
- verifyWebhookDeliveryByEvent = async ({ event, callbackToVerifyDeliveries, ...fieldsToBeVerified }) => {
5939
- await this.page.getByRole("row", { name: event }).getByRole("link").click();
5940
- await this.verifyWebhookDeliveries({
5941
- callback: callbackToVerifyDeliveries,
5942
- ...fieldsToBeVerified,
5943
- });
5944
- };
5945
- }
5946
-
5947
5035
  const simulateTypingWithDelay = async ({ field, value, delay = 500, }) => {
5948
5036
  const minSliceLength = Math.max(3, Math.floor(value.length * 0.6));
5949
5037
  const maxSliceLength = Math.max(4, Math.floor(value.length * 0.8));
@@ -5983,6 +5071,9 @@ class ZapierPage extends IntegrationBase {
5983
5071
  zapierWebPage;
5984
5072
  continueButton;
5985
5073
  mailerUtils;
5074
+ zapId;
5075
+ zapierLoginEmail;
5076
+ zapierLoginPassword;
5986
5077
  stepBlock;
5987
5078
  navbar;
5988
5079
  zapToggle;
@@ -5996,15 +5087,14 @@ class ZapierPage extends IntegrationBase {
5996
5087
  neetoPlaywrightUtilities,
5997
5088
  integrationRouteIndex,
5998
5089
  });
5999
- if (isNil(process.env.ZAPIER_LOGIN_PASSWORD) ||
6000
- isNil(process.env.ZAPIER_LOGIN_EMAIL) ||
6001
- isNil(process.env.ZAP_ID)) {
6002
- throw new Error("ENV variable ZAPIER_LOGIN_PASSWORD or ZAPIER_LOGIN_EMAIL or ZAP_ID is not properly configured");
6003
- }
5090
+ const env = requireEnv("ZAPIER_LOGIN_EMAIL", "ZAPIER_LOGIN_PASSWORD", "ZAP_ID");
5091
+ this.zapierLoginEmail = env.ZAPIER_LOGIN_EMAIL;
5092
+ this.zapierLoginPassword = env.ZAPIER_LOGIN_PASSWORD;
5093
+ this.zapId = env.ZAP_ID;
6004
5094
  this.mailerUtils = mailerUtils;
6005
5095
  }
6006
5096
  gotoZapEditor = async () => {
6007
- await this.zapierWebPage.goto(THIRD_PARTY_ROUTES.zapier.zapEditor(process.env.ZAP_ID));
5097
+ await this.zapierWebPage.goto(THIRD_PARTY_ROUTES.zapier.zapEditor(this.zapId));
6008
5098
  await this.zapierWebPage.waitForLoadState();
6009
5099
  await expect(this.firstStepBlock).toBeVisible({ timeout: 25_000 });
6010
5100
  };
@@ -6114,16 +5204,16 @@ class ZapierPage extends IntegrationBase {
6114
5204
  });
6115
5205
  await simulateTypingWithDelay({
6116
5206
  field: emailField,
6117
- value: process.env.ZAPIER_LOGIN_EMAIL,
5207
+ value: this.zapierLoginEmail,
6118
5208
  });
6119
5209
  await simulateClickWithDelay({
6120
5210
  element: this.continueButton,
6121
5211
  page: zapierWebPage,
6122
5212
  });
6123
- await expect(zapierWebPage.getByText(ZAPIER_WEB_TEXTS.welcomeText(process.env.ZAPIER_LOGIN_EMAIL))).toBeVisible({ timeout: 15_000 });
5213
+ await expect(zapierWebPage.getByText(ZAPIER_WEB_TEXTS.welcomeText(this.zapierLoginEmail))).toBeVisible({ timeout: 15_000 });
6124
5214
  await simulateTypingWithDelay({
6125
5215
  field: passwordField,
6126
- value: process.env.ZAPIER_LOGIN_PASSWORD,
5216
+ value: this.zapierLoginPassword,
6127
5217
  });
6128
5218
  await simulateClickWithDelay({
6129
5219
  element: this.continueButton,
@@ -6139,9 +5229,7 @@ class ZapierPage extends IntegrationBase {
6139
5229
  });
6140
5230
  await this.zapierWebPage.close();
6141
5231
  };
6142
- verifyZapIsTriggered = ({ productName, submittedEmail, zapTriggeredAfter, timeout = 2 * 60_000, }) => IS_MAILPIT_ENABLED
6143
- ? this.mailerUtils.findMessageV2({ to: ZAPIER_TEST_EMAIL_V2(productName), body: submittedEmail }, { timeout, receivedAfter: zapTriggeredAfter })
6144
- : this.mailerUtils.findMessage({ to: ZAPIER_TEST_EMAIL(productName), body: submittedEmail }, { timeout, receivedAfter: zapTriggeredAfter });
5232
+ verifyZapIsTriggered = ({ productName, submittedEmail, zapTriggeredAfter, timeout = 2 * 60_000, }) => this.mailerUtils.findMessage({ to: ZAPIER_TEST_EMAIL(productName), body: submittedEmail }, { timeout, receivedAfter: zapTriggeredAfter });
6145
5233
  skipIfTaskLimitIsExhausted = async () => {
6146
5234
  // Zapier provides 100 free task limit for free account; skip test if it's exhausted
6147
5235
  const universalSidebar = this.zapierWebPage.locator(ZAPIER_SELECTORS.universalSidebar);
@@ -6197,111 +5285,6 @@ class ZapierPage extends IntegrationBase {
6197
5285
  await this.neetoPlaywrightUtilities.verifyToast({ message: toastMessage });
6198
5286
  await this.verifyIntegrationStatus("disconnected");
6199
5287
  };
6200
- generateAPIKey = async (apiKeyLabel) => {
6201
- await this.page.getByTestId(API_KEYS_SELECTORS.addApiKeyButton).click();
6202
- await this.page
6203
- .getByTestId(COMMON_SELECTORS.paneBody)
6204
- .getByTestId(COMMON_SELECTORS.customInputField("label"))
6205
- .fill(apiKeyLabel);
6206
- await this.page.getByTestId(COMMON_SELECTORS.radioInput("zapier")).check();
6207
- await this.neetoPlaywrightUtilities.saveChanges({ isPane: true });
6208
- await this.page
6209
- .getByRole("row", { name: apiKeyLabel })
6210
- .getByTestId(COMMON_SELECTORS.copyToClipboardButton)
6211
- .click();
6212
- return getClipboardContent(this.page);
6213
- };
6214
- }
6215
-
6216
- const MEMBER_PAGE_SIZE = 200;
6217
- const NAME_SYNC_WAIT = 5_000;
6218
- class Member {
6219
- memberApis;
6220
- constructor(neetoPlaywrightUtilities) {
6221
- this.memberApis = new MemberApis(neetoPlaywrightUtilities);
6222
- }
6223
- addMemberViaRequest = async ({ email, role = MEMBER_TEXTS.agent, appName, subscriptionPlan = "free", }) => {
6224
- let response;
6225
- await expect
6226
- .poll(async () => {
6227
- response = await this.memberApis.create({
6228
- emails: [email],
6229
- organization_role: role,
6230
- app_roles: [
6231
- { app_name: appName, active_role: role, is_enabled: true },
6232
- ],
6233
- subscription_plan: subscriptionPlan,
6234
- });
6235
- return response?.status();
6236
- }, { timeout: 30_000 })
6237
- .toBe(200);
6238
- const responseBodyBuffer = await response?.body();
6239
- const { job_id: jobId } = JSON.parse(String(responseBodyBuffer));
6240
- await expect
6241
- .poll(async () => {
6242
- const jobResponse = await this.memberApis.jobStatus(jobId);
6243
- const responseBodyBuffer = await jobResponse?.body();
6244
- const { is_completed: isCompleted, is_successful: isSuccessful, error, } = JSON.parse(String(responseBodyBuffer));
6245
- if (isCompleted && !isSuccessful) {
6246
- throw new Error(`Member creation failed: ${error}`);
6247
- }
6248
- return isCompleted;
6249
- }, { timeout: 60_000 })
6250
- .toBe(true);
6251
- };
6252
- editMemberViaRequest = async ({ email, newEmail, firstName, lastName, newRole, subscriptionPlan, }) => {
6253
- const findMember = async (isRequestedMember) => {
6254
- for (let page = 1;; page++) {
6255
- const { members } = (await this.memberApis
6256
- .fetch({ page, page_size: MEMBER_PAGE_SIZE })
6257
- .then(response => response?.json()));
6258
- const member = members.find(isRequestedMember);
6259
- if (member || members.length < MEMBER_PAGE_SIZE)
6260
- return member;
6261
- }
6262
- };
6263
- const memberDetails = await findMember(member => member.email.toLowerCase() === email.toLowerCase());
6264
- if (!memberDetails)
6265
- throw new Error(`Member ${email} was not found`);
6266
- await expect(async () => {
6267
- await this.memberApis.update(memberDetails.id, keysToSnakeCase({
6268
- active: true,
6269
- firstName,
6270
- lastName,
6271
- organizationRole: newRole,
6272
- email: newEmail,
6273
- subscriptionPlan,
6274
- }));
6275
- if (!firstName && !lastName)
6276
- return;
6277
- await new Promise(resolve => setTimeout(resolve, NAME_SYNC_WAIT));
6278
- const updatedMember = await findMember(({ id }) => id === memberDetails.id);
6279
- expect(updatedMember, `Member ${email} was not found`).toBeDefined();
6280
- firstName && expect(updatedMember?.first_name).toBe(firstName);
6281
- lastName && expect(updatedMember?.last_name).toBe(lastName);
6282
- }).toPass({ timeout: 60_000 });
6283
- };
6284
- deactivateMemberViaRequest = (email) => this.memberApis.bulkUpdate({ active: false, emails: [email] });
6285
- generateRandomTeamMembers = ({ count = 1, role = "standard" }) => dynamicArray(count, () => ({
6286
- firstName: faker.person.firstName(),
6287
- lastName: faker.person.lastName(),
6288
- email: exampleEmail(),
6289
- role,
6290
- }));
6291
- getUserIdViaAPI = async (email) => {
6292
- const response = await this.memberApis.fetch();
6293
- const { members } = (await response?.json());
6294
- const member = findBy({ email }, members);
6295
- return member?.id;
6296
- };
6297
- updateEmailViaAPI = async ({ oldEmail, newEmail, role = "Admin", }) => {
6298
- const userId = await this.getUserIdViaAPI(oldEmail);
6299
- await this.memberApis.update(userId, keysToSnakeCase({
6300
- organizationRole: role,
6301
- email: newEmail,
6302
- active: true,
6303
- }));
6304
- };
6305
5288
  }
6306
5289
 
6307
5290
  const DESCRIPTION_EDITOR_TEXTS = {
@@ -6592,13 +5575,7 @@ class EditorPage {
6592
5575
  this.videoWrapperSelector = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.videoWrapper);
6593
5576
  this.emojiSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.emojiOption);
6594
5577
  const fixedMenuWrapper = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.fixedMenuWrapper);
6595
- const fixedMenuButtons = fixedMenuWrapper.getByRole("button");
6596
- const legacyMoreIcon = this.page.getByTestId(COMMON_SELECTORS.dropdownIcon);
6597
- this.moreMenuSelector = IS_SHADCN_UI
6598
- ? fixedMenuWrapper.getByTestId(NEETO_EDITOR_SELECTORS.moreMenuOption)
6599
- : fixedMenuButtons
6600
- .and(legacyMoreIcon)
6601
- .or(fixedMenuButtons.filter({ has: legacyMoreIcon }));
5578
+ this.moreMenuSelector = fixedMenuWrapper.getByTestId(NEETO_EDITOR_SELECTORS.moreMenuOption);
6602
5579
  this.contentField = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.contentField);
6603
5580
  this.dynamicVariablesButton = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.dynamicVariablesButton);
6604
5581
  this.calloutSelector = this.toolbarOption(NEETO_EDITOR_SELECTORS.calloutOption);
@@ -6642,9 +5619,6 @@ class EditorPage {
6642
5619
  if (await expandedMenuTrigger.isVisible()) {
6643
5620
  await expandedMenuTrigger.click({ timeout: 1_000 });
6644
5621
  }
6645
- else if (!IS_SHADCN_UI) {
6646
- await this.contentField.click();
6647
- }
6648
5622
  await expect(dropdownContainer).toBeHidden({ timeout: 1_000 });
6649
5623
  }).toPass({ timeout: 10_000 });
6650
5624
  };
@@ -6672,9 +5646,7 @@ class EditorPage {
6672
5646
  await this.moreMenuSelector.click();
6673
5647
  const dropdownContainer = this.page.getByTestId(COMMON_SELECTORS.dropdownContainer);
6674
5648
  await expect(dropdownContainer).toBeVisible();
6675
- const moreMenuButtons = await dropdownContainer
6676
- .getByRole(IS_SHADCN_UI ? "menuitem" : "button")
6677
- .all();
5649
+ const moreMenuButtons = await dropdownContainer.getByRole("menuitem").all();
6678
5650
  const moreMenuButtonLocators = await Promise.all(moreMenuButtons.map(async (button) => {
6679
5651
  const dataTestid = await button.getAttribute("data-testid");
6680
5652
  return this.cleanString(dataTestid);
@@ -6683,37 +5655,7 @@ class EditorPage {
6683
5655
  await expect(dropdownContainer).toBeHidden();
6684
5656
  return moreMenuButtonLocators;
6685
5657
  };
6686
- verifyFontSize = async (isButtonInMoreMenu = false) => IS_SHADCN_UI
6687
- ? this.verifyFontSizeV2(isButtonInMoreMenu)
6688
- : this.verifyFontSizeV1(isButtonInMoreMenu);
6689
- verifyFontSizeV1 = async (isButtonInMoreMenu) => {
6690
- const fontsAndTexts = [];
6691
- const fontSizeDropdown = this.page.getByTestId(NEETO_EDITOR_SELECTORS.fontSize);
6692
- await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
6693
- const headingButtons = await this.page
6694
- .getByTestId(NEETO_EDITOR_SELECTORS.fontSizeHeadingOptions)
6695
- .and(this.page.getByRole("button"))
6696
- .all();
6697
- const headingLevels = (await Promise.all(headingButtons.map(async (button) => {
6698
- const dataTestid = await button.getAttribute("data-testid");
6699
- const headingLevel = dataTestid?.split("-").pop();
6700
- return /^h[1-5]$/.test(headingLevel || "") ? headingLevel : null;
6701
- }))).filter(Boolean);
6702
- await this.dismissToolbarMenu();
6703
- for (const headingLevel of headingLevels) {
6704
- const fontKey = headingLevel;
6705
- const randomText = await this.fillRandomText();
6706
- await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
6707
- await this.page.getByTestId(FONT_SIZE_SELECTORS[fontKey]).click();
6708
- await expect(this.contentField.getByRole("heading", {
6709
- level: Number(headingLevel?.slice(1)),
6710
- name: randomText,
6711
- })).toBeVisible();
6712
- fontsAndTexts.push({ key: fontKey, value: randomText });
6713
- }
6714
- return fontsAndTexts;
6715
- };
6716
- verifyFontSizeV2 = async (isButtonInMoreMenu) => {
5658
+ verifyFontSize = async (isButtonInMoreMenu) => {
6717
5659
  const fontsAndTexts = [];
6718
5660
  const fontSizeDropdown = this.page.getByTestId(NEETO_EDITOR_SELECTORS.fontSize);
6719
5661
  await this.clickToolbarOption(fontSizeDropdown, isButtonInMoreMenu);
@@ -7051,9 +5993,7 @@ class EditorPage {
7051
5993
  verifyCalloutSelector = async (isButtonInMoreMenu) => {
7052
5994
  const calloutTypes = ["default", "info", "warning", "error", "success"];
7053
5995
  const calloutContentField = this.contentField.locator(NEETO_EDITOR_SELECTORS.calloutContent);
7054
- const calloutTypeOption = IS_SHADCN_UI
7055
- ? this.page.getByTestId(NEETO_EDITOR_SELECTORS.calloutTypeOptionV2)
7056
- : this.page.locator(NEETO_EDITOR_SELECTORS.calloutTypeOption);
5996
+ const calloutTypeOption = this.page.getByTestId(NEETO_EDITOR_SELECTORS.calloutTypeOptionV2);
7057
5997
  await this.moveCursorAtBottom();
7058
5998
  for (const [index, type] of calloutTypes.entries()) {
7059
5999
  await this.clickToolbarOption(this.calloutSelector, isButtonInMoreMenu);
@@ -7267,673 +6207,70 @@ class ImageUploader {
7267
6207
  aspectRatioHeight,
7268
6208
  aspectRatioWidth,
7269
6209
  width,
7270
- height,
7271
- });
7272
- await this.submitCroppedImage();
7273
- };
7274
- selectImageFromWeb = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
7275
- await this.openImageLibrary();
7276
- await this.page
7277
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashTab)
7278
- .click();
7279
- if (isNotEmpty(searchTerm)) {
7280
- await this.page
7281
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
7282
- .fill(searchTerm);
7283
- await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
7284
- timeout: 10_000,
7285
- });
7286
- }
7287
- await this.page
7288
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthUnsplashImage(nthImage))
7289
- .click();
7290
- await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
7291
- timeout: 10_000,
7292
- });
7293
- toggleOrginalImage
7294
- ? await this.page
7295
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
7296
- .click()
7297
- : await this.cropImage({
7298
- toggleAspectRatioLock,
7299
- aspectRatioHeight,
7300
- aspectRatioWidth,
7301
- width,
7302
- height,
7303
- });
7304
- await this.submitCroppedImage();
7305
- };
7306
- selectImageFromLibrary = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
7307
- await this.openImageLibrary();
7308
- await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
7309
- timeout: 10_000,
7310
- });
7311
- if (isNotEmpty(searchTerm)) {
7312
- await this.page
7313
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
7314
- .fill(searchTerm);
7315
- await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
7316
- timeout: 10_000,
7317
- });
7318
- }
7319
- await this.page
7320
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthLibraryImage(nthImage))
7321
- .click();
7322
- toggleOrginalImage
7323
- ? await this.page
7324
- .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
7325
- .click()
7326
- : await this.cropImage({
7327
- toggleAspectRatioLock,
7328
- aspectRatioHeight,
7329
- aspectRatioWidth,
7330
- width,
7331
- height,
7332
- });
7333
- await this.submitCroppedImage();
7334
- };
7335
- }
7336
-
7337
- const openFilterPane = async (page) => {
7338
- await page
7339
- .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7340
- .or(page.getByTestId(COMMON_SELECTORS.filterButon))
7341
- .click();
7342
- await expect(page.getByTestId(COMMON_SELECTORS.paneHeader)).toHaveText(getI18nInstance().t("neetoFilters.common.filters"));
7343
- };
7344
- const openFilterPaneV2 = async (page) => {
7345
- await page
7346
- .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7347
- .or(page.getByTestId(COMMON_SELECTORS.filterButon))
7348
- .click();
7349
- await expect(page.getByTestId(NEETO_FILTERS_SELECTORS.filterPaneHeading)).toHaveText(getI18nInstance().t("neetoFilters.common.filters"));
7350
- };
7351
- const clearFiltersFromActionBlock = async (page) => {
7352
- const isClearButtonVisible = await page
7353
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)
7354
- .isVisible();
7355
- if (isClearButtonVisible) {
7356
- await page
7357
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)
7358
- .click();
7359
- await Promise.all([
7360
- expect(page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeHidden(),
7361
- expect(page.locator(COMMON_SELECTORS.tableSpinner)).toHaveCount(0, {
7362
- timeout: 15_000,
7363
- }),
7364
- ]);
7365
- }
7366
- };
7367
- const filterUtils = {
7368
- openFilterPane,
7369
- openFilterPaneV2,
7370
- clearFiltersFromActionBlock,
7371
- };
7372
-
7373
- class TeamMembers {
7374
- page;
7375
- neetoPlaywrightUtilities;
7376
- t;
7377
- constructor({ page, neetoPlaywrightUtilities, }) {
7378
- this.page = page;
7379
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
7380
- this.t = getI18nInstance().t;
7381
- }
7382
- navigateToTeamMembers = async () => {
7383
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7384
- await this.page.getByTestId(MEMBER_SELECTORS.membersTab).click();
7385
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7386
- };
7387
- openMemberPane = async () => {
7388
- await this.page.getByTestId(MEMBER_SELECTORS.newButton).click();
7389
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7390
- const continueButton = this.page.getByTestId(MEMBER_SELECTORS.continueButton);
7391
- await expect(continueButton).toBeVisible();
7392
- await expect(continueButton.getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden({ timeout: 35_000 });
7393
- };
7394
- fillMemberForm = async (emails, role) => {
7395
- await this.page
7396
- .getByTestId(MEMBER_FORM_SELECTORS.emailTextField)
7397
- .fill(emails.join(", "));
7398
- await this.page.keyboard.press("Enter");
7399
- role &&
7400
- (await this.neetoPlaywrightUtilities.toggleElement({
7401
- locator: this.page.getByTestId(MEMBER_SELECTORS.roleLabel(role)),
7402
- }));
7403
- const continueBtn = this.page.getByTestId(MEMBER_SELECTORS.continueButton);
7404
- await continueBtn.click();
7405
- if (IS_DEV_ENV)
7406
- return;
7407
- await this.page
7408
- .getByTestId(COMMON_SELECTORS.paneBody)
7409
- .getByTestId(COMMON_SELECTORS.checkboxLabel)
7410
- .click();
7411
- await continueBtn.click();
7412
- };
7413
- addMemberViaUI = async ({ emails = [exampleEmail()], role = "standard", } = {}) => {
7414
- await this.openMemberPane();
7415
- await this.fillMemberForm(emails, role);
7416
- await this.submit();
7417
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7418
- };
7419
- submit = async () => {
7420
- const pane = this.page.getByTestId(COMMON_SELECTORS.paneBody);
7421
- const submitBtn = this.page.getByTestId(MEMBER_SELECTORS.submitButton);
7422
- const buttonSpinner = submitBtn.getByTestId(COMMON_SELECTORS.uiSpinner);
7423
- await expect(submitBtn).toBeVisible({ timeout: 10_000 });
7424
- await expect(async () => {
7425
- if (await pane.isHidden())
7426
- return;
7427
- (await buttonSpinner.isHidden()) && (await submitBtn.click());
7428
- await expect(buttonSpinner).toHaveCount(0, { timeout: 10_000 });
7429
- await expect(pane).toBeHidden();
7430
- }).toPass({ timeout: 60_000 });
7431
- await this.neetoPlaywrightUtilities.verifyToast();
7432
- };
7433
- searchAndVerifyMemberByEmail = async ({ email }) => {
7434
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7435
- await this.page.getByTestId(MEMBER_SELECTORS.searchTextField).fill(email);
7436
- const emailSubstr = email.length > 20 ? email.substring(0, 20) : email;
7437
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.searchTermBlock)).toContainText(emailSubstr);
7438
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7439
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7440
- await expect(this.page.getByRole("cell", { name: email, exact: true })).toBeVisible();
7441
- };
7442
- editMemberViaUI = async ({ email = "", firstName = "", lastName = "", role = "standard", } = {}) => {
7443
- await this.page.getByTestId(MEMBER_SELECTORS.dropDownIcon).click();
7444
- await this.page.getByTestId(MEMBER_SELECTORS.editButton).click();
7445
- await this.neetoPlaywrightUtilities.waitForPaneToLoad();
7446
- await expect(this.page
7447
- .getByTestId(MEMBER_SELECTORS.submitButton)
7448
- .getByTestId(COMMON_SELECTORS.uiSpinner)).toHaveCount(0, { timeout: 35_000 });
7449
- isPresent(email) &&
7450
- (await this.page
7451
- .getByTestId(MEMBER_FORM_SELECTORS.emailInput)
7452
- .fill(email));
7453
- isPresent(firstName) &&
7454
- (await this.page
7455
- .getByTestId(MEMBER_FORM_SELECTORS.firstNameTextField)
7456
- .fill(firstName));
7457
- isPresent(lastName) &&
7458
- (await this.page
7459
- .getByTestId(MEMBER_FORM_SELECTORS.lastNameTextField)
7460
- .fill(lastName));
7461
- await this.neetoPlaywrightUtilities.toggleElement({
7462
- locator: this.page.getByTestId(MEMBER_SELECTORS.roleLabel(role)),
7463
- });
7464
- await this.submit();
7465
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7466
- };
7467
- removeMemberViaUI = async (parentLocator = this.page) => {
7468
- await parentLocator.getByTestId(MEMBER_SELECTORS.dropDownIcon).click();
7469
- await this.page.getByTestId(MEMBER_SELECTORS.removeMember).click();
7470
- await this.page
7471
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
7472
- .click();
7473
- await this.neetoPlaywrightUtilities.verifyToast();
7474
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7475
- };
7476
- openFilterPane = async () => {
7477
- await this.page
7478
- .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7479
- .or(this.page.getByTestId(COMMON_SELECTORS.filterButon))
7480
- .click();
7481
- await expect(this.page.getByTestId(COMMON_SELECTORS.paneHeader)).toHaveText(this.t("neetoFilters.common.filters"));
7482
- };
7483
- filterMembersByMultiSelect = async ({ selectedOptions = [], selectContainerLocator = NEETO_FILTERS_SELECTORS.roleSelectContainer, }) => {
7484
- await this.page
7485
- .getByTestId(selectContainerLocator)
7486
- .getByTestId(COMMON_SELECTORS.actionSelectIndicator)
7487
- .click();
7488
- for (const option of selectedOptions) {
7489
- await this.page
7490
- .getByTestId(COMMON_SELECTORS.selectOption(option))
7491
- .click();
7492
- }
7493
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7494
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7495
- };
7496
- filterMembers = async ({ email = { id: "", condition: "Is" }, roles = [], name = "", }) => {
7497
- await filterUtils.clearFiltersFromActionBlock(this.page);
7498
- await filterUtils.openFilterPane(this.page);
7499
- if (isPresent(email.id)) {
7500
- await this.page
7501
- .getByTestId(NEETO_FILTERS_SELECTORS.emailSelectContainer)
7502
- .getByTestId(COMMON_SELECTORS.actionSelectIndicator)
7503
- .click();
7504
- await this.page
7505
- .getByTestId(COMMON_SELECTORS.selectOption(email.condition))
7506
- .click();
7507
- await this.page
7508
- .getByTestId(NEETO_FILTERS_SELECTORS.filtersEmailFilter)
7509
- .fill(email.id);
7510
- }
7511
- isPresent(name) &&
7512
- (await this.page
7513
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersNameFilterField)
7514
- .fill(name));
7515
- isPresent(roles) &&
7516
- (await this.filterMembersByMultiSelect({ selectedOptions: roles }));
7517
- await this.applyFilter();
7518
- };
7519
- getMemberRowByName = (name) => this.page.getByRole("row").filter({
7520
- has: this.page.getByTestId(MEMBER_SELECTORS.memberNameCell(name)),
7521
- });
7522
- takeActionOnMembers = async ({ names = [], state, action, }) => {
7523
- if (isPresent(names)) {
7524
- for (const name of names) {
7525
- await this.getMemberRowByName(name).getByRole("checkbox").click();
7526
- }
7527
- }
7528
- else {
7529
- await this.page
7530
- .getByRole("columnheader", { name: MEMBER_TEXTS.selectAll })
7531
- .click();
7532
- }
7533
- await this.page.getByTestId(COMMON_SELECTORS.takeActionDropdown).click();
7534
- if (isPresent(state)) {
7535
- await this.page
7536
- .getByTestId(MEMBER_SELECTORS.takeActionStateOption(state))
7537
- .click();
7538
- }
7539
- else {
7540
- await this.page
7541
- .getByRole("button", { name: action?.actionButtonText })
7542
- .click();
7543
- await this.page
7544
- .getByRole("button", { name: action?.valueButtonText })
7545
- .click();
7546
- }
7547
- await this.page
7548
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
7549
- .click();
7550
- await this.neetoPlaywrightUtilities.verifyToast();
7551
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7552
- };
7553
- performColumnAction = async ({ columnName = "Name", actionButtonText = "Ascending", } = {}) => {
7554
- await this.page
7555
- .getByTestId(MEMBER_SELECTORS.teamMembersTable)
7556
- .getByLabel(columnName)
7557
- .getByTestId(TABLE_SELECTORS.columnMenuButton)
7558
- .click();
7559
- await this.page.getByRole("button", { name: actionButtonText }).click();
7560
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7561
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7562
- };
7563
- toggleMemberColumns = async ({ columns = [], bulkAction, }) => {
7564
- await expect(async () => {
7565
- await this.page
7566
- .getByTestId(COMMON_SELECTORS.columnsDropdownButton)
7567
- .click();
7568
- await expect(this.page.getByTestId(COMMON_SELECTORS.columnsSearchInput)).toBeVisible();
7569
- }).toPass({ timeout: 15_000 });
7570
- if (isPresent(bulkAction)) {
7571
- await this.page
7572
- .getByTestId(COMMON_SELECTORS.columnVisibilityBtn(bulkAction === "hide" ? "hide-all" : "reset"))
7573
- .click();
7574
- }
7575
- else {
7576
- for (const column of columns) {
7577
- await this.page
7578
- .getByTestId(COMMON_SELECTORS.columnsSearchInput)
7579
- .fill(column);
7580
- const columnCheckbox = this.page
7581
- .getByTestId(COMMON_SELECTORS.nuiCheckboxContainer)
7582
- .filter({ hasText: column })
7583
- .getByTestId(MEMBER_SELECTORS.columnCheckBox);
7584
- const isChecked = await columnCheckbox.isChecked();
7585
- await columnCheckbox.click();
7586
- await expect(columnCheckbox).toBeChecked({ checked: !isChecked });
7587
- }
7588
- }
7589
- await this.page.getByTestId(COMMON_SELECTORS.columnsDropdownButton).click();
7590
- };
7591
- verifyMemberInTable = ({ name, email }) => expect(this.getMemberRowByName(name).getByRole("cell", {
7592
- name: email,
7593
- exact: true,
7594
- })).toBeVisible();
7595
- applyFilter = async () => {
7596
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible();
7597
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7598
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden({
7599
- timeout: 30_000,
7600
- });
7601
- await this.page
7602
- .getByTestId(NEETO_FILTERS_SELECTORS.filterDoneButton)
7603
- .click();
7604
- };
7605
- exportDetails = async (fileType, adminEmail) => {
7606
- await this.page.getByTestId(MEMBER_SELECTORS.downloadButton).click();
7607
- await expect(this.page.getByTestId(MEMBER_SELECTORS.exportMemberHeading)).toHaveText(this.t("neetoTeamMembers.exportPane.title"));
7608
- await this.page
7609
- .getByTestId(MEMBER_SELECTORS.downloadAsRadioItem(fileType))
7610
- .check();
7611
- const exportStartTime = new Date();
7612
- await this.page.getByTestId(MEMBER_SELECTORS.exportSubmitBtn).click();
7613
- await this.neetoPlaywrightUtilities.verifyToast({
7614
- message: this.t("toastr.success.exportMembers", { email: adminEmail }),
7615
- });
7616
- return exportStartTime;
7617
- };
7618
- verifyNoDataTitle = async (email) => {
7619
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7620
- await this.page.getByTestId(MEMBER_SELECTORS.searchTextField).fill(email);
7621
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible();
7622
- await expect(this.page.getByTestId(COMMON_SELECTORS.noDataTitle)).toBeVisible({ timeout: 10_000 });
7623
- await filterUtils.clearFiltersFromActionBlock(this.page);
7624
- };
7625
- }
7626
- class TeamMembersV2 extends TeamMembers {
7627
- fillMemberForm = async (emails, role) => {
7628
- await this.page
7629
- .getByTestId(MEMBER_FORM_SELECTORS.emailTextField)
7630
- .pressSequentially(emails.join(", "));
7631
- const continueBtn = this.page.getByTestId(MEMBER_SELECTORS.continueButton);
7632
- await this.page.keyboard.press("Enter");
7633
- await expect(continueBtn).toBeEnabled();
7634
- role &&
7635
- (await this.neetoPlaywrightUtilities.toggleElement({
7636
- locator: this.page.getByRole("radio", { name: role, exact: true }),
7637
- }));
7638
- await continueBtn.click();
7639
- if (IS_DEV_ENV)
7640
- return;
7641
- await this.page.getByTestId(MEMBER_SELECTORS.manageAppListChk).click();
7642
- await continueBtn.click();
7643
- };
7644
- openMemberPane = async () => {
7645
- await this.page.getByTestId(MEMBER_SELECTORS.newButton).click();
7646
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7647
- const continueButton = this.page.getByTestId(MEMBER_SELECTORS.continueButton);
7648
- await expect(continueButton).toBeVisible();
7649
- await this.neetoPlaywrightUtilities.waitForSheetOpen();
7650
- await expect(continueButton.getByTestId(COMMON_SELECTORS.uiSpinner)).toBeHidden({ timeout: 35_000 });
7651
- };
7652
- addMemberViaUI = async ({ emails = [exampleEmail()], role = "standard", } = {}) => {
7653
- await this.openMemberPane();
7654
- await this.fillMemberForm(emails, role);
7655
- await this.submit();
7656
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7657
- };
7658
- submit = async () => {
7659
- const pane = this.page.getByRole("dialog");
7660
- const submitBtn = this.page.getByTestId(MEMBER_SELECTORS.submitButton);
7661
- const buttonSpinner = submitBtn.getByTestId(COMMON_SELECTORS.uiSpinner);
7662
- await expect(submitBtn).toBeVisible({ timeout: 10_000 });
7663
- await expect(async () => {
7664
- if (await pane.isHidden())
7665
- return;
7666
- (await buttonSpinner.isHidden()) && (await submitBtn.click());
7667
- await expect(buttonSpinner).toHaveCount(0, { timeout: 10_000 });
7668
- await expect(pane).toBeHidden();
7669
- }).toPass({ timeout: 60_000 });
7670
- await this.neetoPlaywrightUtilities.verifyToast();
7671
- };
7672
- editMemberViaUI = async ({ email = "", firstName = "", lastName = "", role = "standard", } = {}) => {
7673
- await expect(this.page.getByTestId(MEMBER_SELECTORS.dropDownIcon)).toHaveCount(1);
7674
- await this.page.getByTestId(MEMBER_SELECTORS.dropDownIcon).click();
7675
- await this.page.getByTestId(MEMBER_SELECTORS.editButton).click();
7676
- const editPane = this.page.getByRole("dialog");
7677
- await expect(editPane).toBeVisible({ timeout: 35_000 });
7678
- await expect(editPane.getByTestId(COMMON_SELECTORS.uiSpinner)).toHaveCount(0, { timeout: 35_000 });
7679
- await expect(this.page
7680
- .getByTestId(MEMBER_SELECTORS.submitButton)
7681
- .getByTestId(COMMON_SELECTORS.uiSpinner)).toHaveCount(0, { timeout: 35_000 });
7682
- await this.neetoPlaywrightUtilities.waitForSheetOpen();
7683
- isPresent(email) &&
7684
- (await this.page
7685
- .getByTestId(MEMBER_FORM_SELECTORS.emailInput)
7686
- .fill(email));
7687
- isPresent(firstName) &&
7688
- (await this.page
7689
- .getByTestId(MEMBER_FORM_SELECTORS.firstNameTextField)
7690
- .fill(firstName));
7691
- isPresent(lastName) &&
7692
- (await this.page
7693
- .getByTestId(MEMBER_FORM_SELECTORS.lastNameTextField)
7694
- .fill(lastName));
7695
- await this.neetoPlaywrightUtilities.toggleElement({
7696
- locator: this.page.getByRole("radio", { name: role, exact: true }),
7697
- });
7698
- await this.submit();
7699
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7700
- };
7701
- openFilterPane = async () => {
7702
- await this.page
7703
- .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7704
- .or(this.page.getByTestId(COMMON_SELECTORS.filterButon))
7705
- .click();
7706
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.filterPaneHeading)).toHaveText(this.t("neetoFilters.common.filters"));
7707
- };
7708
- filterMembersByMultiSelect = async ({ selectedOptions = [], selectContainerLocator = NEETO_FILTERS_SELECTORS.roleSelectContainer, }) => {
7709
- await this.page
7710
- .getByTestId(selectContainerLocator)
7711
- .getByRole("combobox")
7712
- .click({ timeout: 30_000 });
7713
- for (const option of selectedOptions) {
7714
- await this.page
7715
- .getByRole("option", { name: option, exact: true })
7716
- .click();
7717
- }
7718
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7719
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7720
- };
7721
- filterMembers = async ({ email = { id: "", condition: "Is" }, roles = [], name = "", }) => {
7722
- await filterUtils.clearFiltersFromActionBlock(this.page);
7723
- await this.openFilterPane();
7724
- if (isPresent(email.id)) {
7725
- await this.page
7726
- .getByTestId(NEETO_FILTERS_SELECTORS.emailSelectContainer)
7727
- .getByRole("combobox")
7728
- .click();
7729
- await this.page
7730
- .getByRole("option", { name: email.condition, exact: true })
7731
- .click();
7732
- await this.page
7733
- .getByTestId(NEETO_FILTERS_SELECTORS.filtersEmailFilter)
7734
- .fill(email.id);
7735
- }
7736
- isPresent(name) &&
7737
- (await this.page
7738
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersNameFilterField)
7739
- .fill(name));
7740
- isPresent(roles) &&
7741
- (await this.filterMembersByMultiSelect({ selectedOptions: roles }));
7742
- await this.applyFilter();
7743
- };
7744
- verifyNoDataTitle = async (email) => {
7745
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7746
- await this.page.getByTestId(MEMBER_SELECTORS.searchTextField).fill(email);
7747
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible();
7748
- await expect(this.page.getByTestId(COMMON_SELECTORS.noDataTitleV2)).toBeVisible({ timeout: 10_000 });
7749
- await filterUtils.clearFiltersFromActionBlock(this.page);
7750
- };
7751
- applyFilter = async () => {
7752
- await expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible();
7753
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7754
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden({
7755
- timeout: 30_000,
7756
- });
7757
- await this.page
7758
- .getByTestId(NEETO_FILTERS_SELECTORS.filterDoneButton)
7759
- .click();
7760
- await this.neetoPlaywrightUtilities.waitForSheetClose();
7761
- };
7762
- performColumnAction = async ({ columnName = "Name", actionButtonText = "Ascending", } = {}) => {
7763
- await this.page
7764
- .getByTestId(TABLE_SELECTORS.columnHeaderTitle(hyphenate(columnName)))
7765
- .getByTestId(TABLE_SELECTORS.columnMenuButton)
7766
- .click();
7767
- await this.page.getByRole("menuitem", { name: actionButtonText }).click();
7768
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7769
- await expect(this.page.locator(COMMON_SELECTORS.tableSpinner)).toBeHidden();
7770
- };
7771
- takeActionOnMembers = async ({ names = [], state, action, }) => {
7772
- if (isPresent(names)) {
7773
- for (const name of names) {
7774
- await this.getMemberRowByName(name).getByRole("checkbox").click();
7775
- }
7776
- }
7777
- else {
7778
- await this.page
7779
- .getByRole("columnheader", { name: MEMBER_TEXTS.selectAll })
7780
- .click();
7781
- }
7782
- await this.page.getByTestId(MEMBER_SELECTORS.takeActionDropdown).click();
7783
- if (isPresent(state)) {
7784
- await this.page
7785
- .getByTestId(MEMBER_SELECTORS.takeActionStateOption(state))
7786
- .click();
7787
- }
7788
- else {
7789
- await this.page
7790
- .getByRole("menuitem", { name: action?.actionButtonText })
7791
- .click();
7792
- await this.page
7793
- .getByRole("menuitem", { name: action?.valueButtonText })
7794
- .click();
7795
- }
7796
- await this.page
7797
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
7798
- .click();
7799
- await this.neetoPlaywrightUtilities.verifyToast();
7800
- await this.neetoPlaywrightUtilities.waitForPageLoad();
7801
- };
7802
- }
7803
-
7804
- dayjs.extend(customParseFormat);
7805
- class ApiKeysPage {
7806
- page;
7807
- neetoPlaywrightUtilities;
7808
- t;
7809
- constructor(page, neetoPlaywrightUtilities) {
7810
- this.page = page;
7811
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
7812
- this.t = getI18nInstance().t;
7813
- }
7814
- enableExpiryDate = async (expiryDate) => {
7815
- const userProps = await getGlobalUserProps(this.page);
7816
- const normalizedDate = dayjs(expiryDate, DATE_FORMATS.date);
7817
- const formattedExpiryDate = normalizedDate.format(userProps?.dateFormat);
7818
- const expiryDateInput = this.page
7819
- .getByTestId(COMMON_SELECTORS.paneBody)
7820
- .getByTestId(ADMIN_PANEL_SELECTORS.expiryDateInput);
7821
- const nextYearBtn = this.page.getByLabel(DATE_TEXTS.nextYear, {
7822
- exact: true,
7823
- });
7824
- await this.page
7825
- .getByTestId(COMMON_SELECTORS.checkboxInput("never-expires"))
7826
- .uncheck();
7827
- await expiryDateInput.click();
7828
- await expect(nextYearBtn).toBeVisible();
7829
- await expiryDateInput.pressSequentially(formattedExpiryDate, {
7830
- delay: 250,
7831
- });
7832
- await Promise.all([
7833
- expect(expiryDateInput).toHaveValue(formattedExpiryDate),
7834
- expect(this.page.getByRole("button", { name: CALENDAR_LABELS.month })).toHaveText(normalizedDate.format(DATE_FORMATS.month)),
7835
- expect(this.page.getByRole("button", { name: CALENDAR_LABELS.year })).toHaveText(normalizedDate.format(DATE_FORMATS.year)),
7836
- expect(this.page.getByTitle(normalizedDate.format(DATE_FORMATS.calendarDate))).toHaveClass(RegExp(DATE_PICKER_SELECTORS.selectedDateInCalendarClass)),
7837
- ]);
7838
- await this.page.keyboard.press("Enter");
7839
- await expect(nextYearBtn).toBeHidden({ timeout: 15_000 });
7840
- };
7841
- fillApiKeyDetails = async ({ label, expiryDate }) => {
7842
- await this.page
7843
- .getByTestId(COMMON_SELECTORS.paneBody)
7844
- .getByTestId(COMMON_SELECTORS.customInputField("name"))
7845
- .fill(label);
7846
- isPresent(expiryDate) && (await this.enableExpiryDate(expiryDate));
7847
- await this.neetoPlaywrightUtilities.saveChanges({ isPane: true });
7848
- };
7849
- verifyApiKey = ({ targetRow, label, date }) => Promise.all([
7850
- expect(targetRow.getByRole("cell", { name: label })).toBeVisible(),
7851
- expect(targetRow.getByRole("cell", { name: date })).toBeVisible(),
7852
- expect(targetRow.getByRole("cell", {
7853
- name: this.t("neetoApiKeys.common.never"),
7854
- })).toBeVisible(),
7855
- expect(targetRow.getByTestId(TAGS_SELECTORS.tagContainer)).toHaveText(this.t("neetoApiKeys.tags.active")),
7856
- ]);
7857
- editApiKey = async ({ label, expiryDate }) => {
7858
- await this.page
7859
- .getByTestId(COMMON_SELECTORS.dropdownContainer)
7860
- .getByTestId(API_KEYS_SELECTORS.editApiKeyButton)
7861
- .click();
7862
- await this.fillApiKeyDetails({ label, expiryDate });
6210
+ height,
6211
+ });
6212
+ await this.submitCroppedImage();
7863
6213
  };
7864
- deleteApiKey = async (targetRow) => {
7865
- await targetRow.getByTestId(COMMON_SELECTORS.dropdownIcon).click();
6214
+ selectImageFromWeb = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
6215
+ await this.openImageLibrary();
7866
6216
  await this.page
7867
- .getByTestId(COMMON_SELECTORS.dropdownContainer)
7868
- .getByTestId(API_KEYS_SELECTORS.deleteApiKeyButton)
6217
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashTab)
7869
6218
  .click();
6219
+ if (isNotEmpty(searchTerm)) {
6220
+ await this.page
6221
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
6222
+ .fill(searchTerm);
6223
+ await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
6224
+ timeout: 10_000,
6225
+ });
6226
+ }
7870
6227
  await this.page
7871
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
6228
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthUnsplashImage(nthImage))
7872
6229
  .click();
7873
- await this.neetoPlaywrightUtilities.verifyToast();
7874
- await expect(targetRow).toBeHidden();
7875
- };
7876
- }
7877
- class ApiKeysPageV2 extends ApiKeysPage {
7878
- enableExpiryDate = async (expiryDate) => {
7879
- const dialog = this.page.getByRole("dialog");
7880
- const neverExpiresCheckbox = dialog.getByRole("checkbox", {
7881
- name: this.t("neetoApiKeys.fields.neverExpire"),
7882
- });
7883
- await expect(async () => {
7884
- await neverExpiresCheckbox.uncheck();
7885
- await expect(neverExpiresCheckbox).not.toBeChecked();
7886
- }).toPass({ timeout: 10_000 });
7887
- const userProps = await getGlobalUserProps(this.page);
7888
- const formattedExpiryDate = dayjs(expiryDate, DATE_FORMATS.date).format(userProps?.dateFormat);
7889
- const expiryDateInput = dialog.getByRole("textbox", {
7890
- name: this.t("neetoApiKeys.fields.expiryDate"),
6230
+ await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
6231
+ timeout: 10_000,
7891
6232
  });
7892
- await expect(async () => {
7893
- await expiryDateInput.fill(formattedExpiryDate);
7894
- await expect(expiryDateInput).toHaveValue(formattedExpiryDate);
7895
- }).toPass({ timeout: 10_000 });
7896
- };
7897
- fillApiKeyDetails = async ({ label, expiryDate }) => {
7898
- const dialog = this.page.getByRole("dialog");
7899
- await this.page
7900
- .getByTestId(COMMON_SELECTORS.customInputField("name"))
7901
- .fill(label);
7902
- isPresent(expiryDate) && (await this.enableExpiryDate(expiryDate));
7903
- const saveChangesButton = this.page.getByTestId(COMMON_SELECTORS.saveChangesButton);
7904
- await expect(saveChangesButton).toBeEnabled({ timeout: 10_000 });
7905
- await saveChangesButton.click();
7906
- await Promise.all([
7907
- expect(dialog).toBeHidden(),
7908
- this.neetoPlaywrightUtilities.verifyToast(),
7909
- ]);
7910
- };
7911
- verifyApiKey = ({ targetRow, label, date }) => Promise.all([
7912
- expect(targetRow.getByRole("cell", { name: label })).toBeVisible(),
7913
- expect(targetRow.getByRole("cell", { name: date })).toBeVisible(),
7914
- expect(targetRow.getByRole("cell", {
7915
- name: this.t("neetoApiKeys.common.never"),
7916
- })).toBeVisible(),
7917
- expect(targetRow.getByTestId(COMMON_SELECTORS.badgeContainer)).toHaveText(this.t("neetoApiKeys.tags.active")),
7918
- ]);
7919
- editApiKey = async ({ label, expiryDate }) => {
7920
- await this.page
7921
- .getByRole("menu")
7922
- .getByTestId(API_KEYS_SELECTORS.editApiKeyButton)
7923
- .click();
7924
- await this.fillApiKeyDetails({ label, expiryDate });
6233
+ toggleOrginalImage
6234
+ ? await this.page
6235
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
6236
+ .click()
6237
+ : await this.cropImage({
6238
+ toggleAspectRatioLock,
6239
+ aspectRatioHeight,
6240
+ aspectRatioWidth,
6241
+ width,
6242
+ height,
6243
+ });
6244
+ await this.submitCroppedImage();
7925
6245
  };
7926
- deleteApiKey = async (targetRow) => {
7927
- await targetRow.getByTestId(COMMON_SELECTORS.dropdownIcon).click();
7928
- await this.page
7929
- .getByRole("menu")
7930
- .getByTestId(API_KEYS_SELECTORS.deleteApiKeyButton)
7931
- .click();
6246
+ selectImageFromLibrary = async ({ nthImage = 0, searchTerm = "", toggleOrginalImage = false, toggleAspectRatioLock = false, aspectRatioHeight = "9", aspectRatioWidth = "16", width = "100", height = "100", } = {}) => {
6247
+ await this.openImageLibrary();
6248
+ await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
6249
+ timeout: 10_000,
6250
+ });
6251
+ if (isNotEmpty(searchTerm)) {
6252
+ await this.page
6253
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.unsplashSearchInput)
6254
+ .fill(searchTerm);
6255
+ await expect(this.page.getByTestId(COMMON_SELECTORS.spinner)).toBeHidden({
6256
+ timeout: 10_000,
6257
+ });
6258
+ }
7932
6259
  await this.page
7933
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
6260
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.nthLibraryImage(nthImage))
7934
6261
  .click();
7935
- await this.neetoPlaywrightUtilities.verifyToast();
7936
- await expect(targetRow).toBeHidden();
6262
+ toggleOrginalImage
6263
+ ? await this.page
6264
+ .getByTestId(NEETO_IMAGE_UPLOADER_SELECTORS.selectOriginalImageSwitch)
6265
+ .click()
6266
+ : await this.cropImage({
6267
+ toggleAspectRatioLock,
6268
+ aspectRatioHeight,
6269
+ aspectRatioWidth,
6270
+ width,
6271
+ height,
6272
+ });
6273
+ await this.submitCroppedImage();
7937
6274
  };
7938
6275
  }
7939
6276
 
@@ -7956,15 +6293,11 @@ dayjs.extend(timezone);
7956
6293
  class AuditLogsPage {
7957
6294
  page;
7958
6295
  neetoPlaywrightUtilities;
7959
- currentDate;
7960
6296
  messageBuilders;
7961
6297
  admin;
7962
- constructor(page, neetoPlaywrightUtilities,
7963
- /** @deprecated Audit log messages no longer include the product name. */
7964
- _product, timeZone = "Asia/Kolkata") {
6298
+ constructor(page, neetoPlaywrightUtilities) {
7965
6299
  this.page = page;
7966
6300
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
7967
- this.currentDate = dayjs().tz(timeZone).format("MMM D, YYYY");
7968
6301
  this.messageBuilders = {
7969
6302
  [ACTIONS.inviteUsers]: (data) => `${this.admin} added ${data.emails.join(", ").toLowerCase()}.`,
7970
6303
  [ACTIONS.updatedUser]: (data) => `${this.admin} changed ${data.emails[0].toLowerCase()}'s email from ${data.emails[0].toLowerCase()} to ${data.emails[1].toLowerCase()}.`,
@@ -7995,8 +6328,10 @@ class AuditLogsPage {
7995
6328
  // eslint-disable-next-line playwright/no-nth-methods
7996
6329
  const card = this.page.getByTestId(AUDIT_LOGS_SELECTORS.card).first();
7997
6330
  const content = card.getByTestId(AUDIT_LOGS_SELECTORS.content);
6331
+ const { timeZone } = await getGlobalUserProps(this.page);
6332
+ const currentDate = dayjs().tz(timeZone).format("MMM D, YYYY");
7998
6333
  await Promise.all([
7999
- expect(content.getByTestId(AUDIT_LOGS_SELECTORS.timestamp)).toContainText(this.currentDate),
6334
+ expect(content.getByTestId(AUDIT_LOGS_SELECTORS.timestamp)).toContainText(currentDate),
8000
6335
  expect(content.getByTestId(AUDIT_LOGS_SELECTORS.text)).toHaveText(expectedMessage),
8001
6336
  ]);
8002
6337
  };
@@ -8088,9 +6423,7 @@ class CustomDomainPage {
8088
6423
  const validateButton = this.page.getByTestId(CUSTOM_DOMAIN_SELECTORS.customDomainValidateButton);
8089
6424
  await Promise.all([
8090
6425
  expect(validateButton).toBeVisible(),
8091
- expect(this.getValidationPaneBody().getByRole("cell", {
8092
- name: domain.split(".")[0],
8093
- })).toBeVisible(),
6426
+ expect(this.validationSheet.getByRole("cell", { name: domain.split(".")[0] })).toBeVisible(),
8094
6427
  ]);
8095
6428
  await this.neetoPlaywrightUtilities.waitForPageLoad();
8096
6429
  await validateButton.click();
@@ -8135,7 +6468,7 @@ class CustomDomainPage {
8135
6468
  const organizationPage = new OrganizationPage(loginPage, playwrightUtils);
8136
6469
  await loginPage.goto(loginUrl);
8137
6470
  await playwrightUtils.waitForPageLoad();
8138
- await organizationPage.loginViaSSO(email);
6471
+ await organizationPage.login({ email });
8139
6472
  await expect(loginPage).toHaveURL(RegExp(loginUrl), { timeout: 15_000 });
8140
6473
  await playwrightUtils.waitForPageLoad();
8141
6474
  };
@@ -8289,19 +6622,19 @@ class CustomDomainPage {
8289
6622
  waitUntil: "load",
8290
6623
  }));
8291
6624
  };
8292
- getValidationPaneBody = () => this.page.getByTestId(IS_SHADCN_UI ? COMMON_SELECTORS.sheetWrapper : COMMON_SELECTORS.paneBody);
8293
- getValidationPane = () => this.page.getByTestId(IS_SHADCN_UI ? COMMON_SELECTORS.sheetWrapper : COMMON_SELECTORS.pane);
6625
+ get validationSheet() {
6626
+ return this.page.getByTestId(COMMON_SELECTORS.sheetWrapper);
6627
+ }
8294
6628
  getCertificateInfrastructureSkipReason = async () => {
8295
- const pane = this.getValidationPaneBody();
8296
- if (await pane
6629
+ if (await this.validationSheet
8297
6630
  .getByText(RegExp(CERTIFICATE_LIMIT_EXCEEDED_REGEXP, "i"))
8298
6631
  .isVisible()) {
8299
6632
  return CERTIFICATE_LIMIT_EXCEEDED_MESSAGE;
8300
6633
  }
8301
6634
  const message = this.t("neetoCustomDomains.certificateProvisionFailed");
8302
6635
  const [hasProvisionFailedMessage, hasProvisionFailedFallback] = await Promise.all([
8303
- pane.getByText(message).isVisible(),
8304
- pane
6636
+ this.validationSheet.getByText(message).isVisible(),
6637
+ this.validationSheet
8305
6638
  .getByText(RegExp(CERTIFICATE_PROVISION_FAILED_REGEXP, "i"))
8306
6639
  .isVisible(),
8307
6640
  ]);
@@ -8311,7 +6644,7 @@ class CustomDomainPage {
8311
6644
  return null;
8312
6645
  };
8313
6646
  closeValidationPane = async () => {
8314
- const cancelButton = this.getValidationPane().getByTestId(COMMON_SELECTORS.cancelButton);
6647
+ const cancelButton = this.validationSheet.getByTestId(COMMON_SELECTORS.cancelButton);
8315
6648
  if (await cancelButton.isVisible())
8316
6649
  await cancelButton.click();
8317
6650
  };
@@ -8382,145 +6715,6 @@ class IPRestrictionsPage {
8382
6715
  };
8383
6716
  }
8384
6717
 
8385
- class RolesPage {
8386
- page;
8387
- neetoPlaywrightUtilities;
8388
- roleApis;
8389
- t;
8390
- constructor(page, neetoPlaywrightUtilities) {
8391
- this.page = page;
8392
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
8393
- this.roleApis = new RoleApis(neetoPlaywrightUtilities);
8394
- this.t = getI18nInstance().t;
8395
- }
8396
- getPermissionIds = async (targetPermissions, isGranularPermission = false) => {
8397
- const { permissions } = await this.roleApis
8398
- .fetch("permissions")
8399
- .then(response => response?.json());
8400
- const permissionObjects = targetPermissions.flatMap(permission => permissions.filter((p) => isGranularPermission
8401
- ? p.description === permission
8402
- : p.category === permission));
8403
- return pluck("id", permissionObjects);
8404
- };
8405
- getRoleIdAndOrganizationId = async (roleName) => {
8406
- const roles = await this.roleApis
8407
- .fetch("organization_roles")
8408
- .then(response => response?.json());
8409
- const { id: roleId, organization_id: organizationId } = findBy({ name: roleName }, roles.organization_roles);
8410
- return { roleId, organizationId };
8411
- };
8412
- addCustomRoleViaRequest = async (roleName, targetPermissions, isGranularPermission = false) => {
8413
- const permissionIds = await this.getPermissionIds(targetPermissions, isGranularPermission);
8414
- return this.roleApis.addRole(roleName, permissionIds);
8415
- };
8416
- editRoleViaRequest = async (roleName, targetPermissions, isGranularPermission = false) => {
8417
- const [permissionIds, { roleId, organizationId }] = await Promise.all([
8418
- this.getPermissionIds(targetPermissions, isGranularPermission),
8419
- this.getRoleIdAndOrganizationId(roleName),
8420
- ]);
8421
- return this.roleApis.editRole(roleId, {
8422
- id: roleId,
8423
- kind: "custom",
8424
- name: roleName,
8425
- organization_id: organizationId,
8426
- permission_ids: permissionIds,
8427
- });
8428
- };
8429
- deleteRoleViaRequest = async (roleName, secondaryRoleName = "Editor") => {
8430
- const [{ roleId }, { roleId: secondaryRoleId }] = await Promise.all([roleName, secondaryRoleName].map(this.getRoleIdAndOrganizationId));
8431
- return this.roleApis.deleteRole(roleId, secondaryRoleId);
8432
- };
8433
- addRoleViaUI = async ({ roleName, permissions, parentPermission = "", hierarchyLevelOfPermissions = 2, }) => {
8434
- await this.page.getByTestId(ROLES_SELECTORS.newButton).click();
8435
- await this.page.getByTestId(ROLES_SELECTORS.nameTextField).fill(roleName);
8436
- await this.selectAndSubmitPermissions(permissions, parentPermission, hierarchyLevelOfPermissions);
8437
- };
8438
- editRoleViaUI = async ({ roleName, permissions, parentPermission = "", hierarchyLevelOfPermissions = 2, }) => {
8439
- await this.page
8440
- .getByTestId(ROLES_SELECTORS.tableHeaderRoleName)
8441
- .filter({ hasText: roleName })
8442
- .getByTestId(ROLES_SELECTORS.dropDownIcon)
8443
- .click();
8444
- await this.page.getByTestId(ROLES_SELECTORS.editRoleButton).click();
8445
- await expect(this.page.getByTestId(ROLES_SELECTORS.updateRolePaneHeading)).toBeVisible();
8446
- await this.selectAndSubmitPermissions(permissions, parentPermission, hierarchyLevelOfPermissions);
8447
- };
8448
- selectAndSubmitPermissions = async (permissions, parentPermission = "", hierarchyLevelOfPermissions = 2) => {
8449
- const parentPermissionSelector = parentPermission
8450
- ? this.page
8451
- .getByTestId(ROLES_SELECTORS.permissionSubCategoryCard(hierarchyLevelOfPermissions - 1))
8452
- .filter({ hasText: parentPermission })
8453
- : this.page;
8454
- parentPermission &&
8455
- (await parentPermissionSelector
8456
- .getByTestId(COMMON_SELECTORS.customCheckboxLabel(parentPermission))
8457
- .click({ force: true }));
8458
- for (const permission of permissions) {
8459
- await parentPermissionSelector
8460
- .getByTestId(COMMON_SELECTORS.customCheckboxLabel(permission))
8461
- .click({ force: true }); // Used force: true because disabling the parent permission disables the child permissions means the checkboxes label become disable
8462
- }
8463
- await Promise.all([
8464
- this.page.getByTestId(ROLES_SELECTORS.proceedButton).click(),
8465
- this.neetoPlaywrightUtilities.verifyToast(),
8466
- ]);
8467
- };
8468
- deleteRoleViaUI = async (roleName) => {
8469
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8470
- await this.page
8471
- .getByTestId(ROLES_SELECTORS.tableHeaderRoleName)
8472
- .filter({ hasText: roleName })
8473
- .getByTestId(ROLES_SELECTORS.dropDownIcon)
8474
- .click();
8475
- await this.page.getByTestId(ROLES_SELECTORS.deleteRoleButton).click();
8476
- await expect(this.page.getByTestId(COMMON_SELECTORS.alertTitle)).toHaveText(this.t("neetoTeamMembers.labels.deleteRole"));
8477
- await this.neetoPlaywrightUtilities.clickButtonAndAwaitLoad({
8478
- locator: this.page.getByTestId(COMMON_SELECTORS.alertModalSubmitButton),
8479
- });
8480
- await this.neetoPlaywrightUtilities.verifyToast();
8481
- await expect(this.page
8482
- .getByTestId(ROLES_SELECTORS.tableHeaderRoleTitle)
8483
- .filter({ hasText: roleName })).toBeHidden();
8484
- };
8485
- verifyPermissions = ({ allPermissions, rolePermissions, }) => Promise.all(Object.values(allPermissions).map(async (permission) => rolePermissions.includes(permission)
8486
- ? await expect(this.page.getByTestId(permission)).toBeVisible()
8487
- : await expect(this.page.getByTestId(permission)).toBeHidden()));
8488
- verifyRoleSpecificLinkAccess = async ({ roleAccessableLinks = [], adminAccessableLinks = [], }) => {
8489
- if (isNotEqualDeep(roleAccessableLinks, adminAccessableLinks)) {
8490
- for (const link of adminAccessableLinks) {
8491
- await this.page.goto(link);
8492
- await this.neetoPlaywrightUtilities.waitForFloatingMenu();
8493
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8494
- await expect(this.page.getByRole("heading", {
8495
- name: this.t("neetoMolecules.errorPage.unauthorized"),
8496
- }))[roleAccessableLinks.includes(link) ? "toBeHidden" : "toBeVisible"]();
8497
- }
8498
- }
8499
- };
8500
- }
8501
- class RolesPageV2 extends RolesPage {
8502
- selectAndSubmitPermissions = async (permissions, parentPermission = "", hierarchyLevelOfPermissions = 2) => {
8503
- const parentPermissionSelector = parentPermission
8504
- ? this.page
8505
- .getByTestId(ROLES_SELECTORS.permissionSubCategoryCard(hierarchyLevelOfPermissions - 1))
8506
- .filter({ hasText: parentPermission })
8507
- : this.page;
8508
- parentPermission &&
8509
- (await parentPermissionSelector
8510
- .getByLabel(parentPermission, { exact: true })
8511
- .click());
8512
- for (const permission of permissions) {
8513
- await parentPermissionSelector
8514
- .getByLabel(permission, { exact: true })
8515
- .click();
8516
- }
8517
- await Promise.all([
8518
- this.page.getByTestId(ROLES_SELECTORS.proceedButton).click(),
8519
- this.neetoPlaywrightUtilities.verifyToast(),
8520
- ]);
8521
- };
8522
- }
8523
-
8524
6718
  class SidebarSection {
8525
6719
  page;
8526
6720
  neetoPlaywrightUtilities;
@@ -8534,123 +6728,6 @@ class SidebarSection {
8534
6728
  clickOnGoBackButton = (label) => this.page.getByTestId(COMMON_SELECTORS.sidebarGoBackButton(label)).click();
8535
6729
  }
8536
6730
 
8537
- class TagsPage {
8538
- page;
8539
- neetoPlaywrightUtilities;
8540
- t;
8541
- tagsApi;
8542
- constructor(page, neetoPlaywrightUtilities) {
8543
- this.page = page;
8544
- this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
8545
- this.t = getI18nInstance().t;
8546
- this.tagsApi = new TagsApi(neetoPlaywrightUtilities);
8547
- }
8548
- searchAndVerifyTags = async (tagName) => {
8549
- await this.page.getByTestId(TAGS_SELECTORS.searchTextField).fill(tagName);
8550
- await expect(this.page.getByRole("row", { name: tagName })).toBeVisible();
8551
- };
8552
- addTagViaUI = async ({ tagName, addTagsLabel, }) => {
8553
- await this.page
8554
- .getByTestId(COMMON_SELECTORS.header)
8555
- .getByTestId(TAGS_SELECTORS.newTagButton)
8556
- .click();
8557
- await expect(this.page.getByTestId(COMMON_SELECTORS.sheetHeader)).toHaveText(addTagsLabel);
8558
- await this.page.getByTestId(TAGS_SELECTORS.tagNameTextField).fill(tagName);
8559
- await this.page
8560
- .getByTestId(TAGS_SELECTORS.descriptionTextArea)
8561
- .fill(faker.lorem.word(7));
8562
- await this.page.getByTestId(TAGS_SELECTORS.submitButton).click();
8563
- await this.neetoPlaywrightUtilities.verifyToast();
8564
- await this.neetoPlaywrightUtilities.waitForSheetClose();
8565
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8566
- };
8567
- filterTagsViaUI = async (tagName) => {
8568
- const nameBlock = this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFilterNameBlock);
8569
- const rows = this.page.getByRole("row");
8570
- const tagRow = this.page.getByRole("row", { name: tagName });
8571
- await filterUtils.openFilterPaneV2(this.page);
8572
- await this.page
8573
- .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersNameFilterField)
8574
- .fill(tagName);
8575
- await this.page.waitForURL(new RegExp(tagName));
8576
- await this.page
8577
- .getByTestId(NEETO_FILTERS_SELECTORS.filterDoneButton)
8578
- .click();
8579
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8580
- await Promise.all([
8581
- expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.filterPaneHeading)).toBeHidden(),
8582
- expect(this.page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeVisible(),
8583
- expect(nameBlock).toContainText(tagName),
8584
- expect(tagRow).toBeVisible(),
8585
- expect(rows).toHaveCount(2),
8586
- ]);
8587
- await filterUtils.clearFiltersFromActionBlock(this.page);
8588
- await Promise.all([
8589
- expect(nameBlock).toBeHidden(),
8590
- expect(tagRow).toBeVisible(),
8591
- expect(rows).not.toHaveCount(2),
8592
- ]);
8593
- };
8594
- editTagViaUI = async ({ tagName, newTagName, }) => {
8595
- await this.page
8596
- .getByRole("row", { name: tagName })
8597
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
8598
- .click();
8599
- await this.page.getByTestId(TAGS_SELECTORS.editButton).click();
8600
- await this.page
8601
- .getByTestId(TAGS_SELECTORS.tagNameTextField)
8602
- .fill(newTagName);
8603
- await this.page.getByTestId(TAGS_SELECTORS.submitButton).click();
8604
- await this.neetoPlaywrightUtilities.verifyToast();
8605
- await expect(this.page.getByRole("row", { name: tagName })).toBeHidden();
8606
- await expect(this.page.getByRole("row", { name: newTagName })).toBeVisible();
8607
- };
8608
- deleteTagViaUI = async (tagName) => {
8609
- await this.page
8610
- .getByRole("row", { name: tagName })
8611
- .getByTestId(COMMON_SELECTORS.dropdownIcon)
8612
- .click();
8613
- await this.page.getByTestId(TAGS_SELECTORS.deleteButton).click();
8614
- await this.page
8615
- .getByTestId(COMMON_SELECTORS.alertModalSubmitButton)
8616
- .click();
8617
- await this.neetoPlaywrightUtilities.verifyToast();
8618
- await expect(this.page.getByRole("row", { name: tagName })).toBeHidden();
8619
- };
8620
- addTagsViaRequest = ({ name, description = "", tagsRequestUrl, }) => this.tagsApi.create({ body: { name, description }, tagsRequestUrl });
8621
- navigateToMergeTagsPage = async () => {
8622
- await this.page.getByTestId(MERGE_TAGS_SELECTORS.mergeTagsButton).click();
8623
- await this.neetoPlaywrightUtilities.waitForPageLoad();
8624
- await expect(this.page.getByTestId(COMMON_SELECTORS.heading)).toHaveText(this.t("neetoTags.common.mergeTag_other"));
8625
- };
8626
- searchAndSelect = async ({ selector, tagName, rowSelector, }) => {
8627
- await this.page.getByTestId(selector).fill(tagName);
8628
- await this.page
8629
- .getByTestId(rowSelector)
8630
- .filter({ hasText: tagName })
8631
- .click();
8632
- };
8633
- mergeAndVerifyTagsViaUI = async ({ sourceTagName, destinationTagName, tagsBreadcrumbSelector, }) => {
8634
- await this.searchAndSelect({
8635
- selector: MERGE_TAGS_SELECTORS.sourceSearchTextField,
8636
- tagName: sourceTagName,
8637
- rowSelector: MERGE_TAGS_SELECTORS.sourceTagRow,
8638
- });
8639
- await this.searchAndSelect({
8640
- selector: MERGE_TAGS_SELECTORS.destinationSearchTextField,
8641
- tagName: destinationTagName,
8642
- rowSelector: MERGE_TAGS_SELECTORS.destinationTagRow,
8643
- });
8644
- await this.page.getByTestId(MERGE_TAGS_SELECTORS.mergeButton).click();
8645
- await expect(this.page.getByTestId(COMMON_SELECTORS.dialogHeader)).toHaveText(this.t("neetoTags.common.mergeTag_other"));
8646
- await this.page.getByTestId(MERGE_TAGS_SELECTORS.proceedButton).click();
8647
- await this.neetoPlaywrightUtilities.verifyToast();
8648
- await this.page.getByTestId(tagsBreadcrumbSelector).click();
8649
- await expect(this.page.getByText(sourceTagName)).toBeHidden();
8650
- await expect(this.page.getByText(destinationTagName)).toBeVisible();
8651
- };
8652
- }
8653
-
8654
6731
  const USER_AGENTS = {
8655
6732
  windows: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36",
8656
6733
  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",
@@ -8708,10 +6785,6 @@ const FILE_FORMATS = {
8708
6785
  gif: "gif",
8709
6786
  };
8710
6787
 
8711
- const TEAM_MEMBER_TEXTS = {
8712
- emailSubject: "Your team members export is here",
8713
- };
8714
-
8715
6788
  const KEYBOARD_SHORTCUT_TEST_CASES = [
8716
6789
  { os: "windows", agent: USER_AGENTS.windows },
8717
6790
  { os: "mac", agent: USER_AGENTS.mac },
@@ -9077,128 +7150,83 @@ const toggleColumnCheckboxAndVerifyVisibility = async ({ page, tableColumns, sho
9077
7150
  });
9078
7151
  }
9079
7152
  };
7153
+ // The checkbox column and some product columns render no column menu, so only
7154
+ // the columns between the first and last menu are frozen and unfrozen.
9080
7155
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
9081
7156
  const verifyFreezeColumnAction = async (page, _t) => {
9082
7157
  const columnHeader = page.getByRole("columnheader");
9083
- const [columnHeaders, originalColumnNames, checkboxVisible] = await Promise.all([
7158
+ const columnsDropdown = page.getByTestId(COMMON_SELECTORS.columnsDropdownContainer);
7159
+ (await columnsDropdown.isVisible()) && (await page.keyboard.press("Escape"));
7160
+ await expect(columnsDropdown).toBeHidden();
7161
+ // A column menu only appears once the real header row has rendered, so wait
7162
+ // for one before reading the headers.
7163
+ await expect(
7164
+ // eslint-disable-next-line playwright/no-nth-methods
7165
+ columnHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).first()).toBeAttached();
7166
+ const [columnHeaders, originalColumnNames] = await Promise.all([
9084
7167
  columnHeader.all(),
9085
7168
  columnHeader.allTextContents(),
9086
- columnHeader.getByRole("checkbox").isVisible(),
9087
7169
  ]);
9088
- const columnOffset = checkboxVisible ? 1 : 0;
9089
- const moreThanFiveColumns = columnHeaders.length > 5;
9090
- moreThanFiveColumns &&
9091
- (await page.evaluate(() => {
9092
- document.body.style.zoom = "0.25";
9093
- }));
9094
- await unFreezeAllColumns({ columnHeaders, columnOffset, page });
9095
- await toggleColumnState({ columnHeaders, columnOffset, page });
9096
- await validateColumnNames(columnHeaders, columnOffset, originalColumnNames);
9097
- await toggleColumnState({
7170
+ const hasMenu = await Promise.all(columnHeaders.map(async (header) => (await header.getByTestId(TABLE_SELECTORS.columnMenuButton).count()) > 0));
7171
+ const range = {
9098
7172
  columnHeaders,
9099
- columnOffset,
9100
- action: "Unfreeze",
7173
+ firstIndex: hasMenu.indexOf(true),
7174
+ lastIndex: hasMenu.lastIndexOf(true),
9101
7175
  page,
9102
- });
9103
- await expect(columnHeader).toHaveText(originalColumnNames);
9104
- moreThanFiveColumns &&
9105
- (await page.evaluate(() => {
9106
- document.body.style.zoom = "1";
9107
- }));
9108
- };
9109
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
9110
- const verifyFreezeColumnActionV2 = async (page, _t) => {
9111
- const columnHeader = page.getByRole("columnheader");
9112
- const [columnHeaders, originalColumnNames, checkboxVisible] = await Promise.all([
9113
- columnHeader.all(),
9114
- columnHeader.allTextContents(),
9115
- columnHeader.getByRole("checkbox").isVisible(),
9116
- ]);
9117
- const columnOffset = checkboxVisible ? 1 : 0;
7176
+ };
7177
+ expect(range.firstIndex, "No column renders a column menu, so this table offers no column freeze").toBeGreaterThan(-1);
9118
7178
  const moreThanFiveColumns = columnHeaders.length > 5;
9119
7179
  moreThanFiveColumns &&
9120
7180
  (await page.evaluate(() => {
9121
7181
  document.body.style.zoom = "0.25";
9122
7182
  }));
9123
- await unFreezeAllColumnsV2({ columnHeaders, columnOffset, page });
9124
- await toggleColumnStateV2({ columnHeaders, columnOffset, page });
9125
- await validateColumnNamesV2(columnHeaders, columnOffset, originalColumnNames);
9126
- await toggleColumnStateV2({
9127
- columnHeaders,
9128
- columnOffset,
9129
- action: "Unfreeze",
9130
- page,
9131
- });
7183
+ await unFreezeAllColumns(range);
7184
+ await toggleColumnState(range);
7185
+ await validateColumnNames(range, originalColumnNames);
7186
+ await toggleColumnState({ ...range, action: "Unfreeze" });
9132
7187
  await expect(columnHeader).toHaveText(originalColumnNames);
9133
7188
  moreThanFiveColumns &&
9134
7189
  (await page.evaluate(() => {
9135
7190
  document.body.style.zoom = "1";
9136
7191
  }));
9137
7192
  };
9138
- const unFreezeAllColumns = async ({ columnHeaders, columnOffset, page, }) => {
9139
- const unFreezeColumnButton = freezeUnfreezeMenuItem(page, TABLE_COLUMN_TEXTS.unfreezeColumn);
9140
- for (let i = columnHeaders.length - 1; i >= columnOffset; i--) {
9141
- const currentHeader = columnHeaders[i];
9142
- await currentHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
9143
- await expect(page.getByTestId(COMMON_SELECTORS.dropdownContainer)).toBeVisible();
9144
- (await unFreezeColumnButton.isVisible())
9145
- ? await unFreezeColumnButton.click()
9146
- : await currentHeader
9147
- .getByTestId(TABLE_SELECTORS.columnMenuButton)
9148
- .click();
9149
- }
7193
+ const openColumnMenu = async (page, columnHeader) => {
7194
+ const menu = page.getByRole("menu");
7195
+ (await page.getByTestId(COMMON_SELECTORS.tooltip).isVisible()) &&
7196
+ (await page.mouse.move(0, 0));
7197
+ // Let the previous menu finish its close animation, or two menus match below.
7198
+ await expect(menu).toHaveCount(0);
7199
+ await columnHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
7200
+ await expect(menu).toBeVisible();
9150
7201
  };
9151
- const unFreezeAllColumnsV2 = async ({ columnHeaders, columnOffset, page, }) => {
7202
+ const unFreezeAllColumns = async ({ columnHeaders, firstIndex, lastIndex, page, }) => {
9152
7203
  const unFreezeColumnButton = freezeUnfreezeMenuItem(page, TABLE_COLUMN_TEXTS.unfreezeColumn);
9153
- for (let i = columnHeaders.length - 1; i >= columnOffset; i--) {
9154
- const currentHeader = columnHeaders[i];
9155
- await currentHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
9156
- await expect(page.getByRole("menu")).toBeVisible();
7204
+ // Escape closes the Radix menu visually but can leave `body` with
7205
+ // `pointer-events: none`, blocking the next column; closing it through its
7206
+ // trigger lets Radix clean up.
7207
+ const openColumnMenuButton = page
7208
+ .getByTestId(TABLE_SELECTORS.columnMenuButton)
7209
+ .and(page.locator('[aria-expanded="true"]'));
7210
+ for (let i = lastIndex; i >= firstIndex; i--) {
7211
+ await openColumnMenu(page, columnHeaders[i]);
9157
7212
  (await unFreezeColumnButton.isVisible())
9158
7213
  ? await unFreezeColumnButton.click()
9159
- : await page.keyboard.press("Escape");
9160
- }
9161
- };
9162
- const toggleColumnState = async ({ columnHeaders, columnOffset, action = "Freeze", page, }) => {
9163
- const firstColumnIndex = columnOffset;
9164
- const lastColumnIndex = columnHeaders.length - 1;
9165
- const targetIndex = action === "Freeze" ? lastColumnIndex : firstColumnIndex;
9166
- const toggleButton = freezeUnfreezeMenuItem(page, action === "Freeze"
9167
- ? TABLE_COLUMN_TEXTS.freezeColumn
9168
- : TABLE_COLUMN_TEXTS.unfreezeColumn);
9169
- for (let i = firstColumnIndex; i < lastColumnIndex; i++) {
9170
- const columnHeader = columnHeaders[targetIndex];
9171
- (await page.getByTestId(COMMON_SELECTORS.tooltip).isVisible()) &&
9172
- (await page.mouse.move(0, 0));
9173
- await columnHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
9174
- await toggleButton.click();
7214
+ : await openColumnMenuButton.click({ force: true });
9175
7215
  }
9176
7216
  };
9177
- const toggleColumnStateV2 = async ({ columnHeaders, columnOffset, action = "Freeze", page, }) => {
9178
- const firstColumnIndex = columnOffset;
9179
- const lastColumnIndex = columnHeaders.length - 1;
9180
- const targetIndex = action === "Freeze" ? lastColumnIndex : firstColumnIndex;
7217
+ const toggleColumnState = async ({ columnHeaders, firstIndex, lastIndex, action = "Freeze", page, }) => {
7218
+ const targetIndex = action === "Freeze" ? lastIndex : firstIndex;
9181
7219
  const toggleButton = freezeUnfreezeMenuItem(page, action === "Freeze"
9182
7220
  ? TABLE_COLUMN_TEXTS.freezeColumn
9183
7221
  : TABLE_COLUMN_TEXTS.unfreezeColumn);
9184
- for (let i = firstColumnIndex; i < lastColumnIndex; i++) {
9185
- const columnHeader = columnHeaders[targetIndex];
9186
- (await page.getByTestId(COMMON_SELECTORS.tooltip).isVisible()) &&
9187
- (await page.mouse.move(0, 0));
9188
- await columnHeader.getByTestId(TABLE_SELECTORS.columnMenuButton).click();
7222
+ for (let i = firstIndex; i < lastIndex; i++) {
7223
+ await openColumnMenu(page, columnHeaders[targetIndex]);
9189
7224
  await toggleButton.click();
9190
7225
  }
9191
7226
  };
9192
- const validateColumnNames = async (columnHeaders, columnOffset, originalColumnNames) => {
9193
- for (let i = columnOffset; i < originalColumnNames.length - 1; i++) {
9194
- const expectedName = originalColumnNames[i + 1];
9195
- await expect(columnHeaders[i]).toHaveText(expectedName);
9196
- }
9197
- };
9198
- const validateColumnNamesV2 = async (columnHeaders, columnOffset, originalColumnNames) => {
9199
- const lastColumnIndex = columnHeaders.length - 1;
9200
- for (let i = columnOffset; i < lastColumnIndex; i++) {
9201
- await expect(columnHeaders[i]).toHaveText(originalColumnNames[columnOffset + lastColumnIndex - i]);
7227
+ const validateColumnNames = async ({ columnHeaders, firstIndex, lastIndex }, originalColumnNames) => {
7228
+ for (let i = firstIndex; i < lastIndex; i++) {
7229
+ await expect(columnHeaders[i]).toHaveText(originalColumnNames[firstIndex + lastIndex - i]);
9202
7230
  }
9203
7231
  };
9204
7232
  const verifyReorderColumns = async (page) => {
@@ -9241,7 +7269,6 @@ const tableUtils = {
9241
7269
  assertColumnHeaderVisibility,
9242
7270
  toggleColumnCheckboxAndVerifyVisibility,
9243
7271
  verifyFreezeColumnAction,
9244
- verifyFreezeColumnActionV2,
9245
7272
  verifyReorderColumns,
9246
7273
  };
9247
7274
 
@@ -9276,6 +7303,34 @@ const executeWithThrottledResources = async ({ code: emulatedCode, kind = "both"
9276
7303
  await cpuThrottlingUsingCDP({ cdpSession, rate: 1 });
9277
7304
  };
9278
7305
 
7306
+ const openFilterPane = async (page) => {
7307
+ await page
7308
+ .getByTestId(NEETO_FILTERS_SELECTORS.filterButton)
7309
+ .or(page.getByTestId(COMMON_SELECTORS.filterButon))
7310
+ .click();
7311
+ await expect(page.getByTestId(NEETO_FILTERS_SELECTORS.filterPaneHeading)).toHaveText(getI18nInstance().t("neetoFilters.common.filters"));
7312
+ };
7313
+ const clearFiltersFromActionBlock = async (page) => {
7314
+ const isClearButtonVisible = await page
7315
+ .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)
7316
+ .isVisible();
7317
+ if (isClearButtonVisible) {
7318
+ await page
7319
+ .getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)
7320
+ .click();
7321
+ await Promise.all([
7322
+ expect(page.getByTestId(NEETO_FILTERS_SELECTORS.neetoFiltersBarClearButton)).toBeHidden(),
7323
+ expect(page.locator(COMMON_SELECTORS.tableSpinner)).toHaveCount(0, {
7324
+ timeout: 15_000,
7325
+ }),
7326
+ ]);
7327
+ }
7328
+ };
7329
+ const filterUtils = {
7330
+ openFilterPane,
7331
+ clearFiltersFromActionBlock,
7332
+ };
7333
+
9279
7334
  const getAmountWithSymbol = (amount, options) => {
9280
7335
  const formatter = new Intl.NumberFormat(dayjs.locale(), {
9281
7336
  ...options,
@@ -12269,11 +10324,9 @@ const DEFAULT_WARMUP_URLS = ["/login"];
12269
10324
  async function warmup({ urls = DEFAULT_WARMUP_URLS, timeout = 60_000, } = {}) {
12270
10325
  if (!IS_DEV_ENV)
12271
10326
  return;
12272
- const { RAILS_SERVER_PORT, SUBDOMAIN = "spinkart" } = process.env;
12273
- if (!RAILS_SERVER_PORT) {
12274
- throw new Error("RAILS_SERVER_PORT is not defined in environment variables.");
12275
- }
12276
- const baseURL = `http://${SUBDOMAIN}.lvh.me:${RAILS_SERVER_PORT}`;
10327
+ const railsServerPort = requireEnv("RAILS_SERVER_PORT");
10328
+ const subdomain = process.env.SUBDOMAIN ?? "spinkart";
10329
+ const baseURL = `http://${subdomain}.lvh.me:${railsServerPort}`;
12277
10330
  const browser = await chromium.launch();
12278
10331
  const page = await browser.newPage();
12279
10332
  try {
@@ -12288,6 +10341,22 @@ async function warmup({ urls = DEFAULT_WARMUP_URLS, timeout = 60_000, } = {}) {
12288
10341
  }
12289
10342
  }
12290
10343
 
10344
+ /** Check for an HTTP response without following redirects or downloading its body. */
10345
+ const httpCheck = async (url, timeout = 3000) => {
10346
+ try {
10347
+ const response = await fetch(url, {
10348
+ redirect: "manual",
10349
+ signal: AbortSignal.timeout(timeout),
10350
+ });
10351
+ // Any status means the server is listening, including redirects and errors.
10352
+ await response.body?.cancel();
10353
+ return true;
10354
+ }
10355
+ catch {
10356
+ return false;
10357
+ }
10358
+ };
10359
+
12291
10360
  const DIR = "/tmp/neeto-auth-web";
12292
10361
  const CONFIG$1 = {
12293
10362
  DIR,
@@ -12320,14 +10389,7 @@ const buildEmailCaptureInitializer = (targetApp) => {
12320
10389
  return template.replace("{{TARGET_APP}}", escapeRubyString(targetApp));
12321
10390
  };
12322
10391
  const log$1 = (msg) => console.log(`[NeetoAuth] ${msg}`);
12323
- const httpCheck$1 = (port, timeout = 3000) => new Promise(resolve => {
12324
- const req = http.get(`http://localhost:${port}/`, () => resolve(true));
12325
- req.on("error", () => resolve(false));
12326
- req.setTimeout(timeout, () => {
12327
- req.destroy();
12328
- resolve(false);
12329
- });
12330
- });
10392
+ const isServerListening$1 = () => httpCheck(`http://localhost:${CONFIG$1.PORT}/`);
12331
10393
  const pollUntil = async (check, timeoutMs, intervalMs) => {
12332
10394
  const deadline = Date.now() + timeoutMs;
12333
10395
  while (Date.now() < deadline) {
@@ -12494,7 +10556,7 @@ class NeetoAuthServer {
12494
10556
  if (this.process !== null && this.process.exitCode !== null) {
12495
10557
  throw new Error(`[NeetoAuth] Server process exited unexpectedly with code ${this.process.exitCode}.\nLog:\n${readServerLog()}`);
12496
10558
  }
12497
- return httpCheck$1(CONFIG$1.PORT);
10559
+ return isServerListening$1();
12498
10560
  }, timeoutMs, CONFIG$1.WAIT_FOR_SERVER_POLL_MS);
12499
10561
  if (started)
12500
10562
  return;
@@ -12534,7 +10596,7 @@ class NeetoAuthServer {
12534
10596
  const currentContent = fs.readFileSync(CONFIG$1.EMAIL_INIT, "utf-8");
12535
10597
  return currentContent === buildEmailCaptureInitializer(this.targetApp);
12536
10598
  };
12537
- isServingCurrentApp = async () => (await httpCheck$1(CONFIG$1.PORT)) && this.isRunningForCurrentApp();
10599
+ isServingCurrentApp = async () => (await isServerListening$1()) && this.isRunningForCurrentApp();
12538
10600
  start = async () => {
12539
10601
  if (IS_STAGING_ENV)
12540
10602
  return;
@@ -12555,7 +10617,7 @@ class NeetoAuthServer {
12555
10617
  log$1("Server already running for this app.");
12556
10618
  return;
12557
10619
  }
12558
- if (await httpCheck$1(CONFIG$1.PORT)) {
10620
+ if (await isServerListening$1()) {
12559
10621
  log$1("Server running for a different app — restarting...");
12560
10622
  await this.killServerOnPort();
12561
10623
  }
@@ -12607,14 +10669,7 @@ const DEFAULT_STATE = { pid: null, refCount: 0 };
12607
10669
  const WIDGET_BASE_URL = `http://localhost:${CONFIG.PORT}`;
12608
10670
  const SCRIPTS_DIR = path.join(import.meta.dirname, "scripts", "neeto-chat-widget");
12609
10671
  const log = (msg) => console.log(`[NeetoChatWidget] ${msg}`);
12610
- const httpCheck = (timeout = 3000) => new Promise(resolve => {
12611
- const req = http.get(`${WIDGET_BASE_URL}/main.js`, () => resolve(true));
12612
- req.on("error", () => resolve(false));
12613
- req.setTimeout(timeout, () => {
12614
- req.destroy();
12615
- resolve(false);
12616
- });
12617
- });
10672
+ const isServerListening = () => httpCheck(`${WIDGET_BASE_URL}/main.js`);
12618
10673
  class NeetoChatWidget {
12619
10674
  process = null;
12620
10675
  hasLease = false;
@@ -12754,7 +10809,7 @@ class NeetoChatWidget {
12754
10809
  if (this.process !== null && this.process.exitCode !== null) {
12755
10810
  throw new Error(`[NeetoChatWidget] Server process exited unexpectedly with code ${this.process.exitCode}.\nLog:\n${this.getLogContent()}`);
12756
10811
  }
12757
- if (await httpCheck())
10812
+ if (await isServerListening())
12758
10813
  return;
12759
10814
  await setTimeout$1(CONFIG.SERVER_POLL_INTERVAL_MS);
12760
10815
  }
@@ -12765,7 +10820,7 @@ class NeetoChatWidget {
12765
10820
  return;
12766
10821
  await this.withLock(async () => {
12767
10822
  const state = this.readState();
12768
- if (await httpCheck()) {
10823
+ if (await isServerListening()) {
12769
10824
  this.hasLease = true;
12770
10825
  this.writeState({ ...state, refCount: state.refCount + 1 });
12771
10826
  log("Server already running.");
@@ -12787,7 +10842,7 @@ class NeetoChatWidget {
12787
10842
  const pid = this.process?.pid;
12788
10843
  this.killServer(pid);
12789
10844
  pid && (await this.waitForProcessExit(pid));
12790
- (await httpCheck()) && (await this.killProcessOnWidgetPort());
10845
+ (await isServerListening()) && (await this.killProcessOnWidgetPort());
12791
10846
  this.process = null;
12792
10847
  this.closeLogStream();
12793
10848
  throw error;
@@ -12815,7 +10870,7 @@ class NeetoChatWidget {
12815
10870
  log("Stopping server...");
12816
10871
  this.killServer(state.pid);
12817
10872
  await this.waitForProcessExit(state.pid);
12818
- (await httpCheck()) && (await this.killProcessOnWidgetPort());
10873
+ (await isServerListening()) && (await this.killProcessOnWidgetPort());
12819
10874
  }
12820
10875
  this.process = null;
12821
10876
  this.closeLogStream();
@@ -12859,11 +10914,7 @@ class EmailDeliveryUtils {
12859
10914
  }
12860
10915
  connectViaRequest = async ({ provider, ownerId }) => {
12861
10916
  if (provider === "sparkpost") {
12862
- const sparkpostEmailEnvKey = FROM_EMAIL_ENV_KEYS.sparkpost;
12863
- const email = process.env[sparkpostEmailEnvKey];
12864
- if (isNil(email)) {
12865
- throw new Error(`ENV variable ${sparkpostEmailEnvKey} is not properly configured`);
12866
- }
10917
+ const email = requireEnv(FROM_EMAIL_ENV_KEYS.sparkpost);
12867
10918
  const response = await this.emailDeliveryApi.connect({
12868
10919
  emailProvider: "sparkpost",
12869
10920
  email,
@@ -12872,11 +10923,7 @@ class EmailDeliveryUtils {
12872
10923
  expect(response?.ok()).toBeTruthy();
12873
10924
  return response;
12874
10925
  }
12875
- const refreshTokenEnvKey = REFRESH_TOKEN_ENV_KEYS[provider];
12876
- const refreshToken = process.env[refreshTokenEnvKey];
12877
- if (isNil(refreshToken)) {
12878
- throw new Error(`ENV variable ${refreshTokenEnvKey} is not properly configured`);
12879
- }
10926
+ const refreshToken = requireEnv(REFRESH_TOKEN_ENV_KEYS[provider]);
12880
10927
  const response = await this.emailDeliveryApi.connect({
12881
10928
  emailProvider: provider,
12882
10929
  refreshToken,
@@ -12886,10 +10933,7 @@ class EmailDeliveryUtils {
12886
10933
  return response;
12887
10934
  };
12888
10935
  verifyEmailViaRequest = async ({ subject, to, partialBody, from }, { provider, ownerId, timeout = 30 * 1000, shouldThrowErrorOnTimeout = true, }) => {
12889
- const fromEmail = from ?? process.env[FROM_EMAIL_ENV_KEYS[provider]];
12890
- if (isNil(fromEmail)) {
12891
- throw new Error(`ENV variable ${FROM_EMAIL_ENV_KEYS[provider]} is not properly configured`);
12892
- }
10936
+ const fromEmail = from ?? requireEnv(FROM_EMAIL_ENV_KEYS[provider]);
12893
10937
  const verifyParams = {
12894
10938
  emailProvider: provider,
12895
10939
  subject,
@@ -13274,10 +11318,7 @@ class InboundEmailApis {
13274
11318
  : this.deliverViaMailgunIngress(source);
13275
11319
  };
13276
11320
  deliverViaMailgunIngress = (source) => {
13277
- const signingKey = process.env.MAILGUN_INGRESS_SIGNING_KEY;
13278
- if (!signingKey) {
13279
- throw new Error("MAILGUN_INGRESS_SIGNING_KEY is required to inject inbound emails outside development");
13280
- }
11321
+ const signingKey = requireEnv("MAILGUN_INGRESS_SIGNING_KEY");
13281
11322
  const timestamp = Math.floor(Date.now() / 1000).toString();
13282
11323
  const token = randomBytes(25).toString("hex");
13283
11324
  const signature = createHmac("sha256", signingKey)
@@ -13291,4 +11332,4 @@ class InboundEmailApis {
13291
11332
  };
13292
11333
  }
13293
11334
 
13294
- export { 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, serializeFileForBrowser, shouldSkipCustomDomainSetup, shouldSkipSetupAndTeardown, simulateClickWithDelay, simulateTypingWithDelay, skipTest, squish, stealth as stealthTest, tableUtils, toCamelCase, updateCredentials, waitForReviewApp, warmup, withCookieCache, writeDataToFile };
11335
+ 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 };