@bigbinary/neeto-playwright-commons 1.26.34 → 1.26.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -751,8 +751,10 @@ declare class ApiKeysApi {
751
751
  declare class CustomDomainApi {
752
752
  private neetoPlaywrightUtilities;
753
753
  constructor(neetoPlaywrightUtilities: CustomCommands);
754
+ create: (hostname: string, baseUrl?: string) => Promise<playwright_core.APIResponse | undefined>;
754
755
  delete: (customDomain: string) => Promise<playwright_core.APIResponse | undefined>;
755
- fetch: () => Promise<playwright_core.APIResponse | undefined>;
756
+ fetch: (baseUrl?: string) => Promise<playwright_core.APIResponse | undefined>;
757
+ validate: (baseUrl?: string) => Promise<playwright_core.APIResponse | undefined>;
756
758
  }
757
759
  interface AllowedIpRange {
758
760
  ipStart: string;
@@ -4773,7 +4775,7 @@ declare class CustomDomainPage {
4773
4775
  customDomainApi: CustomDomainApi;
4774
4776
  subdomain: string;
4775
4777
  loginPage: Page;
4776
- baseURL: string;
4778
+ customDomainURL: string;
4777
4779
  t: TFunction;
4778
4780
  constructor({
4779
4781
  browser,
@@ -4808,6 +4810,7 @@ declare class CustomDomainPage {
4808
4810
  * @endexample
4809
4811
  */
4810
4812
  validateCustomDomain: (domain: string) => Promise<void>;
4813
+ private getDomainStatus;
4811
4814
  private loginToCustomDomain;
4812
4815
  private waitForTrustedSSL;
4813
4816
  private saveCustomDomainState;
@@ -4824,7 +4827,17 @@ declare class CustomDomainPage {
4824
4827
  setupCustomDomain: () => Promise<void>;
4825
4828
  /**
4826
4829
  *
4827
- * Connects and validates a custom domain for the specified product.
4830
+ * Sets up a custom domain using the API instead of the UI.
4831
+ *
4832
+ * @example
4833
+ *
4834
+ * await customDomainPage.setupCustomDomainViaAPI();
4835
+ * @endexample
4836
+ */
4837
+ setupCustomDomainViaAPI: () => Promise<void>;
4838
+ /**
4839
+ *
4840
+ * Connects and validates a custom domain for the specified product via the UI.
4828
4841
  *
4829
4842
  * subdomain (optional): The subdomain to use for generating the custom domain.
4830
4843
  *
@@ -4834,6 +4847,20 @@ declare class CustomDomainPage {
4834
4847
  * @endexample
4835
4848
  */
4836
4849
  connectCustomDomain: (subdomain?: string) => Promise<void>;
4850
+ /**
4851
+ *
4852
+ * Connects and validates a custom domain using only API calls.
4853
+ *
4854
+ * subdomain (optional): The subdomain to use for generating the custom domain. If omitted, uses the subdomain from global user state.
4855
+ *
4856
+ * @example
4857
+ *
4858
+ * await customDomainPage.connectViaAPI("cpt-form-534343434");
4859
+ * @endexample
4860
+ */
4861
+ connectViaAPI: (subdomain?: string) => Promise<void>;
4862
+ private validateDomain;
4863
+ private awaitDomainValidation;
4837
4864
  private getCustomDomainFromAPI;
4838
4865
  /**
4839
4866
  *
@@ -6268,6 +6295,7 @@ declare const COMMON_SELECTORS: {
6268
6295
  columnsDropdownIcon: string;
6269
6296
  columnDragHandle: string;
6270
6297
  reactSelectContainer: string;
6298
+ calloutElement: string;
6271
6299
  };
6272
6300
  /**
6273
6301
  *
package/index.js CHANGED
@@ -131,15 +131,26 @@ class ApiKeysApi {
131
131
  }
132
132
  }
133
133
 
134
+ const CUSTOM_DOMAIN_BASE_URL = `${BASE_URL}/custom_domains`;
134
135
  class CustomDomainApi {
135
136
  constructor(neetoPlaywrightUtilities) {
136
137
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
138
+ this.create = (hostname, baseUrl = "") => this.neetoPlaywrightUtilities.apiRequest({
139
+ url: `${baseUrl}${CUSTOM_DOMAIN_BASE_URL}`,
140
+ method: "post",
141
+ body: { hostname },
142
+ });
137
143
  this.delete = (customDomain) => this.neetoPlaywrightUtilities.apiRequest({
138
- url: `${BASE_URL}/custom_domains/${customDomain}`,
144
+ url: `${CUSTOM_DOMAIN_BASE_URL}/${customDomain}`,
139
145
  method: "delete",
140
146
  });
141
- this.fetch = () => this.neetoPlaywrightUtilities.apiRequest({
142
- url: `${BASE_URL}/custom_domains`,
147
+ this.fetch = (baseUrl = "") => this.neetoPlaywrightUtilities.apiRequest({
148
+ url: `${baseUrl}${CUSTOM_DOMAIN_BASE_URL}`,
149
+ });
150
+ this.validate = (baseUrl = "") => this.neetoPlaywrightUtilities.apiRequest({
151
+ url: `${baseUrl}${CUSTOM_DOMAIN_BASE_URL}/validate_domain`,
152
+ failOnStatusCode: false,
153
+ method: "patch",
143
154
  });
144
155
  }
145
156
  }
@@ -4961,6 +4972,7 @@ const COMMON_SELECTORS = {
4961
4972
  columnsDropdownIcon: "columns-dropdown-icon",
4962
4973
  columnDragHandle: "column-drag-handle",
4963
4974
  reactSelectContainer: ".neeto-ui-react-select__container",
4975
+ calloutElement: "callout-element",
4964
4976
  };
4965
4977
 
4966
4978
  const THANK_YOU_SELECTORS = {
@@ -119313,13 +119325,13 @@ class AuditLogsPage {
119313
119325
  this.messageBuilders = {
119314
119326
  [ACTIONS.inviteUsers]: (data) => `${this.admin} added ${data.emails.join(", ").toLowerCase()} to Neeto${this.product}.`,
119315
119327
  [ACTIONS.updatedUser]: (data) => `${this.admin} changed ${data.emails[1].toLowerCase()}'s email from ${data.emails[0].toLowerCase()} to ${data.emails[1]} on Neeto${this.product}.`,
119316
- [ACTIONS.removedUser]: (data) => `${this.admin} changed ${data.emails[0].toLowerCase()}'s active from true to false on Neeto${this.product}.`,
119328
+ [ACTIONS.removedUser]: (data) => `${this.admin} removed ${data.emails[0].toLowerCase()} from Neeto${this.product}.`,
119317
119329
  [ACTIONS.createdRole]: (data) => `${this.admin} created ${data.roleName} role on Neeto${this.product}.`,
119318
119330
  [ACTIONS.addedPermission]: (data) => `${this.admin} added ${data.permissions.join(", ").toLowerCase()} permission to ${data.roleName} role on Neeto${this.product}.`,
119319
119331
  [ACTIONS.removedPermission]: (data) => `${this.admin} removed ${data.permissions.join(", ")} permissions from ${data.roleName} role on Neeto${this.product}.`,
119320
119332
  [ACTIONS.updatedRole]: (data) => `${this.admin} updated ${data.roleName} role on Neeto${this.product}.`,
119321
119333
  [ACTIONS.deletedRole]: (data) => `${this.admin} deleted ${data.roleName} role on Neeto${this.product}.`,
119322
- [ACTIONS.updatedName]: (data) => `${this.admin} updated their first name: from ${data.name} to ${this.admin.split(" ")[0]} on Neeto${this.product}.`,
119334
+ [ACTIONS.updatedName]: (data) => `${this.admin} changed first name from ${data.name} to ${this.admin.split(" ")[0]} in Neeto${this.product}.`,
119323
119335
  };
119324
119336
  }
119325
119337
  }
@@ -119351,12 +119363,13 @@ class CustomDomainPage {
119351
119363
  .getByRole("cell", { name: domain.split(".")[0] })).toBeVisible(),
119352
119364
  ]);
119353
119365
  await this.neetoPlaywrightUtilities.waitForPageLoad();
119366
+ await validateButton.click();
119367
+ await expect(this.page.getByTestId(COMMON_SELECTORS.calloutElement)).toBeVisible({ timeout: 15000 });
119354
119368
  let isCertificateLimitExceeded = false;
119355
119369
  await expect(async () => {
119356
119370
  isCertificateLimitExceeded = await this.isCertificateLimitExceeded();
119357
119371
  if (isCertificateLimitExceeded)
119358
119372
  return;
119359
- await validateButton.click();
119360
119373
  await this.neetoPlaywrightUtilities.verifyToast({
119361
119374
  message: this.t("neetoCustomDomains.validation.successMessage"),
119362
119375
  });
@@ -119366,13 +119379,21 @@ class CustomDomainPage {
119366
119379
  return;
119367
119380
  }
119368
119381
  await this.neetoPlaywrightUtilities.waitForPageLoad();
119369
- await expect(this.page.getByTestId(CUSTOM_DOMAIN_SELECTORS.activeTagContainer)).toBeVisible();
119382
+ await expect(validateButton).toBeHidden();
119383
+ };
119384
+ this.getDomainStatus = async (hostname, baseURL) => {
119385
+ var _a;
119386
+ const response = await this.customDomainApi
119387
+ .fetch(baseURL)
119388
+ .then(response => response === null || response === void 0 ? void 0 : response.json());
119389
+ const domain = (_a = response === null || response === void 0 ? void 0 : response.custom_domains) === null || _a === void 0 ? void 0 : _a.find((domain) => { var _a; return ((_a = domain.hostname) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === hostname.toLowerCase(); });
119390
+ return domain === null || domain === void 0 ? void 0 : domain.status;
119370
119391
  };
119371
119392
  this.loginToCustomDomain = async () => {
119372
119393
  await this.page.close();
119373
119394
  const loginPage = this.loginPage;
119374
119395
  const { email } = getGlobalUserState();
119375
- const loginUrl = `${this.baseURL}${ROUTES.admin}`;
119396
+ const loginUrl = `${this.customDomainURL}${ROUTES.admin}`;
119376
119397
  const playwrightUtils = new CustomCommands(loginPage, loginPage.request);
119377
119398
  const organizationPage = new OrganizationPage(loginPage, playwrightUtils);
119378
119399
  await loginPage.goto(loginUrl);
@@ -119384,7 +119405,7 @@ class CustomDomainPage {
119384
119405
  this.waitForTrustedSSL = () => expect
119385
119406
  .poll(() => new Promise(resolve => {
119386
119407
  https
119387
- .get(this.baseURL, { rejectUnauthorized: true }, res => {
119408
+ .get(this.customDomainURL, { rejectUnauthorized: true }, res => {
119388
119409
  res.resume();
119389
119410
  resolve(true);
119390
119411
  })
@@ -119398,7 +119419,7 @@ class CustomDomainPage {
119398
119419
  await this.loginPage.context().storageState({ path: STORAGE_STATE });
119399
119420
  const mergedCredentials = mergeAll([readFileSyncIfExists(), { user }]);
119400
119421
  writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
119401
- updateCredentials({ key: "baseUrl", value: this.baseURL });
119422
+ updateCredentials({ key: "baseUrl", value: this.customDomainURL });
119402
119423
  updateCredentials({ key: "domain", value: CUSTOM_DOMAIN_SUFFIX });
119403
119424
  };
119404
119425
  // eslint-disable-next-line playwright/no-wait-for-timeout
@@ -119412,21 +119433,57 @@ class CustomDomainPage {
119412
119433
  await this.loginToCustomDomain();
119413
119434
  await this.saveCustomDomainState();
119414
119435
  };
119436
+ this.setupCustomDomainViaAPI = async () => {
119437
+ if (shouldSkipCustomDomainSetup())
119438
+ return;
119439
+ await this.connectViaAPI();
119440
+ const context = await this.browser.newContext(EMPTY_STORAGE_STATE);
119441
+ this.loginPage = await context.newPage();
119442
+ await this.loginToCustomDomain();
119443
+ await this.saveCustomDomainState();
119444
+ };
119415
119445
  this.connectCustomDomain = async (subdomain) => {
119416
119446
  if (shouldSkipCustomDomainSetup())
119417
119447
  return;
119418
- const baseURL = baseURLGenerator(this.product, subdomain);
119419
119448
  const domain = this.getCustomDomain(subdomain);
119420
- this.baseURL = `https://${domain}`;
119449
+ const baseURL = baseURLGenerator(this.product, this.subdomain);
119450
+ this.customDomainURL = `https://${domain}`;
119421
119451
  await this.neetoPlaywrightUtilities.waitForPageLoad();
119422
119452
  await this.page.goto(`${baseURL}${ROUTES.adminPanel.customDomain}`);
119423
119453
  await this.neetoPlaywrightUtilities.waitForPageLoad();
119424
119454
  await this.addCustomDomain(domain);
119425
119455
  await this.validateCustomDomain(domain);
119426
- process.env.BASE_URL = this.baseURL;
119456
+ process.env.BASE_URL = this.customDomainURL;
119457
+ await this.waitForTrustedSSL();
119458
+ await this.waitForDomainPropagation();
119459
+ };
119460
+ this.connectViaAPI = async (subdomain) => {
119461
+ if (shouldSkipCustomDomainSetup())
119462
+ return;
119463
+ const domain = this.getCustomDomain(subdomain);
119464
+ this.customDomainURL = `https://${domain}`;
119465
+ const baseURL = baseURLGenerator(this.product, this.subdomain);
119466
+ await this.page.goto(`${baseURL}${ROUTES.adminPanel.customDomain}`);
119467
+ await this.page.waitForLoadState("domcontentloaded");
119468
+ await this.customDomainApi.create(domain, baseURL);
119469
+ await this.validateDomain(baseURL);
119470
+ await this.awaitDomainValidation(domain, baseURL);
119471
+ process.env.BASE_URL = this.customDomainURL;
119427
119472
  await this.waitForTrustedSSL();
119428
119473
  await this.waitForDomainPropagation();
119429
119474
  };
119475
+ this.validateDomain = (baseURL) => expect
119476
+ .poll(async () => { var _a; return (_a = (await this.customDomainApi.validate(baseURL))) === null || _a === void 0 ? void 0 : _a.status(); }, {
119477
+ timeout: 2 * 60000,
119478
+ intervals: [10000],
119479
+ })
119480
+ .toBe(200);
119481
+ this.awaitDomainValidation = (hostname, baseURL) => expect
119482
+ .poll(async () => this.getDomainStatus(hostname, baseURL), {
119483
+ timeout: 2 * 60000,
119484
+ intervals: [5000],
119485
+ })
119486
+ .toBe("active");
119430
119487
  this.getCustomDomainFromAPI = async () => {
119431
119488
  const { custom_domains } = await this.customDomainApi
119432
119489
  .fetch()