@bigbinary/neeto-playwright-commons 1.25.1 → 1.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -1,14 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ var neetoCist = require('@bigbinary/neeto-cist');
4
+ var faker = require('@faker-js/faker');
3
5
  var require$$0$4 = require('fs');
4
6
  var path$1 = require('path');
5
7
  var test = require('@playwright/test');
6
8
  var playwrightI18nextFixture = require('playwright-i18next-fixture');
7
9
  var require$$0$3 = require('util');
8
10
  var ramda = require('ramda');
9
- var neetoCist = require('@bigbinary/neeto-cist');
10
11
  var child_process = require('child_process');
11
- var faker = require('@faker-js/faker');
12
12
  var dayjs = require('dayjs');
13
13
  var require$$0$6 = require('stream');
14
14
  var node_module = require('node:module');
@@ -252,6 +252,43 @@ class RoleApis {
252
252
  }
253
253
  }
254
254
 
255
+ const SECURITY_BASE_URL = `/secure${BASE_URL}/configuration`;
256
+ class SecurityApi {
257
+ constructor(neetoPlaywrightUtilities) {
258
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
259
+ this.buildBody = (auth, value) => {
260
+ switch (auth) {
261
+ case "password":
262
+ return {
263
+ configuration: {
264
+ auth: "basic",
265
+ password: value || faker.faker.internet.password(),
266
+ },
267
+ };
268
+ case "invite":
269
+ return { configuration: { auth: "invited" } };
270
+ case "member":
271
+ return { configuration: { auth: "session" } };
272
+ case "email":
273
+ return {
274
+ configuration: {
275
+ auth: "email",
276
+ allowed_keywords: [value || faker.faker.internet.domainName()],
277
+ },
278
+ };
279
+ default:
280
+ return { configuration: { auth: "no" } };
281
+ }
282
+ };
283
+ this.update = ({ ownerId, auth, value }) => this.neetoPlaywrightUtilities.apiRequest({
284
+ body: this.buildBody(auth, value),
285
+ url: SECURITY_BASE_URL,
286
+ ...(ownerId && { params: neetoCist.keysToSnakeCase({ ownerId }) }),
287
+ method: "put",
288
+ });
289
+ }
290
+ }
291
+
255
292
  class TagsApi {
256
293
  constructor(neetoPlaywrightUtilities) {
257
294
  this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
@@ -263,6 +300,119 @@ class TagsApi {
263
300
  }
264
301
  }
265
302
 
303
+ const ENVIRONMENT = {
304
+ development: "development",
305
+ staging: "staging",
306
+ review: "review",
307
+ };
308
+ const EXAMPLE_URL = "https://example.com";
309
+ const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
310
+ const STORAGE_STATE = "./e2e/auth/user.json";
311
+ const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
312
+ const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
313
+ const CREDENTIALS = {
314
+ name: "Oliver Smith",
315
+ email: "oliver@example.com",
316
+ password: "welcome",
317
+ };
318
+ const OTP_EMAIL_PATTERN = "is your login code";
319
+ const SLACK_DEFAULT_CHANNEL = "general";
320
+ const CUSTOM_DOMAIN_SUFFIX = "aceinvoice.com";
321
+ const ZAPIER_TEST_EMAIL = (product) => `neeto-${product}-zapier-test@${process.env.FASTMAIL_DOMAIN_NAME}`;
322
+ // constants for translation
323
+ const SINGULAR = { count: 1 };
324
+ const PLURAL = { count: 2 };
325
+ const COLOR = {
326
+ transparent: "rgba(0, 0, 0, 0)",
327
+ softBlue: "rgb(230, 244, 255)",
328
+ };
329
+ const DATE_TEXTS = { now: "Now", nextYear: "next-year" };
330
+ const EMPTY_STORAGE_STATE = {
331
+ storageState: { cookies: [], origins: [] },
332
+ };
333
+ const CURRENT_TIME_RANGES = {
334
+ last24Hours: "Last 24 hours",
335
+ thisWeek: "This week",
336
+ thisMonth: "This month",
337
+ thisYear: "This year",
338
+ thisQuarter: "This quarter",
339
+ last30Days: "Last 30 days",
340
+ last7Days: "Last 7 days",
341
+ };
342
+ const PAST_TIME_RANGES = {
343
+ lastWeek: "Last week",
344
+ lastMonth: "Last month",
345
+ lastYear: "Last year",
346
+ lastQuarter: "Last quarter",
347
+ };
348
+ const TIME_RANGES = {
349
+ ...PAST_TIME_RANGES,
350
+ ...CURRENT_TIME_RANGES,
351
+ customDuration: "Custom duration",
352
+ };
353
+ const DATE_RANGES = {
354
+ ...PAST_TIME_RANGES,
355
+ ...CURRENT_TIME_RANGES,
356
+ after: "After",
357
+ before: "Before",
358
+ customDateRange: "Custom date range",
359
+ };
360
+ const CERTIFICATE_LIMIT_EXCEEDED_REGEXP = `too many certificates \\(\\d+\\) already issued for "${CUSTOM_DOMAIN_SUFFIX}"`;
361
+ const CERTIFICATE_LIMIT_EXCEEDED_MESSAGE = "Certificate limit exceeded for custom domain";
362
+ const EXPORT_FILE_TYPES = {
363
+ pdf: "pdf",
364
+ excel: "excel",
365
+ csv: "csv",
366
+ };
367
+
368
+ const THANK_YOU_URL = "/neeto_thank_you/thank_you_configurations";
369
+ class ThankYouApi {
370
+ constructor(neetoPlaywrightUtilities) {
371
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
372
+ this.create = ({ entityId, title, }) => this.neetoPlaywrightUtilities.apiRequest({
373
+ method: "post",
374
+ body: { title, description: "" },
375
+ url: THANK_YOU_URL,
376
+ params: neetoCist.keysToSnakeCase({ entityId }),
377
+ });
378
+ this.fetch = ({ entityId }) => this.neetoPlaywrightUtilities.apiRequest({
379
+ url: THANK_YOU_URL,
380
+ params: neetoCist.keysToSnakeCase({ entityId }),
381
+ });
382
+ this.update = ({ thankYouPageId, entityId, }) => this.neetoPlaywrightUtilities.apiRequest({
383
+ method: "put",
384
+ url: `${THANK_YOU_URL}/${thankYouPageId}`,
385
+ body: neetoCist.keysToSnakeCase({
386
+ entityId,
387
+ thankYouConfiguration: {
388
+ id: thankYouPageId,
389
+ kind: "redirect_to_url",
390
+ passEventDetailsToRedirectUrl: false,
391
+ redirectUrl: EXAMPLE_URL,
392
+ },
393
+ }),
394
+ });
395
+ }
396
+ }
397
+
398
+ class SlackApi {
399
+ constructor(neetoPlaywrightUtilities) {
400
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
401
+ this.apiRequest = (endpoint, params) => this.neetoPlaywrightUtilities.apiRequest({
402
+ url: `https://slack.com/api/conversations.${endpoint}`,
403
+ headers: { Authorization: `Bearer ${this.botToken}` },
404
+ params,
405
+ });
406
+ this.fetchMessages = (channelId, unixTimestamp) => this.apiRequest("history", { channel: channelId, oldest: unixTimestamp });
407
+ this.createChannel = (channelName) => this.apiRequest("create", { name: channelName });
408
+ this.addUser = (channelId, userId) => this.apiRequest("invite", { channel: channelId, users: userId });
409
+ if (!process.env.SLACK_BOT_TOKEN) {
410
+ throw new Error("SLACK_BOT_TOKEN is not set");
411
+ }
412
+ this.botToken = process.env.SLACK_BOT_TOKEN;
413
+ }
414
+ }
415
+
266
416
  class WebhookSiteApi {
267
417
  constructor(request) {
268
418
  this.request = request;
@@ -272,6 +422,50 @@ class WebhookSiteApi {
272
422
  }
273
423
  }
274
424
 
425
+ class TwilioApi {
426
+ constructor(neetoPlaywrightUtilities) {
427
+ this.neetoPlaywrightUtilities = neetoPlaywrightUtilities;
428
+ this.apiRequest = ({ endpoint, params, body, method = "get", }) => this.neetoPlaywrightUtilities.apiRequest({
429
+ method,
430
+ url: `/neeto_integrations/${endpoint}`,
431
+ ...(params && { params }),
432
+ ...(body && { body }),
433
+ });
434
+ this.fetch = ({ integrableId, integrableType }) => this.apiRequest({
435
+ endpoint: "twilio/sms_configurations",
436
+ ...(integrableId && {
437
+ params: neetoCist.keysToSnakeCase({ integrableId, integrableType }),
438
+ }),
439
+ });
440
+ this.disconnect = ({ integrableId, integrableType }) => this.apiRequest({
441
+ method: "delete",
442
+ endpoint: "disconnect",
443
+ body: neetoCist.keysToSnakeCase({
444
+ disconnect: { slug: "twilio" },
445
+ ...(integrableId && { integrableId, integrableType }),
446
+ }),
447
+ });
448
+ this.connect = ({ integrableId, integrableType }) => this.apiRequest({
449
+ endpoint: "twilio/sms_configurations",
450
+ method: "post",
451
+ body: neetoCist.keysToSnakeCase({
452
+ twilioAuthToken: this.authToken,
453
+ twilioSid: this.sid,
454
+ twilioPhoneNumberSid: this.defaultPhoneSid,
455
+ ...(integrableId && { integrableId, integrableType }),
456
+ }),
457
+ });
458
+ if (!process.env.TWILIO_AUTH_TOKEN ||
459
+ !process.env.TWILIO_SID ||
460
+ !process.env.TWILIO_DEFAULT_PHONE_SID) {
461
+ throw new Error("TWILIO_AUTH_TOKEN, TWILIO_SID, and TWILIO_DEFAULT_PHONE_SID are not set");
462
+ }
463
+ this.authToken = process.env.TWILIO_AUTH_TOKEN;
464
+ this.sid = process.env.TWILIO_SID;
465
+ this.defaultPhoneSid = process.env.TWILIO_DEFAULT_PHONE_SID;
466
+ }
467
+ }
468
+
275
469
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
276
470
 
277
471
  function getDefaultExportFromCjs (x) {
@@ -4389,70 +4583,6 @@ function requireLib$c () {
4389
4583
  var libExports = /*@__PURE__*/ requireLib$c();
4390
4584
  var qs = /*@__PURE__*/getDefaultExportFromCjs(libExports);
4391
4585
 
4392
- const ENVIRONMENT = {
4393
- development: "development",
4394
- staging: "staging",
4395
- review: "review",
4396
- };
4397
- const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
4398
- const STORAGE_STATE = "./e2e/auth/user.json";
4399
- const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
4400
- const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
4401
- const CREDENTIALS = {
4402
- name: "Oliver Smith",
4403
- email: "oliver@example.com",
4404
- password: "welcome",
4405
- };
4406
- const OTP_EMAIL_PATTERN = "is your login code";
4407
- const SLACK_DEFAULT_CHANNEL = "general";
4408
- const CUSTOM_DOMAIN_SUFFIX = "aceinvoice.com";
4409
- const ZAPIER_TEST_EMAIL = (product) => `neeto-${product}-zapier-test@${process.env.FASTMAIL_DOMAIN_NAME}`;
4410
- // constants for translation
4411
- const SINGULAR = { count: 1 };
4412
- const PLURAL = { count: 2 };
4413
- const COLOR = {
4414
- transparent: "rgba(0, 0, 0, 0)",
4415
- softBlue: "rgb(230, 244, 255)",
4416
- };
4417
- const DATE_TEXTS = { now: "Now", nextYear: "next-year" };
4418
- const EMPTY_STORAGE_STATE = {
4419
- storageState: { cookies: [], origins: [] },
4420
- };
4421
- const CURRENT_TIME_RANGES = {
4422
- last24Hours: "Last 24 hours",
4423
- thisWeek: "This week",
4424
- thisMonth: "This month",
4425
- thisYear: "This year",
4426
- thisQuarter: "This quarter",
4427
- last30Days: "Last 30 days",
4428
- last7Days: "Last 7 days",
4429
- };
4430
- const PAST_TIME_RANGES = {
4431
- lastWeek: "Last week",
4432
- lastMonth: "Last month",
4433
- lastYear: "Last year",
4434
- lastQuarter: "Last quarter",
4435
- };
4436
- const TIME_RANGES = {
4437
- ...PAST_TIME_RANGES,
4438
- ...CURRENT_TIME_RANGES,
4439
- customDuration: "Custom duration",
4440
- };
4441
- const DATE_RANGES = {
4442
- ...PAST_TIME_RANGES,
4443
- ...CURRENT_TIME_RANGES,
4444
- after: "After",
4445
- before: "Before",
4446
- customDateRange: "Custom date range",
4447
- };
4448
- const CERTIFICATE_LIMIT_EXCEEDED_REGEXP = `too many certificates \\(\\d+\\) already issued for "${CUSTOM_DOMAIN_SUFFIX}"`;
4449
- const CERTIFICATE_LIMIT_EXCEEDED_MESSAGE = "Certificate limit exceeded for custom domain";
4450
- const EXPORT_FILE_TYPES = {
4451
- pdf: "pdf",
4452
- excel: "excel",
4453
- csv: "csv",
4454
- };
4455
-
4456
4586
  const COMMON_SELECTORS = {
4457
4587
  emailInputError: "email-input-error",
4458
4588
  pane: "pane-wrapper",
@@ -5099,7 +5229,9 @@ const SIGNUP_SELECTORS = {
5099
5229
  subdomainNameTextField: "signup-organization-subdomain-text-field",
5100
5230
  subdomainError: "subdomain-input-error",
5101
5231
  tryFreeButton: "neeto-auth-signup-link",
5102
- unregisterdEmailError: "unregisterd-email-error",
5232
+ /** @deprecated Use unregisteredEmailError instead. */
5233
+ unregisterdEmailError: "unregistered-email-error",
5234
+ unregisteredEmailError: "unregistered-email-error",
5103
5235
  organization: (organizationName) => `${organizationName}-organization-item`,
5104
5236
  };
5105
5237
 
@@ -113485,8 +113617,8 @@ class EmbedBase {
113485
113617
  };
113486
113618
  this.copyEmbedScript = async (embedType) => {
113487
113619
  await this.selectEmbedType(embedType);
113488
- await this.page.getByTestId(COMMON_SELECTORS.copyButton).click();
113489
- return await this.page.evaluate(() => navigator.clipboard.readText());
113620
+ await this.page.getByTestId(COMMON_SELECTORS.copyToClipboardButton).click();
113621
+ return await getClipboardContent(this.page);
113490
113622
  };
113491
113623
  this.selectEmbedType = async (embedType) => {
113492
113624
  await this.page.locator(EMBED_SELECTORS.embedSelector(embedType)).click();
@@ -113657,7 +113789,6 @@ const TOASTR_MESSAGES = {
113657
113789
  };
113658
113790
  const ZAPIER_LIMIT_EXHAUSTED_MESSAGE = "Zapier free task limit is exhausted. Test will be aborted";
113659
113791
  const EMOJI_LABEL = "thumbs up";
113660
- const SELECT_COUNTRY = "Select country";
113661
113792
  const GOOGLE_CALENDAR_DATE_FORMAT = "YYYY/M/D";
113662
113793
  const MICROSOFT_LOGIN_TEXTS = {
113663
113794
  passwordInput: "Enter the password",
@@ -118070,7 +118201,7 @@ class OrganizationPage {
118070
118201
  };
118071
118202
  this.fillEmailAndSubmit = async (email, loginTimeout) => {
118072
118203
  await this.page.getByTestId(LOGIN_SELECTORS.emailTextField).fill(email);
118073
- const unregisteredEmailError = this.page.getByTestId(SIGNUP_SELECTORS.unregisterdEmailError);
118204
+ const unregisteredEmailError = this.page.getByTestId(SIGNUP_SELECTORS.unregisteredEmailError);
118074
118205
  await test.expect(async () => {
118075
118206
  await this.page.getByTestId(LOGIN_SELECTORS.submitButton).click();
118076
118207
  await this.neetoPlaywrightUtilities.waitForPageLoad();
@@ -118170,7 +118301,7 @@ class OrganizationPage {
118170
118301
  });
118171
118302
  };
118172
118303
  this.changeCountry = async (country) => {
118173
- const countrySelector = this.page.getByTestId(COMMON_SELECTORS.customSelectValueContainer(SELECT_COUNTRY));
118304
+ const countrySelector = this.page.getByTestId(COMMON_SELECTORS.customSelectValueContainer("country"));
118174
118305
  await countrySelector.click();
118175
118306
  await countrySelector.pressSequentially(country);
118176
118307
  await this.page.getByTestId(COMMON_SELECTORS.selectOption(country)).click();
@@ -124031,6 +124162,7 @@ var _a;
124031
124162
  process.env.TEST_ENV = (_a = process.env.TEST_ENV) !== null && _a !== void 0 ? _a : ENVIRONMENT.development;
124032
124163
  const env = dotenv.config({
124033
124164
  path: `./e2e/config/.env.${process.env.TEST_ENV}`,
124165
+ quiet: true,
124034
124166
  });
124035
124167
  dotenvExpand.expand(env);
124036
124168
  if (require$$0__namespace.existsSync("./e2e/config/.env.local")) {
@@ -124199,6 +124331,7 @@ exports.EMOJI_LABEL = EMOJI_LABEL;
124199
124331
  exports.EMPTY_STORAGE_STATE = EMPTY_STORAGE_STATE;
124200
124332
  exports.ENGAGE_TEXTS = ENGAGE_TEXTS;
124201
124333
  exports.ENVIRONMENT = ENVIRONMENT;
124334
+ exports.EXAMPLE_URL = EXAMPLE_URL;
124202
124335
  exports.EXPANDED_FONT_SIZE = EXPANDED_FONT_SIZE;
124203
124336
  exports.EXPORT_FILE_TYPES = EXPORT_FILE_TYPES;
124204
124337
  exports.EditorPage = EditorPage;
@@ -124257,7 +124390,6 @@ exports.ROLES_SELECTORS = ROLES_SELECTORS;
124257
124390
  exports.ROUTES = ROUTES;
124258
124391
  exports.RoleApis = RoleApis;
124259
124392
  exports.RolesPage = RolesPage;
124260
- exports.SELECT_COUNTRY = SELECT_COUNTRY;
124261
124393
  exports.SIGNUP_SELECTORS = SIGNUP_SELECTORS;
124262
124394
  exports.SINGULAR = SINGULAR;
124263
124395
  exports.SLACK_DATA_QA_SELECTORS = SLACK_DATA_QA_SELECTORS;
@@ -124266,7 +124398,9 @@ exports.SLACK_SELECTORS = SLACK_SELECTORS;
124266
124398
  exports.SLACK_WEB_TEXTS = SLACK_WEB_TEXTS;
124267
124399
  exports.STATUS_TEXTS = STATUS_TEXTS;
124268
124400
  exports.STORAGE_STATE = STORAGE_STATE;
124401
+ exports.SecurityApi = SecurityApi;
124269
124402
  exports.SidebarSection = SidebarSection;
124403
+ exports.SlackApi = SlackApi;
124270
124404
  exports.SlackPage = SlackPage;
124271
124405
  exports.TABLE_SELECTORS = TABLE_SELECTORS;
124272
124406
  exports.TAB_SELECTORS = TAB_SELECTORS;
@@ -124285,7 +124419,9 @@ exports.TWILIO_SELECTORS = TWILIO_SELECTORS;
124285
124419
  exports.TagsApi = TagsApi;
124286
124420
  exports.TagsPage = TagsPage;
124287
124421
  exports.TeamMembers = TeamMembers;
124422
+ exports.ThankYouApi = ThankYouApi;
124288
124423
  exports.ThankYouPage = ThankYouPage;
124424
+ exports.TwilioApi = TwilioApi;
124289
124425
  exports.USER_AGENTS = USER_AGENTS;
124290
124426
  exports.WEBHOOK_SELECTORS = WEBHOOK_SELECTORS;
124291
124427
  exports.WebhookSiteApi = WebhookSiteApi;