@bigbinary/neeto-playwright-commons 1.24.1 → 1.24.3

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
@@ -156,6 +156,9 @@ class CustomDomainApi {
156
156
  url: `${BASE_URL}/custom_domains/${customDomain}`,
157
157
  method: "delete",
158
158
  });
159
+ this.fetch = () => this.neetoPlaywrightUtilities.apiRequest({
160
+ url: `${BASE_URL}/custom_domains`,
161
+ });
159
162
  }
160
163
  }
161
164
 
@@ -258,6 +261,15 @@ class TagsApi {
258
261
  }
259
262
  }
260
263
 
264
+ class WebhookSiteApi {
265
+ constructor(request) {
266
+ this.request = request;
267
+ this.WEBHOOK_SITE_BASE_URL = "https://webhook.site/token";
268
+ this.create = () => this.request.post(this.WEBHOOK_SITE_BASE_URL);
269
+ this.fetch = (token) => this.request.get(`${this.WEBHOOK_SITE_BASE_URL}/${token}/request/latest`);
270
+ }
271
+ }
272
+
261
273
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
262
274
 
263
275
  function getDefaultExportFromCjs (x) {
@@ -4431,6 +4443,8 @@ const DATE_RANGES = {
4431
4443
  before: "Before",
4432
4444
  customDateRange: "Custom date range",
4433
4445
  };
4446
+ const CERTIFICATE_LIMIT_EXCEEDED_REGEXP = `too many certificates \\(\\d+\\) already issued for "${CUSTOM_DOMAIN_SUFFIX}"`;
4447
+ const CERTIFICATE_LIMIT_EXCEEDED_MESSAGE = "Certificate limit exceeded for custom domain";
4434
4448
 
4435
4449
  const COMMON_SELECTORS = {
4436
4450
  emailInputError: "email-input-error",
@@ -116538,6 +116552,21 @@ class SlackPage extends IntegrationBase {
116538
116552
 
116539
116553
  class WebhooksPage {
116540
116554
  constructor({ page, request, neetoPlaywrightUtilities, context, }) {
116555
+ this.getTokenViaAPI = async () => {
116556
+ let webhookToken = null;
116557
+ await test.expect(async () => {
116558
+ var _a;
116559
+ const response = await this.webhookSiteApi.create();
116560
+ await test.expect(response).toBeOK();
116561
+ webhookToken = (_a = (await response.json())) === null || _a === void 0 ? void 0 : _a.uuid;
116562
+ }).toPass({ timeout: 15000 });
116563
+ if (!webhookToken)
116564
+ throw new Error("Failed to get webhook token");
116565
+ return {
116566
+ webhookToken,
116567
+ webhookSiteURL: `${THIRD_PARTY_ROUTES.webhooks.site}${webhookToken}`,
116568
+ };
116569
+ };
116541
116570
  this.getWebhookURL = async () => {
116542
116571
  var _a;
116543
116572
  const WEBHOOK_URL_REGEX = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/g;
@@ -116565,20 +116594,15 @@ class WebhooksPage {
116565
116594
  ]);
116566
116595
  await test.expect(this.page.getByRole("row", { name: webhookSiteURL })).toBeVisible();
116567
116596
  };
116568
- this.verifyLatestWebhookResponse = async ({ callback = () => { }, webhookToken, parseFullResponseContent = false, timeout = 20000, ...otherParams }) => {
116569
- let response;
116570
- await test.expect(async () => {
116571
- response = await this.request.get(`https://webhook.site/token/${webhookToken}/request/latest`);
116572
- test.expect(response.status()).toBe(200);
116573
- if (response.status() === 200) {
116574
- const { content } = await response.json();
116575
- const parsedResponse = parseFullResponseContent
116576
- ? JSON.parse(content)
116577
- : JSON.parse(content).webhook;
116578
- callback({ parsedResponse, ...otherParams });
116579
- }
116580
- }).toPass({ timeout });
116581
- };
116597
+ this.verifyLatestWebhookResponse = ({ callback = () => { }, webhookToken, parseFullResponseContent = false, timeout = 20000, ...otherParams }) => test.expect(async () => {
116598
+ const response = await this.webhookSiteApi.fetch(webhookToken);
116599
+ await test.expect(response).toBeOK();
116600
+ const { content } = await response.json();
116601
+ const parsedResponse = parseFullResponseContent
116602
+ ? JSON.parse(content)
116603
+ : JSON.parse(content).webhook;
116604
+ callback({ parsedResponse, ...otherParams });
116605
+ }).toPass({ timeout });
116582
116606
  this.verifyWebhookDeliveries = async ({ callback = () => { }, ...otherParams }) => {
116583
116607
  await test.expect(this.page.getByTestId(WEBHOOK_SELECTORS.deliveryResponseCode)).toHaveText("200");
116584
116608
  const requestPayload = (await this.page
@@ -116599,6 +116623,7 @@ class WebhooksPage {
116599
116623
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
116600
116624
  this.context = context;
116601
116625
  this.t = playwrightI18nextFixture.getI18nInstance().t;
116626
+ this.webhookSiteApi = new WebhookSiteApi(this.request);
116602
116627
  }
116603
116628
  }
116604
116629
 
@@ -118175,13 +118200,20 @@ class CustomDomainPage {
118175
118200
  test.expect(this.page.getByTestId(COMMON_SELECTORS.paneHeader).getByText(domain)).toBeVisible(),
118176
118201
  ]);
118177
118202
  await this.neetoPlaywrightUtilities.waitForPageLoad();
118203
+ let isCertificateLimitExceeded = false;
118178
118204
  await test.expect(async () => {
118205
+ isCertificateLimitExceeded = await this.isCertificateLimitExceeded();
118206
+ if (isCertificateLimitExceeded)
118207
+ return;
118179
118208
  await validateButton.click();
118180
118209
  await this.neetoPlaywrightUtilities.verifyToast({
118181
- timeout: 20000,
118182
118210
  message: this.t("neetoCustomDomains.validation.successMessage"),
118183
118211
  });
118184
118212
  }).toPass({ timeout: 60000 });
118213
+ if (isCertificateLimitExceeded) {
118214
+ test.test.skip(true, CERTIFICATE_LIMIT_EXCEEDED_MESSAGE);
118215
+ return;
118216
+ }
118185
118217
  await this.neetoPlaywrightUtilities.waitForPageLoad();
118186
118218
  await test.expect(this.page.getByTestId(CUSTOM_DOMAIN_SELECTORS.activeTagContainer)).toBeVisible();
118187
118219
  };
@@ -118244,8 +118276,15 @@ class CustomDomainPage {
118244
118276
  await this.waitForTrustedSSL();
118245
118277
  await this.waitForDomainPropagation();
118246
118278
  };
118279
+ this.getCustomDomainFromAPI = async () => {
118280
+ const { custom_domains } = await this.customDomainApi
118281
+ .fetch()
118282
+ .then(response => response === null || response === void 0 ? void 0 : response.json());
118283
+ return custom_domains;
118284
+ };
118247
118285
  this.disconnectCustomDomain = async () => {
118248
- if (shouldSkipCustomDomainSetup())
118286
+ const customDomains = await this.getCustomDomainFromAPI();
118287
+ if (ramda.isEmpty(customDomains))
118249
118288
  return;
118250
118289
  const baseURL = baseURLGenerator(this.product, this.subdomain);
118251
118290
  await this.neetoPlaywrightUtilities.waitForPageLoad();
@@ -118263,13 +118302,15 @@ class CustomDomainPage {
118263
118302
  await test.expect(this.page.getByTestId(COMMON_SELECTORS.noDataTitle)).toBeVisible();
118264
118303
  };
118265
118304
  this.disconnectViaRequest = async () => {
118266
- if (shouldSkipCustomDomainSetup())
118267
- return;
118268
- const customDomain = this.getCustomDomain(this.subdomain);
118269
- if (!neetoCist.isPresent(customDomain))
118305
+ const customDomains = await this.getCustomDomainFromAPI();
118306
+ if (ramda.isEmpty(customDomains))
118270
118307
  return;
118271
- await this.customDomainApi.delete(customDomain);
118308
+ await Promise.all(customDomains.map(({ hostname }) => this.customDomainApi.delete(hostname)));
118272
118309
  };
118310
+ this.isCertificateLimitExceeded = () => this.page
118311
+ .getByTestId(COMMON_SELECTORS.paneBody)
118312
+ .getByText(RegExp(CERTIFICATE_LIMIT_EXCEEDED_REGEXP, "i"))
118313
+ .isVisible();
118273
118314
  this.page = page;
118274
118315
  this.browser = browser;
118275
118316
  this.product = product;
@@ -123879,6 +123920,7 @@ dotenvExpand.expand(env);
123879
123920
  if (require$$0__namespace.existsSync("./e2e/config/.env.local")) {
123880
123921
  const localEnv = dotenv.config({
123881
123922
  path: "./e2e/config/.env.local",
123923
+ quiet: true,
123882
123924
  });
123883
123925
  dotenvExpand.expand(localEnv);
123884
123926
  }
@@ -123992,6 +124034,8 @@ exports.ApiKeysApi = ApiKeysApi;
123992
124034
  exports.ApiKeysPage = ApiKeysPage;
123993
124035
  exports.AuditLogsPage = AuditLogsPage;
123994
124036
  exports.BASE_URL = BASE_URL;
124037
+ exports.CERTIFICATE_LIMIT_EXCEEDED_MESSAGE = CERTIFICATE_LIMIT_EXCEEDED_MESSAGE;
124038
+ exports.CERTIFICATE_LIMIT_EXCEEDED_REGEXP = CERTIFICATE_LIMIT_EXCEEDED_REGEXP;
123995
124039
  exports.CHANGELOG_WIDGET_SELECTORS = CHANGELOG_WIDGET_SELECTORS;
123996
124040
  exports.CHAT_WIDGET_SELECTORS = CHAT_WIDGET_SELECTORS;
123997
124041
  exports.CHAT_WIDGET_TEXTS = CHAT_WIDGET_TEXTS;
@@ -124102,6 +124146,7 @@ exports.TeamMembers = TeamMembers;
124102
124146
  exports.ThankYouPage = ThankYouPage;
124103
124147
  exports.USER_AGENTS = USER_AGENTS;
124104
124148
  exports.WEBHOOK_SELECTORS = WEBHOOK_SELECTORS;
124149
+ exports.WebhookSiteApi = WebhookSiteApi;
124105
124150
  exports.WebhooksPage = WebhooksPage;
124106
124151
  exports.ZAPIER_LIMIT_EXHAUSTED_MESSAGE = ZAPIER_LIMIT_EXHAUSTED_MESSAGE;
124107
124152
  exports.ZAPIER_SELECTORS = ZAPIER_SELECTORS;