@testid/antd-testid-runtime 1.0.4 → 1.0.5
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 +21 -18
- package/dist/index.mjs +21 -18
- package/package.json +1 -1
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,21 @@ 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
|
-
popconfirm: "
|
|
192
|
-
dropdown: "
|
|
193
|
-
tooltip: "
|
|
187
|
+
modal: ["-modal"],
|
|
188
|
+
drawer: ["-drawer"],
|
|
189
|
+
select: ["-select-dropdown"],
|
|
190
|
+
datePicker: ["-picker-dropdown"],
|
|
191
|
+
popconfirm: ["-popover", "-popconfirm"],
|
|
192
|
+
dropdown: ["-dropdown"],
|
|
193
|
+
tooltip: ["-tooltip"]
|
|
194
194
|
};
|
|
195
|
-
function buildPopupClassMap(
|
|
195
|
+
function buildPopupClassMap(prefixes) {
|
|
196
196
|
const result = {};
|
|
197
197
|
const entries = Object.entries(POPUP_CLASS_SUFFIX_MAP);
|
|
198
|
-
for (const [type,
|
|
199
|
-
result[type] =
|
|
198
|
+
for (const [type, suffixClasses] of entries) {
|
|
199
|
+
result[type] = prefixes.map(
|
|
200
|
+
(prefix) => suffixClasses.map((suffix) => `${prefix}${suffix}`)
|
|
201
|
+
);
|
|
200
202
|
}
|
|
201
203
|
return result;
|
|
202
204
|
}
|
|
@@ -449,18 +451,19 @@ var TestIdObserver = class {
|
|
|
449
451
|
}
|
|
450
452
|
/**
|
|
451
453
|
* 检测节点 class 是否匹配某个浮层类型
|
|
454
|
+
*
|
|
455
|
+
* 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
|
|
452
456
|
*/
|
|
453
457
|
matchPopupClass(node) {
|
|
454
458
|
const classStr = node.className || "";
|
|
455
459
|
if (typeof classStr !== "string") return null;
|
|
460
|
+
const classList = classStr.split(/\s+/);
|
|
456
461
|
const entries = Object.entries(this.popupClassMap);
|
|
457
|
-
for (const [type,
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
if (allMatch) {
|
|
463
|
-
return type;
|
|
462
|
+
for (const [type, selectorSets] of entries) {
|
|
463
|
+
for (const requiredClasses of selectorSets) {
|
|
464
|
+
if (requiredClasses.every((cls) => classList.includes(cls))) {
|
|
465
|
+
return type;
|
|
466
|
+
}
|
|
464
467
|
}
|
|
465
468
|
}
|
|
466
469
|
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,21 @@ 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
|
-
popconfirm: "
|
|
150
|
-
dropdown: "
|
|
151
|
-
tooltip: "
|
|
145
|
+
modal: ["-modal"],
|
|
146
|
+
drawer: ["-drawer"],
|
|
147
|
+
select: ["-select-dropdown"],
|
|
148
|
+
datePicker: ["-picker-dropdown"],
|
|
149
|
+
popconfirm: ["-popover", "-popconfirm"],
|
|
150
|
+
dropdown: ["-dropdown"],
|
|
151
|
+
tooltip: ["-tooltip"]
|
|
152
152
|
};
|
|
153
|
-
function buildPopupClassMap(
|
|
153
|
+
function buildPopupClassMap(prefixes) {
|
|
154
154
|
const result = {};
|
|
155
155
|
const entries = Object.entries(POPUP_CLASS_SUFFIX_MAP);
|
|
156
|
-
for (const [type,
|
|
157
|
-
result[type] =
|
|
156
|
+
for (const [type, suffixClasses] of entries) {
|
|
157
|
+
result[type] = prefixes.map(
|
|
158
|
+
(prefix) => suffixClasses.map((suffix) => `${prefix}${suffix}`)
|
|
159
|
+
);
|
|
158
160
|
}
|
|
159
161
|
return result;
|
|
160
162
|
}
|
|
@@ -407,18 +409,19 @@ var TestIdObserver = class {
|
|
|
407
409
|
}
|
|
408
410
|
/**
|
|
409
411
|
* 检测节点 class 是否匹配某个浮层类型
|
|
412
|
+
*
|
|
413
|
+
* 遍历 popupClassMap 中的所有 class 组合,任一组合全部命中即匹配。
|
|
410
414
|
*/
|
|
411
415
|
matchPopupClass(node) {
|
|
412
416
|
const classStr = node.className || "";
|
|
413
417
|
if (typeof classStr !== "string") return null;
|
|
418
|
+
const classList = classStr.split(/\s+/);
|
|
414
419
|
const entries = Object.entries(this.popupClassMap);
|
|
415
|
-
for (const [type,
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
if (allMatch) {
|
|
421
|
-
return type;
|
|
420
|
+
for (const [type, selectorSets] of entries) {
|
|
421
|
+
for (const requiredClasses of selectorSets) {
|
|
422
|
+
if (requiredClasses.every((cls) => classList.includes(cls))) {
|
|
423
|
+
return type;
|
|
424
|
+
}
|
|
422
425
|
}
|
|
423
426
|
}
|
|
424
427
|
return null;
|