@bigbinary/neeto-commons-frontend 2.0.108 → 2.0.109

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.
@@ -1,8 +1,6 @@
1
1
  const { defineConfig } = require("cypress");
2
2
 
3
3
  const defineCypressConfig = (overrides = {}) => {
4
- const globalState = { skipSetup: false };
5
-
6
4
  const { e2e: e2eOverrides = {}, ...otherProps } = overrides;
7
5
 
8
6
  return defineConfig({
@@ -18,13 +16,6 @@ const defineCypressConfig = (overrides = {}) => {
18
16
  retries: { runMode: 1, openMode: 0 },
19
17
  e2e: {
20
18
  setupNodeEvents(on, config) {
21
- on("task", {
22
- getGlobalState: key => (key ? globalState[key] || null : globalState),
23
- updateGlobalState: ({ key, value }) => (globalState[key] = value),
24
- bulkUpdateGlobalState: newState =>
25
- Object.assign(globalState, newState),
26
- });
27
-
28
19
  return require("./plugins")(on, config);
29
20
  },
30
21
  specPattern: "cypress/e2e/**/*.spec.js",
@@ -20,6 +20,8 @@ const getConfigurationByFile = file => {
20
20
  return file && fs.readJsonSync(path.join(process.cwd(), pathToConfigFile));
21
21
  };
22
22
 
23
+ const globalState = "globalState.txt";
24
+
23
25
  const merge = (target, source = {}) => {
24
26
  Object.keys(source).forEach(key => {
25
27
  if (source[key] && typeof source[key] === "object") {
@@ -61,5 +63,43 @@ module.exports = (on, config) => {
61
63
  return launchOptions;
62
64
  });
63
65
 
66
+ const readFileSyncIfExists = filePath => {
67
+ try {
68
+ return JSON.parse(fs.readFileSync(filePath, "utf8"));
69
+ } catch (error) {
70
+ if (error.code === "ENOENT") {
71
+ return {};
72
+ }
73
+ console.log(error); // eslint-disable-line
74
+ }
75
+
76
+ return {};
77
+ };
78
+
79
+ const writeDataToFile = (filePath, data) => {
80
+ try {
81
+ fs.writeFileSync(filePath, data, "utf8");
82
+ } catch (err) {
83
+ console.log(err); // eslint-disable-line
84
+ }
85
+
86
+ return true;
87
+ };
88
+
89
+ on("task", {
90
+ getGlobalState: key =>
91
+ key
92
+ ? readFileSyncIfExists(globalState)?.[key] ?? null
93
+ : readFileSyncIfExists(globalState),
94
+ updateGlobalState: ({ key, value }) => {
95
+ const data = readFileSyncIfExists(globalState);
96
+ data[key] = value;
97
+
98
+ return writeDataToFile(globalState, JSON.stringify(data));
99
+ },
100
+ bulkUpdateGlobalState: newState =>
101
+ writeDataToFile(globalState, JSON.stringify(newState)),
102
+ });
103
+
64
104
  return config, newEnvironment;
65
105
  };
@@ -1129,7 +1129,7 @@ var createOrganization = function createOrganization(_ref) {
1129
1129
  var appNameInLowerCase = appName.toLowerCase();
1130
1130
  var isNeetoAuth = appNameInLowerCase === "neetoauth";
1131
1131
  if (isNeetoAuth) cy.visit("https://app.neetoauth.".concat(env.tld, "/signups/new"));else {
1132
- var startingUrl = "https://www.neeto.com/".concat(appNameInLowerCase).concat(env.isProduction ? "?env=staging" : "");
1132
+ var startingUrl = "https://www.neeto.com/".concat(appNameInLowerCase).concat(env.isProduction ? "" : "?env=staging");
1133
1133
  cy.visit(startingUrl);
1134
1134
  cy.get(signUpSelectors.tryFreeButton).invoke("removeAttr", "target").click();
1135
1135
  }