@salutejs/sdds-api-tests 0.7.1-next-sbcom.0 → 0.8.0-dev.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/package.json +17 -16
- package/script.mjs +43 -13
- package/src/components/Button/Button.api.test.tsx +28 -2
- package/src/components/Checkbox/Checkbox.api.test.tsx +1 -1
- package/src/components/Combobox/Combobox.api.test.tsx +409 -151
- package/src/components/InformationWrapper/InformationWrapper.api.test.tsx +171 -0
- package/src/components/Popover/Popover.api.test.tsx +172 -0
- package/src/components/Select/Select.api.test.tsx +2 -2
- package/src/components/Skeleton/Skeleton.api.test.tsx +220 -0
- package/src/components/TextField/TextField.api.test.tsx +1 -1
- package/src/components/Typography/Typography.api.test.tsx +1 -1
- package/tsconfig.json +1 -0
- package/tsconfig.typecheck.json +4 -0
- package/vitest.config.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salutejs/sdds-api-tests",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0-dev.0",
|
|
4
4
|
"description": "API tests for components",
|
|
5
5
|
"author": "Salute Frontend Team <salute.developers@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,22 +10,23 @@
|
|
|
10
10
|
"directory": "utils/api-tests"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "rm -rf tests && node script.mjs &&
|
|
13
|
+
"test": "rm -rf tests && node script.mjs && NODE_OPTIONS=--max-old-space-size=8192 tsc --noEmit -p ./tsconfig.typecheck.json"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@salutejs/plasma-b2c": "1.
|
|
17
|
-
"@salutejs/plasma-giga": "0.
|
|
18
|
-
"@salutejs/plasma-icons": "1.238.0-
|
|
19
|
-
"@salutejs/plasma-web": "1.
|
|
20
|
-
"@salutejs/sdds-bizcom": "0.
|
|
21
|
-
"@salutejs/sdds-cs": "0.
|
|
22
|
-
"@salutejs/sdds-dfa": "0.
|
|
23
|
-
"@salutejs/sdds-finai": "0.
|
|
24
|
-
"@salutejs/sdds-insol": "0.
|
|
25
|
-
"@salutejs/sdds-netology": "0.
|
|
26
|
-
"@salutejs/sdds-platform-ai": "0.
|
|
27
|
-
"@salutejs/sdds-scan": "0.
|
|
28
|
-
"@salutejs/sdds-serv": "0.
|
|
16
|
+
"@salutejs/plasma-b2c": "1.619.0-dev.0",
|
|
17
|
+
"@salutejs/plasma-giga": "0.346.0-dev.0",
|
|
18
|
+
"@salutejs/plasma-icons": "1.238.0-dev.0",
|
|
19
|
+
"@salutejs/plasma-web": "1.621.0-dev.0",
|
|
20
|
+
"@salutejs/sdds-bizcom": "0.351.0-dev.0",
|
|
21
|
+
"@salutejs/sdds-cs": "0.355.0-dev.0",
|
|
22
|
+
"@salutejs/sdds-dfa": "0.349.0-dev.0",
|
|
23
|
+
"@salutejs/sdds-finai": "0.342.0-dev.0",
|
|
24
|
+
"@salutejs/sdds-insol": "0.346.0-dev.0",
|
|
25
|
+
"@salutejs/sdds-netology": "0.350.0-dev.0",
|
|
26
|
+
"@salutejs/sdds-platform-ai": "0.350.0-dev.0",
|
|
27
|
+
"@salutejs/sdds-scan": "0.349.0-dev.0",
|
|
28
|
+
"@salutejs/sdds-serv": "0.350.0-dev.0",
|
|
29
|
+
"@types/node": "^25.9.1",
|
|
29
30
|
"@types/react": "18.0.28",
|
|
30
31
|
"@types/react-dom": "18.0.11",
|
|
31
32
|
"react": "18.2.0",
|
|
@@ -34,5 +35,5 @@
|
|
|
34
35
|
"publishConfig": {
|
|
35
36
|
"access": "public"
|
|
36
37
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "bc2c961568e44fb73f80cb9d379a6ffee4f72ded"
|
|
38
39
|
}
|
package/script.mjs
CHANGED
|
@@ -13,11 +13,11 @@ const config = {
|
|
|
13
13
|
libs: [
|
|
14
14
|
{
|
|
15
15
|
name: '@salutejs/plasma-b2c',
|
|
16
|
-
|
|
16
|
+
excludeComponents: ['TextField'],
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
name: '@salutejs/plasma-web',
|
|
20
|
-
|
|
20
|
+
excludeComponents: ['TextField'],
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
name: '@salutejs/plasma-giga',
|
|
@@ -27,9 +27,11 @@ const config = {
|
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
name: '@salutejs/sdds-cs',
|
|
30
|
+
excludeComponents: ['Select', 'InformationWrapper'],
|
|
30
31
|
},
|
|
31
32
|
{
|
|
32
33
|
name: '@salutejs/sdds-dfa',
|
|
34
|
+
excludeComponents: ['InformationWrapper'],
|
|
33
35
|
},
|
|
34
36
|
{
|
|
35
37
|
name: '@salutejs/sdds-finai',
|
|
@@ -50,7 +52,8 @@ const config = {
|
|
|
50
52
|
name: '@salutejs/sdds-serv',
|
|
51
53
|
},
|
|
52
54
|
],
|
|
53
|
-
|
|
55
|
+
includeComponents: [],
|
|
56
|
+
excludeComponents: [],
|
|
54
57
|
srcDir: 'src',
|
|
55
58
|
outDir: 'tests',
|
|
56
59
|
};
|
|
@@ -63,6 +66,29 @@ const config = {
|
|
|
63
66
|
});
|
|
64
67
|
}
|
|
65
68
|
|
|
69
|
+
function hasComponent(filePath, components) {
|
|
70
|
+
return components.some((component) => filePath.includes(`src/components/${component}`));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function shouldSkipComponent(filePath, { includeComponents, excludeComponents }) {
|
|
74
|
+
if (
|
|
75
|
+
Array.isArray(includeComponents) &&
|
|
76
|
+
includeComponents.length > 0 &&
|
|
77
|
+
!hasComponent(filePath, includeComponents)
|
|
78
|
+
) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return Array.isArray(excludeComponents) && hasComponent(filePath, excludeComponents);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function getComponentName(filePath) {
|
|
86
|
+
const pathParts = filePath.split(path.sep);
|
|
87
|
+
const componentsIndex = pathParts.indexOf('components');
|
|
88
|
+
|
|
89
|
+
return componentsIndex === -1 ? null : pathParts[componentsIndex + 1];
|
|
90
|
+
}
|
|
91
|
+
|
|
66
92
|
try {
|
|
67
93
|
const filename = fileURLToPath(import.meta.url);
|
|
68
94
|
const dirname = path.dirname(filename);
|
|
@@ -71,23 +97,19 @@ const config = {
|
|
|
71
97
|
const OUT_DIR = path.resolve(dirname, config.outDir);
|
|
72
98
|
|
|
73
99
|
const files = getFiles(SRC_DIR);
|
|
100
|
+
const checkedComponents = new Set();
|
|
101
|
+
let generatedFilesCount = 0;
|
|
74
102
|
|
|
75
103
|
files.forEach((filePath) => {
|
|
76
|
-
if (
|
|
77
|
-
Array.isArray(config.ignoreComponents) &&
|
|
78
|
-
config.ignoreComponents.some((component) => filePath.includes(`src/components/${component}`))
|
|
79
|
-
) {
|
|
104
|
+
if (shouldSkipComponent(filePath, config)) {
|
|
80
105
|
return;
|
|
81
106
|
}
|
|
82
107
|
|
|
83
108
|
const relPath = path.relative(SRC_DIR, filePath);
|
|
84
109
|
const originalContent = fs.readFileSync(filePath, 'utf8');
|
|
85
110
|
|
|
86
|
-
config.libs.forEach(({ name,
|
|
87
|
-
if (
|
|
88
|
-
Array.isArray(ignoreComponents) &&
|
|
89
|
-
ignoreComponents.some((component) => filePath.includes(`src/components/${component}`))
|
|
90
|
-
) {
|
|
111
|
+
config.libs.forEach(({ name, includeComponents, excludeComponents }) => {
|
|
112
|
+
if (shouldSkipComponent(filePath, { includeComponents, excludeComponents })) {
|
|
91
113
|
return;
|
|
92
114
|
}
|
|
93
115
|
|
|
@@ -98,10 +120,18 @@ const config = {
|
|
|
98
120
|
|
|
99
121
|
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
100
122
|
fs.writeFileSync(targetPath, transformedContent);
|
|
123
|
+
|
|
124
|
+
const componentName = getComponentName(filePath);
|
|
125
|
+
if (componentName) {
|
|
126
|
+
checkedComponents.add(componentName);
|
|
127
|
+
}
|
|
128
|
+
generatedFilesCount += 1;
|
|
101
129
|
});
|
|
102
130
|
});
|
|
103
131
|
|
|
104
|
-
console.log(
|
|
132
|
+
console.log(
|
|
133
|
+
`Файлы для тестов сгенерированы успешно. Компонентов для проверки: ${checkedComponents.size}. Сгенерировано файлов: ${generatedFilesCount}.`,
|
|
134
|
+
);
|
|
105
135
|
} catch (err) {
|
|
106
136
|
console.error('Ошибка генерации тестов: ', err);
|
|
107
137
|
process.exit(1);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { ComponentProps, ReactNode, CSSProperties, AriaRole } from 'react';
|
|
3
|
-
import { describe, it } from '
|
|
2
|
+
import type { ComponentProps, ReactNode, CSSProperties, AriaRole, FC } from 'react';
|
|
3
|
+
import { describe, it } from 'node:test';
|
|
4
4
|
import { expectTypeOf } from 'expect-type';
|
|
5
5
|
import { IconDownload } from '@salutejs/plasma-icons';
|
|
6
6
|
import { Button } from '@salutejs/plasma-b2c';
|
|
@@ -141,3 +141,29 @@ describe('Polymorphic (as prop)', () => {
|
|
|
141
141
|
expectTypeOf(<Button as="div" href="/link" target="_blank" />);
|
|
142
142
|
});
|
|
143
143
|
});
|
|
144
|
+
|
|
145
|
+
describe('ComponentProps', () => {
|
|
146
|
+
it('custom props', () => {
|
|
147
|
+
type CustomButtonProps = Omit<ButtonProps, 'view' | 'isLoading'>;
|
|
148
|
+
|
|
149
|
+
expectTypeOf<CustomButtonProps>({ text: 'text', onClick: () => {} });
|
|
150
|
+
expectTypeOf<CustomButtonProps>({ additionalContent: '', contentRight: '' });
|
|
151
|
+
|
|
152
|
+
// @ts-expect-error
|
|
153
|
+
expectTypeOf<CustomButtonProps>({ view: 'default' });
|
|
154
|
+
|
|
155
|
+
// @ts-expect-error
|
|
156
|
+
expectTypeOf<CustomButtonProps>({ isLoading: true });
|
|
157
|
+
|
|
158
|
+
const CustomButton: FC<CustomButtonProps> = () => <></>;
|
|
159
|
+
|
|
160
|
+
void (<CustomButton text="" />);
|
|
161
|
+
void (<CustomButton disabled />);
|
|
162
|
+
void (<CustomButton onClick={() => {}} />);
|
|
163
|
+
|
|
164
|
+
// @ts-expect-error
|
|
165
|
+
void (<CustomButton view="default" />);
|
|
166
|
+
// @ts-expect-error
|
|
167
|
+
void (<CustomButton isLoading />);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { ComponentProps, ReactNode, CSSProperties, AriaRole } from 'react';
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { describe, it } from '
|
|
4
|
+
import { describe, it } from 'node:test';
|
|
5
5
|
import { expectTypeOf } from 'expect-type';
|
|
6
6
|
import { Checkbox } from '@salutejs/plasma-b2c';
|
|
7
7
|
|