@salutejs/plasma-cy-utils 0.141.0-canary.2339.19756860460.0 → 0.141.0-canary.2340.19759341192.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.
- package/lib/CypressDecorator.js +6 -19
- package/lib/CypressHelpers.js +8 -3
- package/lib/getConfigMatrix.d.ts +5 -0
- package/lib/getConfigMatrix.js +31 -0
- package/lib/getTests.d.ts +10 -0
- package/lib/getTests.js +43 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/package.json +2 -2
package/lib/CypressDecorator.js
CHANGED
|
@@ -14,8 +14,6 @@ var themes_1 = require("@salutejs/plasma-tokens-web/themes");
|
|
|
14
14
|
// plasma-ui
|
|
15
15
|
var themes_2 = require("@salutejs/plasma-tokens/themes");
|
|
16
16
|
// plasma-b2c
|
|
17
|
-
var themes_3 = require("@salutejs/plasma-tokens-b2c/themes");
|
|
18
|
-
var plasma_typo_1 = require("@salutejs/plasma-typo");
|
|
19
17
|
var SSRProvider_1 = require("./SSRProvider");
|
|
20
18
|
var NormalizeCSSDecorator_1 = require("./NormalizeCSSDecorator");
|
|
21
19
|
// NOTE: new theme format
|
|
@@ -25,9 +23,6 @@ var ThemeINSOL = (0, styled_components_1.createGlobalStyle)(sdds_themes_1.sdds_i
|
|
|
25
23
|
// TODO: better naming
|
|
26
24
|
var TypoThemeStyle = (0, styled_components_1.createGlobalStyle)(typo_1.web);
|
|
27
25
|
var WebLightThemeStyle = (0, styled_components_1.createGlobalStyle)(themes_1.light);
|
|
28
|
-
var StandardTypoStyle = (0, styled_components_1.createGlobalStyle)(plasma_typo_1.standard);
|
|
29
|
-
var CompatibleTypoStyle = (0, styled_components_1.createGlobalStyle)(plasma_typo_1.compatible);
|
|
30
|
-
var ColorB2CStyle = (0, styled_components_1.createGlobalStyle)(themes_3.dark);
|
|
31
26
|
var ThemeStyle = (0, styled_components_1.createGlobalStyle)(themes_2.darkSber);
|
|
32
27
|
var testPackagesThemes = {
|
|
33
28
|
'plasma-giga': react_1.default.createElement(ThemeGIGA, null),
|
|
@@ -46,19 +41,19 @@ var getComponent = function (componentName) {
|
|
|
46
41
|
pkg = require('../../../packages/plasma-ui');
|
|
47
42
|
break;
|
|
48
43
|
case 'plasma-web':
|
|
49
|
-
pkg = require('../../../packages/plasma-web
|
|
44
|
+
pkg = require('../../../packages/plasma-web');
|
|
50
45
|
break;
|
|
51
46
|
case 'plasma-b2c':
|
|
52
|
-
pkg = require('../../../packages/plasma-b2c
|
|
47
|
+
pkg = require('../../../packages/plasma-b2c');
|
|
53
48
|
break;
|
|
54
49
|
case 'plasma-giga':
|
|
55
|
-
pkg = require('../../../packages/plasma-giga
|
|
50
|
+
pkg = require('../../../packages/plasma-giga');
|
|
56
51
|
break;
|
|
57
52
|
case 'sdds-cs':
|
|
58
|
-
pkg = require('../../../packages/sdds-cs
|
|
53
|
+
pkg = require('../../../packages/sdds-cs');
|
|
59
54
|
break;
|
|
60
55
|
case 'sdds-insol':
|
|
61
|
-
pkg = require('../../../packages/sdds-insol
|
|
56
|
+
pkg = require('../../../packages/sdds-insol');
|
|
62
57
|
break;
|
|
63
58
|
default:
|
|
64
59
|
throw new Error("Library ".concat(pkgName, " is not required in plasma-core/CypressHelpers:getComponent"));
|
|
@@ -89,15 +84,7 @@ var CypressTestDecorator = function (_a) {
|
|
|
89
84
|
react_1.default.createElement(WebLightThemeStyle, null),
|
|
90
85
|
children));
|
|
91
86
|
}
|
|
92
|
-
if (
|
|
93
|
-
return (react_1.default.createElement(SSRProvider_1.SSRProvider, { noSSR: noSSR },
|
|
94
|
-
react_1.default.createElement(NormalizeCSSDecorator_1.NormalizeCSSDecorator, null),
|
|
95
|
-
react_1.default.createElement(StandardTypoStyle, null),
|
|
96
|
-
react_1.default.createElement(CompatibleTypoStyle, null),
|
|
97
|
-
react_1.default.createElement(ColorB2CStyle, null),
|
|
98
|
-
children));
|
|
99
|
-
}
|
|
100
|
-
if (['plasma-giga', 'sdds-cs', 'sdds-insol'].includes(pkgName)) {
|
|
87
|
+
if (['plasma-b2c', 'plasma-giga', 'sdds-cs', 'sdds-insol'].includes(pkgName)) {
|
|
101
88
|
return (react_1.default.createElement(SSRProvider_1.SSRProvider, { noSSR: noSSR },
|
|
102
89
|
react_1.default.createElement(NormalizeCSSDecorator_1.NormalizeCSSDecorator, null),
|
|
103
90
|
testPackagesThemes[pkgName],
|
package/lib/CypressHelpers.js
CHANGED
|
@@ -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("
|
|
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,
|
|
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,
|
|
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,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 {};
|
package/lib/getTests.js
ADDED
|
@@ -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
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.141.0-canary.
|
|
3
|
+
"version": "0.141.0-canary.2340.19759341192.0",
|
|
4
4
|
"description": "Test helpers shared between ui libraries.",
|
|
5
5
|
"author": "Salute Frontend Team <salute.developers@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"files": [
|
|
49
49
|
"lib"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "1bc3cc85d3493f530739d0b321a652f8e1ea8281"
|
|
52
52
|
}
|