@bigbinary/neeto-playwright-commons 1.1.1 → 1.1.2

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
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var test = require('@playwright/test');
6
- var fs$9 = require('fs');
6
+ var require$$0$3 = require('fs');
7
7
  var require$$2 = require('os');
8
8
  var require$$0 = require('path');
9
9
  var require$$0$1 = require('util');
10
10
  var require$$0$2 = require('stream');
11
- var require$$0$3 = require('events');
11
+ var require$$0$4 = require('events');
12
12
  var ramda = require('ramda');
13
13
  var dayjs = require('dayjs');
14
14
  var require$$3 = require('crypto');
@@ -33,17 +33,17 @@ function _interopNamespace(e) {
33
33
  return Object.freeze(n);
34
34
  }
35
35
 
36
- var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$9);
37
- var fs__namespace = /*#__PURE__*/_interopNamespace(fs$9);
36
+ var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
37
+ var require$$0__namespace = /*#__PURE__*/_interopNamespace(require$$0$3);
38
38
  var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
39
39
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
40
40
  var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
41
41
  var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
42
- var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
42
+ var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$4);
43
43
  var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
44
44
  var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
45
45
 
46
- const COMMON_SELECTORS$1 = {
46
+ const COMMON_SELECTORS = {
47
47
  toastMessage: "toastr-message-container",
48
48
  toastIcon: ".Toastify__toast-icon",
49
49
  toastCloseButton: "toastr-close-button",
@@ -4938,7 +4938,7 @@ var fs$6 = {};
4938
4938
  (function (exports) {
4939
4939
  Object.defineProperty(exports, "__esModule", { value: true });
4940
4940
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
4941
- const fs = fs__default["default"];
4941
+ const fs = require$$0__default$3["default"];
4942
4942
  exports.FILE_SYSTEM_ADAPTER = {
4943
4943
  lstat: fs.lstat,
4944
4944
  stat: fs.stat,
@@ -5289,7 +5289,7 @@ var fs$2 = {};
5289
5289
  (function (exports) {
5290
5290
  Object.defineProperty(exports, "__esModule", { value: true });
5291
5291
  exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
5292
- const fs = fs__default["default"];
5292
+ const fs = require$$0__default$3["default"];
5293
5293
  exports.FILE_SYSTEM_ADAPTER = {
5294
5294
  lstat: fs.lstat,
5295
5295
  stat: fs.stat,
@@ -5726,7 +5726,7 @@ class Reader$1 {
5726
5726
  reader$1.default = Reader$1;
5727
5727
 
5728
5728
  Object.defineProperty(async$4, "__esModule", { value: true });
5729
- const events_1 = require$$0__default$3["default"];
5729
+ const events_1 = require$$0__default$4["default"];
5730
5730
  const fsScandir$2 = out$2;
5731
5731
  const fastq = queue.exports;
5732
5732
  const common$1 = common$3;
@@ -6596,7 +6596,7 @@ var settings = {};
6596
6596
  (function (exports) {
6597
6597
  Object.defineProperty(exports, "__esModule", { value: true });
6598
6598
  exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
6599
- const fs = fs__default["default"];
6599
+ const fs = require$$0__default$3["default"];
6600
6600
  const os = require$$2__default["default"];
6601
6601
  /**
6602
6602
  * The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
@@ -6754,17 +6754,61 @@ function assertPatternsInput(input) {
6754
6754
  }
6755
6755
  var out = FastGlob;
6756
6756
 
6757
- process.env.TEST_ENV === "staging";
6758
- const STORAGE_STATE$1 = "./e2e/auth/user.json";
6757
+ const ENVIRONMENT = {
6758
+ development: "development",
6759
+ staging: "staging",
6760
+ review: "review",
6761
+ };
6762
+ const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
6763
+ const STORAGE_STATE = "./e2e/auth/user.json";
6764
+ const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
6765
+ const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
6766
+ const CREDENTIALS = { email: "oliver@example.com", password: "welcome" };
6759
6767
 
6760
- const readFileSyncIfExists$1 = (path = STORAGE_STATE$1) => {
6768
+ const joinString = (string1, string2, string3 = "", separator = " ") => {
6769
+ if (string3 === "") {
6770
+ return string1 + separator + string2;
6771
+ }
6772
+ return string1 + separator + string2 + separator + string3;
6773
+ };
6774
+ const readFileSyncIfExists = (path = STORAGE_STATE) => {
6761
6775
  try {
6762
- return JSON.parse(fs__namespace.readFileSync(path, "utf8"));
6776
+ return JSON.parse(require$$0__namespace.readFileSync(path, "utf8"));
6763
6777
  }
6764
6778
  catch (error) {
6765
6779
  return {};
6766
6780
  }
6767
6781
  };
6782
+ const writeDataToFile = data => {
6783
+ try {
6784
+ require$$0__namespace.writeFileSync(STORAGE_STATE, data, "utf8");
6785
+ }
6786
+ catch (error) {
6787
+ console.log(error); // eslint-disable-line
6788
+ }
6789
+ return true;
6790
+ };
6791
+ const updateCredentials = ({ key, value }) => {
6792
+ const data = readFileSyncIfExists();
6793
+ data["user"][key] = value;
6794
+ return writeDataToFile(JSON.stringify(data));
6795
+ };
6796
+ const clearCredentials = () => {
6797
+ require$$0__namespace.unlink(STORAGE_STATE, error => {
6798
+ if (!error)
6799
+ return;
6800
+ console.log(error); // eslint-disable-line
6801
+ });
6802
+ };
6803
+ const readTranslations = () => {
6804
+ let translations = readFileSyncIfExists(PROJECT_TRANSLATIONS_PATH);
6805
+ const paths = out.sync(GLOBAL_TRANSLATIONS_PATTERN);
6806
+ paths.forEach(path => {
6807
+ const packageTranslation = readFileSyncIfExists(path);
6808
+ translations = ramda.mergeDeepLeft(translations, packageTranslation);
6809
+ });
6810
+ return translations;
6811
+ };
6768
6812
 
6769
6813
  class CustomCommands {
6770
6814
  constructor(page, request) {
@@ -6797,13 +6841,13 @@ class CustomCommands {
6797
6841
  };
6798
6842
  this.verifySuccessToast = async ({ message, closeAfterVerification = true, }) => {
6799
6843
  if (message) {
6800
- await test.expect(this.page.getByTestId(COMMON_SELECTORS$1.toastMessage)).toHaveValue(message);
6844
+ await test.expect(this.page.getByTestId(COMMON_SELECTORS.toastMessage)).toHaveValue(message);
6801
6845
  }
6802
6846
  else {
6803
- await test.expect(this.page.locator(COMMON_SELECTORS$1.toastIcon)).toHaveValue("👍");
6847
+ await test.expect(this.page.locator(COMMON_SELECTORS.toastIcon)).toHaveValue("👍");
6804
6848
  closeAfterVerification &&
6805
6849
  (await this.page
6806
- .getByTestId(COMMON_SELECTORS$1.toastCloseButton)
6850
+ .getByTestId(COMMON_SELECTORS.toastCloseButton)
6807
6851
  .click());
6808
6852
  }
6809
6853
  };
@@ -6815,7 +6859,7 @@ class CustomCommands {
6815
6859
  await reloadRequests;
6816
6860
  };
6817
6861
  this.apiRequest = async ({ url, headers: additionalHeaders, body: data, method = "get", params = {}, ...otherOptions }) => {
6818
- const { headers } = readFileSyncIfExists$1();
6862
+ const { headers } = readFileSyncIfExists();
6819
6863
  const requestOptions = {
6820
6864
  headers: { ...headers, ...additionalHeaders, "accept-encoding": "gzip" },
6821
6865
  data,
@@ -6848,67 +6892,11 @@ const commands = {
6848
6892
  },
6849
6893
  page: async ({ page }, use) => {
6850
6894
  await page.goto("/");
6851
- await page.waitForLoadState("load");
6895
+ await page.waitForLoadState();
6852
6896
  await use(page);
6853
6897
  },
6854
6898
  };
6855
6899
 
6856
- const ENVIRONMENT = {
6857
- development: "development",
6858
- staging: "staging",
6859
- review: "review",
6860
- };
6861
- const IS_STAGING_ENV = process.env.TEST_ENV === "staging";
6862
- const STORAGE_STATE = "./e2e/auth/user.json";
6863
- const GLOBAL_TRANSLATIONS_PATTERN = "../node_modules/@bigbinary/**/translations/en.json";
6864
- const PROJECT_TRANSLATIONS_PATH = "../app/javascript/src/translations/en.json";
6865
- const CREDENTIALS = { email: "oliver@example.com", password: "welcome" };
6866
-
6867
- const joinString = (string1, string2, string3 = "", separator = " ") => {
6868
- if (string3 === "") {
6869
- return string1 + separator + string2;
6870
- }
6871
- return string1 + separator + string2 + separator + string3;
6872
- };
6873
- const readFileSyncIfExists = (path = STORAGE_STATE) => {
6874
- try {
6875
- return JSON.parse(fs__namespace.readFileSync(path, "utf8"));
6876
- }
6877
- catch (error) {
6878
- return {};
6879
- }
6880
- };
6881
- const writeDataToFile = data => {
6882
- try {
6883
- fs__namespace.writeFileSync(STORAGE_STATE, data, "utf8");
6884
- }
6885
- catch (error) {
6886
- console.log(error); // eslint-disable-line
6887
- }
6888
- return true;
6889
- };
6890
- const updateCredentials = ({ key, value }) => {
6891
- const data = readFileSyncIfExists();
6892
- data["user"][key] = value;
6893
- return writeDataToFile(JSON.stringify(data));
6894
- };
6895
- const clearCredentials = () => {
6896
- fs__namespace.unlink(STORAGE_STATE, error => {
6897
- if (!error)
6898
- return;
6899
- console.log(error); // eslint-disable-line
6900
- });
6901
- };
6902
- const readTranslations = () => {
6903
- let translations = readFileSyncIfExists(PROJECT_TRANSLATIONS_PATH);
6904
- const paths = out.sync(GLOBAL_TRANSLATIONS_PATTERN);
6905
- paths.forEach(path => {
6906
- const packageTranslation = readFileSyncIfExists(path);
6907
- translations = ramda.mergeDeepLeft(translations, packageTranslation);
6908
- });
6909
- return translations;
6910
- };
6911
-
6912
6900
  const timestamp = dayjs__default["default"]().format("YYYYMMDDHH");
6913
6901
  const firstName = "André";
6914
6902
  const lastName = "O'Reilly";
@@ -6925,7 +6913,7 @@ const stagingData = {
6925
6913
  businessName: stagingOrganization,
6926
6914
  subdomainName: IS_STAGING_ENV ? stagingOrganization : "spinkart",
6927
6915
  email: IS_STAGING_ENV
6928
- ? `cypresstest${otpBypassKey}+invoice+${timestamp}@bigbinary.com`
6916
+ ? `cypresstest${otpBypassKey}+invoice+${timestamp}-playwright@bigbinary.com`
6929
6917
  : "oliver@example.com",
6930
6918
  };
6931
6919
 
@@ -6945,25 +6933,14 @@ const i18n = {
6945
6933
  };
6946
6934
 
6947
6935
  const BASE_URL = "/api/v1";
6948
- const PROFILE_PATH = "/profile";
6949
- const NEETO_AUTH_URL = "https://app.neetoauth.net";
6950
- const LOGIN_PATH = `${BASE_URL}/login`;
6951
- const SIGNUP_PATH = `${BASE_URL}/signups`;
6952
- const SUBDOMAIN_AVAILABILITY_PATH = `${BASE_URL}/subdomain_availability`;
6953
- const COUNTRIES_PATH = `${BASE_URL}/countries`;
6954
- const NEETO_APPS_PATH = `${BASE_URL}/neeto_apps`;
6955
-
6956
- const COMMON_SELECTORS = {
6957
- toastMessage: "toastr-message-container",
6958
- toastIcon: ".Toastify__toast-icon",
6959
- toastCloseButton: "toastr-close-button",
6960
- dropdownIcon: "nui-dropdown-icon",
6961
- checkbox: "nui-checkbox-input",
6962
- spinner: ".neeto-ui-spinner",
6963
- input: "nui-input-field",
6964
- alertModalSubmitButton: "alert-submit-button",
6965
- selectContainer: "nui-select-container",
6966
- subheaderText: "subheader-left",
6936
+ const ROUTES = {
6937
+ neetoAuth: "https://app.neetoauth.net",
6938
+ profile: "/profile",
6939
+ login: `${BASE_URL}/login`,
6940
+ signup: `${BASE_URL}/signups`,
6941
+ subdomainAvailability: `${BASE_URL}/subdomain_availability`,
6942
+ countries: `${BASE_URL}/countries`,
6943
+ neetoAps: `${BASE_URL}/neeto_apps`,
6967
6944
  };
6968
6945
 
6969
6946
  const SIGNUP_SELECTORS = {
@@ -7001,8 +6978,8 @@ class OrganizationPage {
7001
6978
  : await this.page.goto(`${authUrl}?redirect_uri=${appNameInLowerCase}.net`);
7002
6979
  await this.page.getByTestId(SIGNUP_SELECTORS.emailTextField).fill(email);
7003
6980
  const signup = this.neetoPlaywrightUtilities.interceptMultipleResponses({
7004
- responseUrl: SIGNUP_PATH,
7005
- baseUrl: NEETO_AUTH_URL,
6981
+ responseUrl: ROUTES.signup,
6982
+ baseUrl: ROUTES.neetoAuth,
7006
6983
  });
7007
6984
  await this.page.getByTestId(SIGNUP_SELECTORS.submitButton).click();
7008
6985
  await signup;
@@ -7010,7 +6987,7 @@ class OrganizationPage {
7010
6987
  await this.page
7011
6988
  .getByTestId(SIGNUP_SELECTORS.organizationNameTextField)
7012
6989
  .fill(businessName);
7013
- const fetchSubdomainAvailability = this.page.waitForResponse(response => response.url().includes(SUBDOMAIN_AVAILABILITY_PATH));
6990
+ const fetchSubdomainAvailability = this.page.waitForResponse(response => response.url().includes(ROUTES.subdomainAvailability));
7014
6991
  await this.page
7015
6992
  .getByTestId(SIGNUP_SELECTORS.subdomainNameTextField)
7016
6993
  .fill(subdomainName);
@@ -7024,10 +7001,10 @@ class OrganizationPage {
7024
7001
  .getByTestId(SIGNUP_SELECTORS.organizationSubmitButton)
7025
7002
  .click();
7026
7003
  await Promise.all([
7027
- this.page.waitForResponse(response => response.url().includes(SIGNUP_PATH)),
7028
- this.page.waitForResponse(response => response.url().includes(COUNTRIES_PATH)),
7004
+ this.page.waitForResponse(response => response.url().includes(ROUTES.signup)),
7005
+ this.page.waitForResponse(response => response.url().includes(ROUTES.countries)),
7029
7006
  ]);
7030
- await this.page.waitForURL(`**${PROFILE_PATH}`, { timeout: 15000 });
7007
+ await this.page.waitForURL(`**${ROUTES.profile}`, { timeout: 15000 });
7031
7008
  await this.page
7032
7009
  .getByTestId(SIGNUP_SELECTORS.firstNameTextField)
7033
7010
  .fill(firstName);
@@ -7036,8 +7013,8 @@ class OrganizationPage {
7036
7013
  .fill(lastName);
7037
7014
  await this.page.getByTestId(COMMON_SELECTORS.checkbox).click();
7038
7015
  const submitProfile = this.neetoPlaywrightUtilities.interceptMultipleResponses({
7039
- responseUrl: SIGNUP_PATH,
7040
- baseUrl: NEETO_AUTH_URL,
7016
+ responseUrl: ROUTES.signup,
7017
+ baseUrl: ROUTES.neetoAuth,
7041
7018
  });
7042
7019
  await this.page.getByTestId(SIGNUP_SELECTORS.profileSubmitButton).click();
7043
7020
  await submitProfile;
@@ -7055,7 +7032,7 @@ class OrganizationPage {
7055
7032
  subdomainName: user.subdomainName,
7056
7033
  appName: "neetoInvoice",
7057
7034
  });
7058
- await this.page.route(`**${NEETO_APPS_PATH}`, async (route) => {
7035
+ await this.page.route(`**${ROUTES.neetoAps}`, async (route) => {
7059
7036
  headers = await route.request().allHeaders();
7060
7037
  await route.continue();
7061
7038
  });
@@ -7078,7 +7055,7 @@ class OrganizationPage {
7078
7055
  await this.page
7079
7056
  .getByTestId(SIGNUP_SELECTORS.subdomainNameTextField)
7080
7057
  .fill(newOrganizationName);
7081
- await this.page.waitForResponse(response => response.url().includes(SUBDOMAIN_AVAILABILITY_PATH));
7058
+ await this.page.waitForResponse(response => response.url().includes(ROUTES.subdomainAvailability));
7082
7059
  subdomainErrorCount = await subdomainError.count();
7083
7060
  if (subdomainErrorCount === 0) {
7084
7061
  updateCredentials({
@@ -7143,7 +7120,7 @@ const loginWithoutSSO = async ({ page, neetoPlaywrightUtilities, }) => {
7143
7120
  var _a;
7144
7121
  await page.goto((_a = process.env.BASE_URL) !== null && _a !== void 0 ? _a : "");
7145
7122
  let headers = {};
7146
- await page.route(`**${LOGIN_PATH}`, async (route) => {
7123
+ await page.route(`**${ROUTES.login}`, async (route) => {
7147
7124
  headers = await route.request().allHeaders();
7148
7125
  await route.continue();
7149
7126
  });
@@ -7250,7 +7227,7 @@ var require$$4 = {
7250
7227
  browser: browser
7251
7228
  };
7252
7229
 
7253
- const fs = fs__default["default"];
7230
+ const fs = require$$0__default$3["default"];
7254
7231
  const path = require$$0__default["default"];
7255
7232
  const os = require$$2__default["default"];
7256
7233
  const crypto = require$$3__default["default"];
@@ -7582,7 +7559,7 @@ const definePlaywrightConfig = (overrides) => {
7582
7559
  const { globalOverrides = {}, useOverrides = {}, projectOverrides = [], currentsOverrides = {}, } = overrides;
7583
7560
  return test.defineConfig({
7584
7561
  testDir: "./e2e/tests",
7585
- fullyParallel: false,
7562
+ fullyParallel: true,
7586
7563
  forbidOnly: isCI,
7587
7564
  retries: isCI ? 1 : 0,
7588
7565
  timeout: 0,
@@ -7616,26 +7593,19 @@ const definePlaywrightConfig = (overrides) => {
7616
7593
  });
7617
7594
  };
7618
7595
 
7619
- exports.BASE_URL = BASE_URL;
7620
7596
  exports.COMMON_SELECTORS = COMMON_SELECTORS;
7621
7597
  exports.COMMON_TEXTS = COMMON_TEXTS;
7622
- exports.COUNTRIES_PATH = COUNTRIES_PATH;
7623
7598
  exports.CREDENTIALS = CREDENTIALS;
7624
7599
  exports.CustomCommands = CustomCommands;
7625
7600
  exports.ENVIRONMENT = ENVIRONMENT;
7626
7601
  exports.GLOBAL_TRANSLATIONS_PATTERN = GLOBAL_TRANSLATIONS_PATTERN;
7627
7602
  exports.IS_STAGING_ENV = IS_STAGING_ENV;
7628
- exports.LOGIN_PATH = LOGIN_PATH;
7629
7603
  exports.LOGIN_SELECTORS = LOGIN_SELECTORS;
7630
- exports.NEETO_APPS_PATH = NEETO_APPS_PATH;
7631
- exports.NEETO_AUTH_URL = NEETO_AUTH_URL;
7632
7604
  exports.OrganizationPage = OrganizationPage;
7633
- exports.PROFILE_PATH = PROFILE_PATH;
7634
7605
  exports.PROJECT_TRANSLATIONS_PATH = PROJECT_TRANSLATIONS_PATH;
7635
- exports.SIGNUP_PATH = SIGNUP_PATH;
7606
+ exports.ROUTES = ROUTES;
7636
7607
  exports.SIGNUP_SELECTORS = SIGNUP_SELECTORS;
7637
7608
  exports.STORAGE_STATE = STORAGE_STATE;
7638
- exports.SUBDOMAIN_AVAILABILITY_PATH = SUBDOMAIN_AVAILABILITY_PATH;
7639
7609
  exports.clearCredentials = clearCredentials;
7640
7610
  exports.commands = commands;
7641
7611
  exports.definePlaywrightConfig = definePlaywrightConfig;