@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.cjs.js CHANGED
@@ -152,15 +152,26 @@ class ApiKeysApi {
152
152
  }
153
153
  }
154
154
 
155
+ const CUSTOM_DOMAIN_BASE_URL = `${BASE_URL}/custom_domains`;
155
156
  class CustomDomainApi {
156
157
  constructor(neetoPlaywrightUtilities) {
157
158
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
159
+ this.create = (hostname, baseUrl = "") => this.neetoPlaywrightUtilities.apiRequest({
160
+ url: `${baseUrl}${CUSTOM_DOMAIN_BASE_URL}`,
161
+ method: "post",
162
+ body: { hostname },
163
+ });
158
164
  this.delete = (customDomain) => this.neetoPlaywrightUtilities.apiRequest({
159
- url: `${BASE_URL}/custom_domains/${customDomain}`,
165
+ url: `${CUSTOM_DOMAIN_BASE_URL}/${customDomain}`,
160
166
  method: "delete",
161
167
  });
162
- this.fetch = () => this.neetoPlaywrightUtilities.apiRequest({
163
- url: `${BASE_URL}/custom_domains`,
168
+ this.fetch = (baseUrl = "") => this.neetoPlaywrightUtilities.apiRequest({
169
+ url: `${baseUrl}${CUSTOM_DOMAIN_BASE_URL}`,
170
+ });
171
+ this.validate = (baseUrl = "") => this.neetoPlaywrightUtilities.apiRequest({
172
+ url: `${baseUrl}${CUSTOM_DOMAIN_BASE_URL}/validate_domain`,
173
+ failOnStatusCode: false,
174
+ method: "patch",
164
175
  });
165
176
  }
166
177
  }
@@ -4982,6 +4993,7 @@ const COMMON_SELECTORS = {
4982
4993
  columnsDropdownIcon: "columns-dropdown-icon",
4983
4994
  columnDragHandle: "column-drag-handle",
4984
4995
  reactSelectContainer: ".neeto-ui-react-select__container",
4996
+ calloutElement: "callout-element",
4985
4997
  };
4986
4998
 
4987
4999
  const THANK_YOU_SELECTORS = {
@@ -119334,13 +119346,13 @@ class AuditLogsPage {
119334
119346
  this.messageBuilders = {
119335
119347
  [ACTIONS.inviteUsers]: (data) => `${this.admin} added ${data.emails.join(", ").toLowerCase()} to Neeto${this.product}.`,
119336
119348
  [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}.`,
119337
- [ACTIONS.removedUser]: (data) => `${this.admin} changed ${data.emails[0].toLowerCase()}'s active from true to false on Neeto${this.product}.`,
119349
+ [ACTIONS.removedUser]: (data) => `${this.admin} removed ${data.emails[0].toLowerCase()} from Neeto${this.product}.`,
119338
119350
  [ACTIONS.createdRole]: (data) => `${this.admin} created ${data.roleName} role on Neeto${this.product}.`,
119339
119351
  [ACTIONS.addedPermission]: (data) => `${this.admin} added ${data.permissions.join(", ").toLowerCase()} permission to ${data.roleName} role on Neeto${this.product}.`,
119340
119352
  [ACTIONS.removedPermission]: (data) => `${this.admin} removed ${data.permissions.join(", ")} permissions from ${data.roleName} role on Neeto${this.product}.`,
119341
119353
  [ACTIONS.updatedRole]: (data) => `${this.admin} updated ${data.roleName} role on Neeto${this.product}.`,
119342
119354
  [ACTIONS.deletedRole]: (data) => `${this.admin} deleted ${data.roleName} role on Neeto${this.product}.`,
119343
- [ACTIONS.updatedName]: (data) => `${this.admin} updated their first name: from ${data.name} to ${this.admin.split(" ")[0]} on Neeto${this.product}.`,
119355
+ [ACTIONS.updatedName]: (data) => `${this.admin} changed first name from ${data.name} to ${this.admin.split(" ")[0]} in Neeto${this.product}.`,
119344
119356
  };
119345
119357
  }
119346
119358
  }
@@ -119372,12 +119384,13 @@ class CustomDomainPage {
119372
119384
  .getByRole("cell", { name: domain.split(".")[0] })).toBeVisible(),
119373
119385
  ]);
119374
119386
  await this.neetoPlaywrightUtilities.waitForPageLoad();
119387
+ await validateButton.click();
119388
+ await test.expect(this.page.getByTestId(COMMON_SELECTORS.calloutElement)).toBeVisible({ timeout: 15000 });
119375
119389
  let isCertificateLimitExceeded = false;
119376
119390
  await test.expect(async () => {
119377
119391
  isCertificateLimitExceeded = await this.isCertificateLimitExceeded();
119378
119392
  if (isCertificateLimitExceeded)
119379
119393
  return;
119380
- await validateButton.click();
119381
119394
  await this.neetoPlaywrightUtilities.verifyToast({
119382
119395
  message: this.t("neetoCustomDomains.validation.successMessage"),
119383
119396
  });
@@ -119387,13 +119400,21 @@ class CustomDomainPage {
119387
119400
  return;
119388
119401
  }
119389
119402
  await this.neetoPlaywrightUtilities.waitForPageLoad();
119390
- await test.expect(this.page.getByTestId(CUSTOM_DOMAIN_SELECTORS.activeTagContainer)).toBeVisible();
119403
+ await test.expect(validateButton).toBeHidden();
119404
+ };
119405
+ this.getDomainStatus = async (hostname, baseURL) => {
119406
+ var _a;
119407
+ const response = await this.customDomainApi
119408
+ .fetch(baseURL)
119409
+ .then(response => response === null || response === void 0 ? void 0 : response.json());
119410
+ 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(); });
119411
+ return domain === null || domain === void 0 ? void 0 : domain.status;
119391
119412
  };
119392
119413
  this.loginToCustomDomain = async () => {
119393
119414
  await this.page.close();
119394
119415
  const loginPage = this.loginPage;
119395
119416
  const { email } = getGlobalUserState();
119396
- const loginUrl = `${this.baseURL}${ROUTES.admin}`;
119417
+ const loginUrl = `${this.customDomainURL}${ROUTES.admin}`;
119397
119418
  const playwrightUtils = new CustomCommands(loginPage, loginPage.request);
119398
119419
  const organizationPage = new OrganizationPage(loginPage, playwrightUtils);
119399
119420
  await loginPage.goto(loginUrl);
@@ -119405,7 +119426,7 @@ class CustomDomainPage {
119405
119426
  this.waitForTrustedSSL = () => test.expect
119406
119427
  .poll(() => new Promise(resolve => {
119407
119428
  https
119408
- .get(this.baseURL, { rejectUnauthorized: true }, res => {
119429
+ .get(this.customDomainURL, { rejectUnauthorized: true }, res => {
119409
119430
  res.resume();
119410
119431
  resolve(true);
119411
119432
  })
@@ -119419,7 +119440,7 @@ class CustomDomainPage {
119419
119440
  await this.loginPage.context().storageState({ path: STORAGE_STATE });
119420
119441
  const mergedCredentials = ramda.mergeAll([readFileSyncIfExists(), { user }]);
119421
119442
  writeDataToFile(JSON.stringify(mergedCredentials, null, 2));
119422
- updateCredentials({ key: "baseUrl", value: this.baseURL });
119443
+ updateCredentials({ key: "baseUrl", value: this.customDomainURL });
119423
119444
  updateCredentials({ key: "domain", value: CUSTOM_DOMAIN_SUFFIX });
119424
119445
  };
119425
119446
  // eslint-disable-next-line playwright/no-wait-for-timeout
@@ -119433,21 +119454,57 @@ class CustomDomainPage {
119433
119454
  await this.loginToCustomDomain();
119434
119455
  await this.saveCustomDomainState();
119435
119456
  };
119457
+ this.setupCustomDomainViaAPI = async () => {
119458
+ if (shouldSkipCustomDomainSetup())
119459
+ return;
119460
+ await this.connectViaAPI();
119461
+ const context = await this.browser.newContext(EMPTY_STORAGE_STATE);
119462
+ this.loginPage = await context.newPage();
119463
+ await this.loginToCustomDomain();
119464
+ await this.saveCustomDomainState();
119465
+ };
119436
119466
  this.connectCustomDomain = async (subdomain) => {
119437
119467
  if (shouldSkipCustomDomainSetup())
119438
119468
  return;
119439
- const baseURL = baseURLGenerator(this.product, subdomain);
119440
119469
  const domain = this.getCustomDomain(subdomain);
119441
- this.baseURL = `https://${domain}`;
119470
+ const baseURL = baseURLGenerator(this.product, this.subdomain);
119471
+ this.customDomainURL = `https://${domain}`;
119442
119472
  await this.neetoPlaywrightUtilities.waitForPageLoad();
119443
119473
  await this.page.goto(`${baseURL}${ROUTES.adminPanel.customDomain}`);
119444
119474
  await this.neetoPlaywrightUtilities.waitForPageLoad();
119445
119475
  await this.addCustomDomain(domain);
119446
119476
  await this.validateCustomDomain(domain);
119447
- process.env.BASE_URL = this.baseURL;
119477
+ process.env.BASE_URL = this.customDomainURL;
119478
+ await this.waitForTrustedSSL();
119479
+ await this.waitForDomainPropagation();
119480
+ };
119481
+ this.connectViaAPI = async (subdomain) => {
119482
+ if (shouldSkipCustomDomainSetup())
119483
+ return;
119484
+ const domain = this.getCustomDomain(subdomain);
119485
+ this.customDomainURL = `https://${domain}`;
119486
+ const baseURL = baseURLGenerator(this.product, this.subdomain);
119487
+ await this.page.goto(`${baseURL}${ROUTES.adminPanel.customDomain}`);
119488
+ await this.page.waitForLoadState("domcontentloaded");
119489
+ await this.customDomainApi.create(domain, baseURL);
119490
+ await this.validateDomain(baseURL);
119491
+ await this.awaitDomainValidation(domain, baseURL);
119492
+ process.env.BASE_URL = this.customDomainURL;
119448
119493
  await this.waitForTrustedSSL();
119449
119494
  await this.waitForDomainPropagation();
119450
119495
  };
119496
+ this.validateDomain = (baseURL) => test.expect
119497
+ .poll(async () => { var _a; return (_a = (await this.customDomainApi.validate(baseURL))) === null || _a === void 0 ? void 0 : _a.status(); }, {
119498
+ timeout: 2 * 60000,
119499
+ intervals: [10000],
119500
+ })
119501
+ .toBe(200);
119502
+ this.awaitDomainValidation = (hostname, baseURL) => test.expect
119503
+ .poll(async () => this.getDomainStatus(hostname, baseURL), {
119504
+ timeout: 2 * 60000,
119505
+ intervals: [5000],
119506
+ })
119507
+ .toBe("active");
119451
119508
  this.getCustomDomainFromAPI = async () => {
119452
119509
  const { custom_domains } = await this.customDomainApi
119453
119510
  .fetch()