@salutejs/plasma-cy-utils 0.140.0-dev.0 → 0.140.1-canary.2359.19825507435.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.
@@ -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,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-dev.0",
3
+ "version": "0.140.1-canary.2359.19825507435.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,12 +26,12 @@
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-dev.0",
29
+ "@salutejs/plasma-tokens": "1.124.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",
33
33
  "@salutejs/plasma-typo": "0.42.0",
34
- "@salutejs/sdds-themes": "0.49.0-dev.0",
34
+ "@salutejs/sdds-themes": "0.49.0",
35
35
  "@types/node": "18.16.20",
36
36
  "@types/react": "18.0.28",
37
37
  "@types/react-dom": "18.0.11",
@@ -48,5 +48,5 @@
48
48
  "files": [
49
49
  "lib"
50
50
  ],
51
- "gitHead": "66241361bde39c4824ffd06801a00d0f8023ce38"
51
+ "gitHead": "adc78a14dc336ff77a7993ce195384407fa17b55"
52
52
  }