@bigbinary/neeto-commons-frontend 2.1.23 → 2.1.25

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/configs/babel.js CHANGED
@@ -35,6 +35,7 @@ module.exports = function (api) {
35
35
  "@bigbinary/neeto",
36
36
  ].filter(Boolean),
37
37
  plugins: [
38
+ "preval",
38
39
  "babel-plugin-macros",
39
40
  "@babel/plugin-transform-runtime",
40
41
  isTestEnv
@@ -9,5 +9,6 @@ module.exports = {
9
9
  module: "writable",
10
10
  // Makes props obtained from Rails backend available everywhere in this project.
11
11
  globalProps: "readonly",
12
+ preval: "readonly",
12
13
  },
13
14
  };
@@ -2,6 +2,12 @@ const { mergeLeft } = require("ramda");
2
2
 
3
3
  const commonConfiguration = require("../../eslint");
4
4
 
5
+ const isCommonsFrontend = !__dirname.includes("node_modules");
6
+
7
+ const configsPath = isCommonsFrontend
8
+ ? "./configs"
9
+ : "./node_modules/@bigbinary/neeto-commons-frontend/configs";
10
+
5
11
  const nanosConfiguration = {
6
12
  extends: [
7
13
  "plugin:@bigbinary/neeto/nanos-recommended",
@@ -9,12 +15,12 @@ const nanosConfiguration = {
9
15
  "plugin:json/recommended",
10
16
  "eslint:recommended",
11
17
  "plugin:react/recommended",
12
- "./node_modules/@bigbinary/neeto-commons-frontend/configs/eslint/globals",
13
- "./node_modules/@bigbinary/neeto-commons-frontend/configs/nanos/eslint/imports/order",
14
- "./node_modules/@bigbinary/neeto-commons-frontend/configs/eslint/overrides",
15
- "./node_modules/@bigbinary/neeto-commons-frontend/configs/eslint/imports/enforced",
16
- "./node_modules/@bigbinary/neeto-commons-frontend/configs/eslint/react",
17
- "./node_modules/@bigbinary/neeto-commons-frontend/configs/eslint/promise",
18
+ `${configsPath}/eslint/globals`,
19
+ `${configsPath}/nanos/eslint/imports/order`,
20
+ `${configsPath}/eslint/overrides`,
21
+ `${configsPath}/eslint/imports/enforced`,
22
+ `${configsPath}/eslint/react`,
23
+ `${configsPath}/eslint/promise`,
18
24
  "prettier",
19
25
  ],
20
26
  };
@@ -1,7 +1,11 @@
1
1
  const path = require("path");
2
2
 
3
+ const isCommonsFrontend = !__dirname.includes("node_modules");
4
+
3
5
  const absolutePath = basePath =>
4
- path.join(__dirname, "../../../../../../", basePath);
6
+ isCommonsFrontend
7
+ ? path.join(__dirname, "../../../", basePath)
8
+ : path.join(__dirname, "../../../../../../", basePath);
5
9
 
6
10
  module.exports = {
7
11
  alias: {
@@ -0,0 +1,38 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+
4
+ const { mergeDeepLeft } = require("ramda");
5
+
6
+ const packageDir = path.join(__dirname, "../");
7
+
8
+ const getPkgTransPath = pkg => path.join(packageDir, pkg, "src/translations");
9
+
10
+ const packages = fs.readdirSync(packageDir);
11
+
12
+ const loadTranslations = translationsDir => {
13
+ try {
14
+ const jsonFiles = fs
15
+ .readdirSync(translationsDir)
16
+ .filter(file => file.endsWith(".json"))
17
+ .map(file => path.join(translationsDir, file));
18
+
19
+ const translations = {};
20
+
21
+ jsonFiles.forEach(jsonFile => {
22
+ const content = fs.readFileSync(jsonFile, "utf8");
23
+ const basename = path.basename(jsonFile, ".json");
24
+
25
+ translations[basename] = { translation: JSON.parse(content) };
26
+ });
27
+
28
+ return translations;
29
+ } catch {
30
+ return {};
31
+ }
32
+ };
33
+
34
+ const packageTranslations = packages
35
+ .map(pkg => loadTranslations(getPkgTransPath(pkg)))
36
+ .reduce(mergeDeepLeft);
37
+
38
+ module.exports = packageTranslations;
@@ -4,9 +4,7 @@ module.exports = [
4
4
  use: [
5
5
  {
6
6
  loader: "@svgr/webpack",
7
- options: {
8
- svgoConfig: { plugins: ["preset-default"] },
9
- },
7
+ options: { svgoConfig: { plugins: ["preset-default"] } },
10
8
  },
11
9
  ],
12
10
  },
@@ -20,15 +18,16 @@ module.exports = [
20
18
  },
21
19
  },
22
20
  },
21
+ {
22
+ test: /\.js$/,
23
+ include: /node_modules\/@bigbinary\/neeto-commons-frontend\/initializers/,
24
+ use: { loader: "babel-loader", options: { plugins: ["preval"] } },
25
+ },
23
26
  {
24
27
  test: /\.m?js$/,
25
28
  resolve: {
26
29
  fullySpecified: false, // allows webpack to ignore some package rules as the Strict EcmaScript Module mode.
27
30
  },
28
31
  },
29
- {
30
- test: /\.js$/,
31
- enforce: "pre",
32
- use: ["source-map-loader"],
33
- },
32
+ { test: /\.js$/, enforce: "pre", use: ["source-map-loader"] },
34
33
  ];
@@ -195,7 +195,9 @@ var commonSelectors = {
195
195
  paneBody: ".neeto-ui-pane__body",
196
196
  paneHeader: ".neeto-ui-pane__header",
197
197
  profileSidebar: ".neeto-ui-profile-sidebar",
198
- selectOption: ".neeto-ui-react-select__option",
198
+ selectOption: function selectOption(label) {
199
+ return dataCy("".concat(joinHyphenCase(label), "-select-option"));
200
+ },
199
201
  toastMessage: dataCy("toastr-message-container"),
200
202
  toastCloseButton: ".neeto-ui-toastr__close-button",
201
203
  windowAlert: "#alert-box",
@@ -364,7 +366,7 @@ var initCustomCommands = function initCustomCommands() {
364
366
  });
365
367
  Cypress.Commands.add("selectOption", function (containerSelector, optionText) {
366
368
  cy.get(containerSelector).click().type(optionText);
367
- cy.contains(commonSelectors.selectOption, optionText).invoke("click");
369
+ cy.get(commonSelectors.selectOption(optionText.split("_").join("-").toLowerCase())).invoke("click");
368
370
  });
369
371
  Cypress.Commands.add("clickDropdownOption", function (optionText) {
370
372
  var dropdownSelector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : commonSelectors.dropdownIcon;
@@ -759,7 +761,8 @@ var uniqueDepartment = function uniqueDepartment() {
759
761
  max: 100
760
762
  });
761
763
  };
762
- var phoneNumber = function phoneNumber(format) {
764
+ var phoneNumber = function phoneNumber() {
765
+ var format = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "9#########";
763
766
  return faker.faker.phone.number(format);
764
767
  };
765
768
  var secureUrl = function secureUrl() {