@bigbinary/neeto-playwright-commons 1.25.0 → 1.26.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.
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",
@@ -4851,9 +4981,9 @@ const NEETO_EDITOR_SELECTORS = {
4851
4981
  todoListOption: optionSelector("todoList"),
4852
4982
  editorMenuWrapper: "neeto-editor-fixed-menu-wrapper",
4853
4983
  dataEmojiType: (type) => `[data-emoji="${type}"]`,
4854
- //Use data-cy once https://github.com/neetozone/neeto-editor/issues/1651 is resolved
4984
+ //Use data-testid once https://github.com/neetozone/neeto-editor/issues/1651 is resolved
4855
4985
  calloutContent: ".callout-content",
4856
- //Use data-cy once https://github.com/neetozone/neeto-editor/issues/1648 is resolved
4986
+ //Use data-testid once https://github.com/neetozone/neeto-editor/issues/1648 is resolved
4857
4987
  calloutTypeOption: ".neeto-editor-callout-dropdown__type-option",
4858
4988
  editorMediaUploaderTab: "neeto-editor-media-uploader-local-tab",
4859
4989
  dynamicVariableSelector: (variable) => `dynamic-variables-list-item-${joinHyphenCase(variable)}`,
@@ -113943,7 +114073,7 @@ class HelpAndProfilePage {
113943
114073
  const replayAppLink = this.page.getByTestId(COMMON_SELECTORS.appLink("Replay"));
113944
114074
  const searchInput = this.page.getByTestId(COMMON_SELECTORS.productSwitcherSearchInput);
113945
114075
  await searchInput.fill(faker.faker.word.words(3));
113946
- //TODO: Use data-cy label when this https://github.com/bigbinary/neeto-molecules/issues/2114 is resolved
114076
+ //TODO: Use data-testid label when this https://github.com/bigbinary/neeto-molecules/issues/2114 is resolved
113947
114077
  await test.expect(this.page.getByText(this.t("neetoMolecules.productSwitcher.noApps"))).toBeVisible();
113948
114078
  await searchInput.fill(searchQueryPartial);
113949
114079
  await Promise.all([
@@ -113971,7 +114101,7 @@ class HelpAndProfilePage {
113971
114101
  const replayAppLink = this.page.getByTestId(COMMON_SELECTORS.appLink("Replay"));
113972
114102
  const searchInput = this.page.getByTestId(COMMON_SELECTORS.productSwitcherSearchInput);
113973
114103
  await searchInput.fill(faker.faker.word.words(3));
113974
- //TODO: Use data-cy label when this https://github.com/bigbinary/neeto-molecules/issues/2114 is resolved
114104
+ //TODO: Use data-testid label when this https://github.com/bigbinary/neeto-molecules/issues/2114 is resolved
113975
114105
  await test.expect(this.page.getByText(this.t("neetoMolecules.productSwitcher.noApps"))).toBeVisible();
113976
114106
  await searchInput.fill(searchQueryPartial);
113977
114107
  await Promise.all([
@@ -116785,7 +116915,7 @@ class ZapierPage extends IntegrationBase {
116785
116915
  await signInPage.waitForLoadState();
116786
116916
  await test.expect(signInPage.getByRole("heading", { name: ZAPIER_WEB_TEXTS.loading })).toBeHidden({ timeout: 10000 });
116787
116917
  // The zapier connect page have two custom fm-prettytext boxes
116788
- // (not an input/textarea) without aria-label or data-cy
116918
+ // (not an input/textarea) without aria-label or data-testid
116789
116919
  const prettyTextBox = signInPage.locator(ZAPIER_SELECTORS.fmPrettytext);
116790
116920
  // eslint-disable-next-line playwright/no-nth-methods
116791
116921
  const subdomainBox = prettyTextBox.nth(0);
@@ -117075,8 +117205,8 @@ class EditorPage {
117075
117205
  .all();
117076
117206
  (await this.moreMenuSelector.isVisible()) && fixedMenuButtons.pop();
117077
117207
  return Promise.all(fixedMenuButtons.map(async (button) => {
117078
- const dataCy = await button.getAttribute("data-cy");
117079
- return this.cleanString(dataCy);
117208
+ const dataTestid = await button.getAttribute("data-testid");
117209
+ return this.cleanString(dataTestid);
117080
117210
  }));
117081
117211
  };
117082
117212
  this.moreMenuOptions = async () => {
@@ -117084,8 +117214,8 @@ class EditorPage {
117084
117214
  const dropdownContainer = this.page.getByTestId(COMMON_SELECTORS.dropdownContainer);
117085
117215
  const moreMenuButtons = await dropdownContainer.getByRole("button").all();
117086
117216
  const moreMenuButtonLocators = Promise.all(moreMenuButtons.map(async (button) => {
117087
- const dataCy = await button.getAttribute("data-cy");
117088
- return this.cleanString(dataCy);
117217
+ const dataTestid = await button.getAttribute("data-testid");
117218
+ return this.cleanString(dataTestid);
117089
117219
  }));
117090
117220
  await this.moreMenuSelector.click();
117091
117221
  await test.expect(dropdownContainer).toBeHidden();
@@ -117100,8 +117230,8 @@ class EditorPage {
117100
117230
  .getByRole("button")
117101
117231
  .all();
117102
117232
  const headingLevels = (await Promise.all(headingButtons.map(async (button) => {
117103
- const dataCy = await button.getAttribute("data-cy");
117104
- const headingLevel = dataCy === null || dataCy === void 0 ? void 0 : dataCy.split("-").pop();
117233
+ const dataTestid = await button.getAttribute("data-testid");
117234
+ const headingLevel = dataTestid === null || dataTestid === void 0 ? void 0 : dataTestid.split("-").pop();
117105
117235
  return /^h[1-5]$/.test(headingLevel || "") ? headingLevel : null;
117106
117236
  }))).filter(Boolean);
117107
117237
  const fontSizeDropdown = this.editorWrapper.getByTestId(NEETO_EDITOR_SELECTORS.fontSize);
@@ -124123,7 +124253,6 @@ const definePlaywrightConfig = (overrides) => {
124123
124253
  ...globalOverrides,
124124
124254
  use: {
124125
124255
  baseURL: process.env.BASE_URL,
124126
- testIdAttribute: "data-cy",
124127
124256
  trace: "on",
124128
124257
  screenshot: "only-on-failure",
124129
124258
  navigationTimeout: 35000,
@@ -124200,6 +124329,7 @@ exports.EMOJI_LABEL = EMOJI_LABEL;
124200
124329
  exports.EMPTY_STORAGE_STATE = EMPTY_STORAGE_STATE;
124201
124330
  exports.ENGAGE_TEXTS = ENGAGE_TEXTS;
124202
124331
  exports.ENVIRONMENT = ENVIRONMENT;
124332
+ exports.EXAMPLE_URL = EXAMPLE_URL;
124203
124333
  exports.EXPANDED_FONT_SIZE = EXPANDED_FONT_SIZE;
124204
124334
  exports.EXPORT_FILE_TYPES = EXPORT_FILE_TYPES;
124205
124335
  exports.EditorPage = EditorPage;
@@ -124267,7 +124397,9 @@ exports.SLACK_SELECTORS = SLACK_SELECTORS;
124267
124397
  exports.SLACK_WEB_TEXTS = SLACK_WEB_TEXTS;
124268
124398
  exports.STATUS_TEXTS = STATUS_TEXTS;
124269
124399
  exports.STORAGE_STATE = STORAGE_STATE;
124400
+ exports.SecurityApi = SecurityApi;
124270
124401
  exports.SidebarSection = SidebarSection;
124402
+ exports.SlackApi = SlackApi;
124271
124403
  exports.SlackPage = SlackPage;
124272
124404
  exports.TABLE_SELECTORS = TABLE_SELECTORS;
124273
124405
  exports.TAB_SELECTORS = TAB_SELECTORS;
@@ -124286,7 +124418,9 @@ exports.TWILIO_SELECTORS = TWILIO_SELECTORS;
124286
124418
  exports.TagsApi = TagsApi;
124287
124419
  exports.TagsPage = TagsPage;
124288
124420
  exports.TeamMembers = TeamMembers;
124421
+ exports.ThankYouApi = ThankYouApi;
124289
124422
  exports.ThankYouPage = ThankYouPage;
124423
+ exports.TwilioApi = TwilioApi;
124290
124424
  exports.USER_AGENTS = USER_AGENTS;
124291
124425
  exports.WEBHOOK_SELECTORS = WEBHOOK_SELECTORS;
124292
124426
  exports.WebhookSiteApi = WebhookSiteApi;