@testid/antd-testid-runtime 1.0.4 → 1.0.6
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/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +26 -18
- package/dist/index.mjs +26 -18
- package/package.json +8 -2
package/dist/index.d.mts
CHANGED
|
@@ -33,10 +33,12 @@ interface TestIdMarkConfig {
|
|
|
33
33
|
/**
|
|
34
34
|
* Ant Design Vue CSS 类名前缀 (对应 ConfigProvider 的 prefixCls)
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* 支持数组,可同时匹配多个前缀体系:
|
|
37
|
+
* 默认: ['ant'] → 匹配 .ant-modal, .ant-picker-dropdown 等
|
|
38
|
+
* 若项目使用 <a-config-provider prefixCls="my-ui"> 则设为 ['my-ui']
|
|
39
|
+
* 混合使用: ['ant', 'my-ui'] → 同时匹配两个体系的所有浮层组件
|
|
38
40
|
*/
|
|
39
|
-
antdClassPrefix: string;
|
|
41
|
+
antdClassPrefix: string[];
|
|
40
42
|
/** 忽略不打标的 HTML 标签名 */
|
|
41
43
|
ignoreTags: string[];
|
|
42
44
|
/** 包含此 class 的 DOM 跳过打标 */
|
|
@@ -299,6 +301,8 @@ declare class TestIdObserver {
|
|
|
299
301
|
private reachesBody;
|
|
300
302
|
/**
|
|
301
303
|
* 检测节点 class 是否匹配某个浮层类型
|
|
304
|
+
*
|
|
305
|
+
* 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
|
|
302
306
|
*/
|
|
303
307
|
private matchPopupClass;
|
|
304
308
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -33,10 +33,12 @@ interface TestIdMarkConfig {
|
|
|
33
33
|
/**
|
|
34
34
|
* Ant Design Vue CSS 类名前缀 (对应 ConfigProvider 的 prefixCls)
|
|
35
35
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
36
|
+
* 支持数组,可同时匹配多个前缀体系:
|
|
37
|
+
* 默认: ['ant'] → 匹配 .ant-modal, .ant-picker-dropdown 等
|
|
38
|
+
* 若项目使用 <a-config-provider prefixCls="my-ui"> 则设为 ['my-ui']
|
|
39
|
+
* 混合使用: ['ant', 'my-ui'] → 同时匹配两个体系的所有浮层组件
|
|
38
40
|
*/
|
|
39
|
-
antdClassPrefix: string;
|
|
41
|
+
antdClassPrefix: string[];
|
|
40
42
|
/** 忽略不打标的 HTML 标签名 */
|
|
41
43
|
ignoreTags: string[];
|
|
42
44
|
/** 包含此 class 的 DOM 跳过打标 */
|
|
@@ -299,6 +301,8 @@ declare class TestIdObserver {
|
|
|
299
301
|
private reachesBody;
|
|
300
302
|
/**
|
|
301
303
|
* 检测节点 class 是否匹配某个浮层类型
|
|
304
|
+
*
|
|
305
|
+
* 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
|
|
302
306
|
*/
|
|
303
307
|
private matchPopupClass;
|
|
304
308
|
/**
|
package/dist/index.js
CHANGED
|
@@ -60,7 +60,7 @@ var defaultConfig = {
|
|
|
60
60
|
globalPrefix: "",
|
|
61
61
|
compilePrefix: "static_",
|
|
62
62
|
runtimePagePrefix: "dynamic_",
|
|
63
|
-
antdClassPrefix: "ant",
|
|
63
|
+
antdClassPrefix: ["ant"],
|
|
64
64
|
popupPrefixMap: {
|
|
65
65
|
modal: "modal_",
|
|
66
66
|
drawer: "drawer_",
|
|
@@ -184,19 +184,26 @@ function buildPopupTestId(type, tag, counterId) {
|
|
|
184
184
|
|
|
185
185
|
// src/utils/testIdObserver.ts
|
|
186
186
|
var POPUP_CLASS_SUFFIX_MAP = {
|
|
187
|
-
modal: "
|
|
188
|
-
drawer: "
|
|
189
|
-
select: "
|
|
190
|
-
datePicker:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
modal: ["-modal"],
|
|
188
|
+
drawer: ["-drawer"],
|
|
189
|
+
select: ["-select-dropdown"],
|
|
190
|
+
datePicker: [
|
|
191
|
+
"-picker-dropdown",
|
|
192
|
+
// Ant Design Vue 4.x (新)
|
|
193
|
+
"-calendar-picker-container"
|
|
194
|
+
// Ant Design Vue 1.x (旧)
|
|
195
|
+
],
|
|
196
|
+
popconfirm: ["-popover", "-popconfirm"],
|
|
197
|
+
dropdown: ["-dropdown"],
|
|
198
|
+
tooltip: ["-tooltip"]
|
|
194
199
|
};
|
|
195
|
-
function buildPopupClassMap(
|
|
200
|
+
function buildPopupClassMap(prefixes) {
|
|
196
201
|
const result = {};
|
|
197
202
|
const entries = Object.entries(POPUP_CLASS_SUFFIX_MAP);
|
|
198
|
-
for (const [type,
|
|
199
|
-
result[type] =
|
|
203
|
+
for (const [type, suffixClasses] of entries) {
|
|
204
|
+
result[type] = prefixes.map(
|
|
205
|
+
(prefix) => suffixClasses.map((suffix) => `${prefix}${suffix}`)
|
|
206
|
+
);
|
|
200
207
|
}
|
|
201
208
|
return result;
|
|
202
209
|
}
|
|
@@ -449,18 +456,19 @@ var TestIdObserver = class {
|
|
|
449
456
|
}
|
|
450
457
|
/**
|
|
451
458
|
* 检测节点 class 是否匹配某个浮层类型
|
|
459
|
+
*
|
|
460
|
+
* 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
|
|
452
461
|
*/
|
|
453
462
|
matchPopupClass(node) {
|
|
454
463
|
const classStr = node.className || "";
|
|
455
464
|
if (typeof classStr !== "string") return null;
|
|
465
|
+
const classList = classStr.split(/\s+/);
|
|
456
466
|
const entries = Object.entries(this.popupClassMap);
|
|
457
|
-
for (const [type,
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (allMatch) {
|
|
463
|
-
return type;
|
|
467
|
+
for (const [type, selectorSets] of entries) {
|
|
468
|
+
for (const requiredClasses of selectorSets) {
|
|
469
|
+
if (requiredClasses.every((cls) => classList.includes(cls))) {
|
|
470
|
+
return type;
|
|
471
|
+
}
|
|
464
472
|
}
|
|
465
473
|
}
|
|
466
474
|
return null;
|
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ var defaultConfig = {
|
|
|
18
18
|
globalPrefix: "",
|
|
19
19
|
compilePrefix: "static_",
|
|
20
20
|
runtimePagePrefix: "dynamic_",
|
|
21
|
-
antdClassPrefix: "ant",
|
|
21
|
+
antdClassPrefix: ["ant"],
|
|
22
22
|
popupPrefixMap: {
|
|
23
23
|
modal: "modal_",
|
|
24
24
|
drawer: "drawer_",
|
|
@@ -142,19 +142,26 @@ function buildPopupTestId(type, tag, counterId) {
|
|
|
142
142
|
|
|
143
143
|
// src/utils/testIdObserver.ts
|
|
144
144
|
var POPUP_CLASS_SUFFIX_MAP = {
|
|
145
|
-
modal: "
|
|
146
|
-
drawer: "
|
|
147
|
-
select: "
|
|
148
|
-
datePicker:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
145
|
+
modal: ["-modal"],
|
|
146
|
+
drawer: ["-drawer"],
|
|
147
|
+
select: ["-select-dropdown"],
|
|
148
|
+
datePicker: [
|
|
149
|
+
"-picker-dropdown",
|
|
150
|
+
// Ant Design Vue 4.x (新)
|
|
151
|
+
"-calendar-picker-container"
|
|
152
|
+
// Ant Design Vue 1.x (旧)
|
|
153
|
+
],
|
|
154
|
+
popconfirm: ["-popover", "-popconfirm"],
|
|
155
|
+
dropdown: ["-dropdown"],
|
|
156
|
+
tooltip: ["-tooltip"]
|
|
152
157
|
};
|
|
153
|
-
function buildPopupClassMap(
|
|
158
|
+
function buildPopupClassMap(prefixes) {
|
|
154
159
|
const result = {};
|
|
155
160
|
const entries = Object.entries(POPUP_CLASS_SUFFIX_MAP);
|
|
156
|
-
for (const [type,
|
|
157
|
-
result[type] =
|
|
161
|
+
for (const [type, suffixClasses] of entries) {
|
|
162
|
+
result[type] = prefixes.map(
|
|
163
|
+
(prefix) => suffixClasses.map((suffix) => `${prefix}${suffix}`)
|
|
164
|
+
);
|
|
158
165
|
}
|
|
159
166
|
return result;
|
|
160
167
|
}
|
|
@@ -407,18 +414,19 @@ var TestIdObserver = class {
|
|
|
407
414
|
}
|
|
408
415
|
/**
|
|
409
416
|
* 检测节点 class 是否匹配某个浮层类型
|
|
417
|
+
*
|
|
418
|
+
* 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
|
|
410
419
|
*/
|
|
411
420
|
matchPopupClass(node) {
|
|
412
421
|
const classStr = node.className || "";
|
|
413
422
|
if (typeof classStr !== "string") return null;
|
|
423
|
+
const classList = classStr.split(/\s+/);
|
|
414
424
|
const entries = Object.entries(this.popupClassMap);
|
|
415
|
-
for (const [type,
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (allMatch) {
|
|
421
|
-
return type;
|
|
425
|
+
for (const [type, selectorSets] of entries) {
|
|
426
|
+
for (const requiredClasses of selectorSets) {
|
|
427
|
+
if (requiredClasses.every((cls) => classList.includes(cls))) {
|
|
428
|
+
return type;
|
|
429
|
+
}
|
|
422
430
|
}
|
|
423
431
|
}
|
|
424
432
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testid/antd-testid-runtime",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "运行时兜底打标模块 — MutationObserver + 锚点计数器 + 浮层计数器 + ID 重复检测",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/testid/testid-plugins.git",
|
|
21
|
+
"directory": "packages/antd-testid-runtime"
|
|
22
|
+
},
|
|
23
|
+
|
|
18
24
|
"scripts": {
|
|
19
25
|
"build": "tsup src/index.ts --dts --format esm,cjs --clean",
|
|
20
26
|
"dev": "tsup src/index.ts --dts --format esm,cjs --watch"
|
|
@@ -24,4 +30,4 @@
|
|
|
24
30
|
"tsup": "^8.0.0",
|
|
25
31
|
"typescript": "^5.3.0"
|
|
26
32
|
}
|
|
27
|
-
}
|
|
33
|
+
}
|