@salutejs/plasma-cy-utils 0.140.0-canary.2334.19467659794.0 → 0.140.0-canary.2340.19568512004.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.
@@ -17,6 +17,7 @@ var themes_2 = require("@salutejs/plasma-tokens/themes");
17
17
  var themes_3 = require("@salutejs/plasma-tokens-b2c/themes");
18
18
  var plasma_typo_1 = require("@salutejs/plasma-typo");
19
19
  var SSRProvider_1 = require("./SSRProvider");
20
+ var NormalizeCSSDecorator_1 = require("./NormalizeCSSDecorator");
20
21
  // NOTE: new theme format
21
22
  var ThemeGIGA = (0, styled_components_1.createGlobalStyle)(plasma_themes_1.plasma_giga__light);
22
23
  var ThemeCS = (0, styled_components_1.createGlobalStyle)(sdds_themes_1.sdds_cs__light);
@@ -83,12 +84,14 @@ var CypressTestDecorator = function (_a) {
83
84
  }
84
85
  if (pkgName === 'plasma-web') {
85
86
  return (react_1.default.createElement(SSRProvider_1.SSRProvider, { noSSR: noSSR },
87
+ react_1.default.createElement(NormalizeCSSDecorator_1.NormalizeCSSDecorator, null),
86
88
  react_1.default.createElement(TypoThemeStyle, null),
87
89
  react_1.default.createElement(WebLightThemeStyle, null),
88
90
  children));
89
91
  }
90
92
  if (pkgName === 'plasma-b2c') {
91
93
  return (react_1.default.createElement(SSRProvider_1.SSRProvider, { noSSR: noSSR },
94
+ react_1.default.createElement(NormalizeCSSDecorator_1.NormalizeCSSDecorator, null),
92
95
  react_1.default.createElement(StandardTypoStyle, null),
93
96
  react_1.default.createElement(CompatibleTypoStyle, null),
94
97
  react_1.default.createElement(ColorB2CStyle, null),
@@ -96,6 +99,7 @@ var CypressTestDecorator = function (_a) {
96
99
  }
97
100
  if (['plasma-giga', 'sdds-cs', 'sdds-insol'].includes(pkgName)) {
98
101
  return (react_1.default.createElement(SSRProvider_1.SSRProvider, { noSSR: noSSR },
102
+ react_1.default.createElement(NormalizeCSSDecorator_1.NormalizeCSSDecorator, null),
99
103
  testPackagesThemes[pkgName],
100
104
  children));
101
105
  }
@@ -1,14 +1,19 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.mountLegacyMode = exports.mount = void 0;
4
- var react_1 = require("@cypress/react");
7
+ var react_1 = __importDefault(require("react"));
8
+ var react_2 = require("@cypress/react");
9
+ var CypressDecorator_1 = require("./CypressDecorator");
5
10
  var mount = function () {
6
11
  var args = [];
7
12
  for (var _i = 0; _i < arguments.length; _i++) {
8
13
  args[_i] = arguments[_i];
9
14
  }
10
15
  var jsx = args[0], _a = args[1], opts = _a === void 0 ? {} : _a;
11
- return (0, react_1.mount)(jsx, opts);
16
+ return (0, react_2.mount)(react_1.default.createElement(CypressDecorator_1.CypressTestDecorator, null, jsx), opts);
12
17
  };
13
18
  exports.mount = mount;
14
19
  // INFO: для временного использования в plasma-ui
@@ -19,7 +24,7 @@ var mountLegacyMode = function () {
19
24
  }
20
25
  var jsx = args[0], _a = args[1], opts = _a === void 0 ? {} : _a;
21
26
  opts.stylesheets = ((opts === null || opts === void 0 ? void 0 : opts.stylesheets) || []).concat('https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansText.0.2.0.css', 'https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansDisplay.0.2.0.css');
22
- var cm = (0, react_1.mount)(jsx, opts);
27
+ var cm = (0, react_2.mount)(jsx, opts);
23
28
  cy.waitForResources('https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansText.0.2.0.css');
24
29
  cy.waitForResources('https://cdn-app.sberdevices.ru/shared-static/0.0.0/styles/SBSansDisplay.0.2.0.css');
25
30
  cy.waitForResources('SBSansText.0.2.0.css', 'SBSansDisplay.0.2.0.css', { timeout: 1500 });
@@ -0,0 +1 @@
1
+ export declare const NormalizeCSSDecorator: import("styled-components").GlobalStyleComponent<{}, import("styled-components").DefaultTheme>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.NormalizeCSSDecorator = void 0;
8
+ var styled_components_1 = require("styled-components");
9
+ /* stylelint-disable selector-max-universal */
10
+ exports.NormalizeCSSDecorator = (0, styled_components_1.createGlobalStyle)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n html {\n box-sizing: border-box;\n }\n\n *,\n ::before,\n ::after {\n box-sizing: border-box;\n }\n"], ["\n html {\n box-sizing: border-box;\n }\n\n *,\n ::before,\n ::after {\n box-sizing: border-box;\n }\n"])));
11
+ var templateObject_1;
12
+ /* stylelint-enable selector-max-universal */
@@ -9,8 +9,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.withNoAnimation = exports.SpaceMe = exports.PadMe = void 0;
11
11
  var styled_components_1 = __importDefault(require("styled-components"));
12
- exports.PadMe = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 5px;\n"], ["\n padding: 5px;\n"])));
13
- exports.SpaceMe = styled_components_1.default.span(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 5px;\n"], ["\n padding: 5px;\n"])));
12
+ exports.PadMe = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: 5px;\n box-sizing: content-box;\n"], ["\n padding: 5px;\n box-sizing: content-box;\n"])));
13
+ exports.SpaceMe = styled_components_1.default.span(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 5px;\n box-sizing: content-box;\n"], ["\n padding: 5px;\n box-sizing: content-box;\n"])));
14
14
  var withNoAnimation = function (Comp) {
15
15
  return (0, styled_components_1.default)(Comp)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n animation: none !important;\n /* stylelint-disable-next-line selector-max-universal */\n & * {\n animation: none !important;\n }\n "], ["\n animation: none !important;\n /* stylelint-disable-next-line selector-max-universal */\n & * {\n animation: none !important;\n }\n "])));
16
16
  };
@@ -0,0 +1,5 @@
1
+ type GetConfigMatrixReturn = {
2
+ [key: string]: string;
3
+ };
4
+ export declare const getConfigMatrix: <T = {}>(config: T, options?: string[]) => GetConfigMatrixReturn[];
5
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-nocheck
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.getConfigMatrix = void 0;
6
+ var getConfigMatrix = function (config, options) {
7
+ var variations = config.variations;
8
+ // Find the prop with the most values
9
+ var maxLength = Object.values(variations).reduce(function (max, values) { return Math.max(max, Object.keys(values).length); }, 0);
10
+ if (maxLength === 0)
11
+ return [];
12
+ return Array.from({ length: maxLength }, function (_, i) {
13
+ return Object.keys(variations).reduce(function (props, propName) {
14
+ if ((options === null || options === void 0 ? void 0 : options.length) && !options.includes(propName)) {
15
+ return props;
16
+ }
17
+ var propValues = Object.keys(variations[propName]);
18
+ if (propValues.length === 1) {
19
+ if (i === 0) {
20
+ // eslint-disable-next-line prefer-destructuring
21
+ props[propName] = propValues[0];
22
+ }
23
+ }
24
+ else if (i < propValues.length) {
25
+ props[propName] = propValues[i];
26
+ }
27
+ return props;
28
+ }, {});
29
+ });
30
+ };
31
+ exports.getConfigMatrix = getConfigMatrix;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ type GetBaseVisualTestsArgs = {
3
+ config: any;
4
+ component: string;
5
+ configPropsForMatrix?: string[];
6
+ children?: ReactNode;
7
+ testCaseIds?: string[];
8
+ };
9
+ export declare const getBaseVisualTests: ({ testCaseIds, config, component, children, configPropsForMatrix, }: GetBaseVisualTestsArgs) => Mocha.Suite;
10
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getBaseVisualTests = void 0;
18
+ var react_1 = __importDefault(require("react"));
19
+ var CypressHelpers_1 = require("./CypressHelpers");
20
+ var CypressDecorator_1 = require("./CypressDecorator");
21
+ var getConfigMatrix_1 = require("./getConfigMatrix");
22
+ var getBaseVisualTests = function (_a) {
23
+ var testCaseIds = _a.testCaseIds, config = _a.config, component = _a.component, children = _a.children, configPropsForMatrix = _a.configPropsForMatrix;
24
+ return describe("plasma-new-hope: ".concat(component), function () {
25
+ var Component = (0, CypressDecorator_1.getComponent)(component);
26
+ var configMatrix = (0, getConfigMatrix_1.getConfigMatrix)(config, configPropsForMatrix);
27
+ configMatrix.forEach(function (combination, ind) {
28
+ var testId = (testCaseIds === null || testCaseIds === void 0 ? void 0 : testCaseIds.at(ind)) ? "".concat(testCaseIds === null || testCaseIds === void 0 ? void 0 : testCaseIds.at(ind), " ") : '';
29
+ var testParams = Object.entries(combination)
30
+ .map(function (_a) {
31
+ var propName = _a[0], propValue = _a[1];
32
+ return "".concat(propName, "=").concat(propValue);
33
+ })
34
+ .join(', ');
35
+ it("".concat(testId).concat(component, " ").concat(testParams), function () {
36
+ (0, CypressHelpers_1.mount)(react_1.default.createElement(react_1.default.Fragment, null, children ? react_1.default.createElement(Component, __assign({}, combination), children) : react_1.default.createElement(Component, __assign({}, combination))));
37
+ // @ts-ignore
38
+ cy.matchImageSnapshot();
39
+ });
40
+ });
41
+ });
42
+ };
43
+ exports.getBaseVisualTests = getBaseVisualTests;
package/lib/index.d.ts CHANGED
@@ -3,3 +3,5 @@ export * from './SSRProvider';
3
3
  export * from './StyleHelpers';
4
4
  export * from './CypressDecorator';
5
5
  export * from './CypressHelpers';
6
+ export * from './getConfigMatrix';
7
+ export * from './getTests';
package/lib/index.js CHANGED
@@ -19,3 +19,5 @@ __exportStar(require("./SSRProvider"), exports);
19
19
  __exportStar(require("./StyleHelpers"), exports);
20
20
  __exportStar(require("./CypressDecorator"), exports);
21
21
  __exportStar(require("./CypressHelpers"), exports);
22
+ __exportStar(require("./getConfigMatrix"), exports);
23
+ __exportStar(require("./getTests"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salutejs/plasma-cy-utils",
3
- "version": "0.140.0-canary.2334.19467659794.0",
3
+ "version": "0.140.0-canary.2340.19568512004.0",
4
4
  "description": "Test helpers shared between ui libraries.",
5
5
  "author": "Salute Frontend Team <salute.developers@gmail.com>",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@cypress/react": "5.12.0",
28
28
  "@salutejs/plasma-themes": "0.38.0",
29
- "@salutejs/plasma-tokens": "1.124.0-canary.2334.19467659794.0",
29
+ "@salutejs/plasma-tokens": "1.123.0",
30
30
  "@salutejs/plasma-tokens-b2b": "1.54.0",
31
31
  "@salutejs/plasma-tokens-b2c": "0.65.0",
32
32
  "@salutejs/plasma-tokens-web": "1.69.0",
@@ -48,5 +48,5 @@
48
48
  "files": [
49
49
  "lib"
50
50
  ],
51
- "gitHead": "76ae3ec385e94214f453fa2503a4117f1afd86da"
51
+ "gitHead": "a69c02bc0f3808eca5049c59cf6c68af69e60a06"
52
52
  }