@testid/antd-testid-runtime 1.0.2 → 1.0.3
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 +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +20 -9
- package/dist/index.mjs +20 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -30,6 +30,13 @@ interface TestIdMarkConfig {
|
|
|
30
30
|
runtimePagePrefix: string;
|
|
31
31
|
/** Antd 浮层组件专属前缀映射 */
|
|
32
32
|
popupPrefixMap: Record<PopupType, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Ant Design Vue CSS 类名前缀 (对应 ConfigProvider 的 prefixCls)
|
|
35
|
+
*
|
|
36
|
+
* 默认: 'ant' → 匹配 .ant-modal, .ant-picker-dropdown 等
|
|
37
|
+
* 若项目使用 <a-config-provider prefixCls="my-ui"> 则设为 'my-ui'
|
|
38
|
+
*/
|
|
39
|
+
antdClassPrefix: string;
|
|
33
40
|
/** 忽略不打标的 HTML 标签名 */
|
|
34
41
|
ignoreTags: string[];
|
|
35
42
|
/** 包含此 class 的 DOM 跳过打标 */
|
|
@@ -194,6 +201,8 @@ declare function buildPopupTestId(type: PopupType, tag: string, counterId: numbe
|
|
|
194
201
|
*/
|
|
195
202
|
declare class TestIdObserver {
|
|
196
203
|
private state;
|
|
204
|
+
/** 浮层 class 匹配映射 (根据 antdClassPrefix 动态构建) */
|
|
205
|
+
private popupClassMap;
|
|
197
206
|
constructor();
|
|
198
207
|
/**
|
|
199
208
|
* 启动 MutationObserver
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,13 @@ interface TestIdMarkConfig {
|
|
|
30
30
|
runtimePagePrefix: string;
|
|
31
31
|
/** Antd 浮层组件专属前缀映射 */
|
|
32
32
|
popupPrefixMap: Record<PopupType, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Ant Design Vue CSS 类名前缀 (对应 ConfigProvider 的 prefixCls)
|
|
35
|
+
*
|
|
36
|
+
* 默认: 'ant' → 匹配 .ant-modal, .ant-picker-dropdown 等
|
|
37
|
+
* 若项目使用 <a-config-provider prefixCls="my-ui"> 则设为 'my-ui'
|
|
38
|
+
*/
|
|
39
|
+
antdClassPrefix: string;
|
|
33
40
|
/** 忽略不打标的 HTML 标签名 */
|
|
34
41
|
ignoreTags: string[];
|
|
35
42
|
/** 包含此 class 的 DOM 跳过打标 */
|
|
@@ -194,6 +201,8 @@ declare function buildPopupTestId(type: PopupType, tag: string, counterId: numbe
|
|
|
194
201
|
*/
|
|
195
202
|
declare class TestIdObserver {
|
|
196
203
|
private state;
|
|
204
|
+
/** 浮层 class 匹配映射 (根据 antdClassPrefix 动态构建) */
|
|
205
|
+
private popupClassMap;
|
|
197
206
|
constructor();
|
|
198
207
|
/**
|
|
199
208
|
* 启动 MutationObserver
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,7 @@ var defaultConfig = {
|
|
|
60
60
|
globalPrefix: "",
|
|
61
61
|
compilePrefix: "static_",
|
|
62
62
|
runtimePagePrefix: "dynamic_",
|
|
63
|
+
antdClassPrefix: "ant",
|
|
63
64
|
popupPrefixMap: {
|
|
64
65
|
modal: "modal_",
|
|
65
66
|
drawer: "drawer_",
|
|
@@ -181,15 +182,23 @@ function buildPopupTestId(type, tag, counterId) {
|
|
|
181
182
|
}
|
|
182
183
|
|
|
183
184
|
// src/utils/testIdObserver.ts
|
|
184
|
-
var
|
|
185
|
-
modal: ".
|
|
186
|
-
drawer: ".
|
|
187
|
-
select: ".
|
|
188
|
-
datePicker: ".
|
|
189
|
-
popconfirm: ".
|
|
190
|
-
dropdown: ".
|
|
191
|
-
tooltip: ".
|
|
185
|
+
var POPUP_CLASS_SUFFIX_MAP = {
|
|
186
|
+
modal: ".{prefix}-modal",
|
|
187
|
+
drawer: ".{prefix}-drawer",
|
|
188
|
+
select: ".{prefix}-select-dropdown",
|
|
189
|
+
datePicker: ".{prefix}-picker-dropdown",
|
|
190
|
+
popconfirm: ".{prefix}-popover.{prefix}-popconfirm",
|
|
191
|
+
dropdown: ".{prefix}-dropdown",
|
|
192
|
+
tooltip: ".{prefix}-tooltip"
|
|
192
193
|
};
|
|
194
|
+
function buildPopupClassMap(prefix) {
|
|
195
|
+
const result = {};
|
|
196
|
+
const entries = Object.entries(POPUP_CLASS_SUFFIX_MAP);
|
|
197
|
+
for (const [type, template] of entries) {
|
|
198
|
+
result[type] = template.replace(/\{prefix\}/g, prefix);
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
193
202
|
var TestIdObserver = class {
|
|
194
203
|
constructor() {
|
|
195
204
|
// ==========================================================
|
|
@@ -208,6 +217,8 @@ var TestIdObserver = class {
|
|
|
208
217
|
});
|
|
209
218
|
}
|
|
210
219
|
};
|
|
220
|
+
const config = getConfig();
|
|
221
|
+
this.popupClassMap = buildPopupClassMap(config.antdClassPrefix);
|
|
211
222
|
this.state = {
|
|
212
223
|
observer: null,
|
|
213
224
|
isRunning: false,
|
|
@@ -441,7 +452,7 @@ var TestIdObserver = class {
|
|
|
441
452
|
matchPopupClass(node) {
|
|
442
453
|
const classStr = node.className || "";
|
|
443
454
|
if (typeof classStr !== "string") return null;
|
|
444
|
-
const entries = Object.entries(
|
|
455
|
+
const entries = Object.entries(this.popupClassMap);
|
|
445
456
|
for (const [type, selector] of entries) {
|
|
446
457
|
const classes = selector.replace(/^\./, "").split(".");
|
|
447
458
|
const allMatch = classes.every(
|
package/dist/index.mjs
CHANGED
|
@@ -18,6 +18,7 @@ var defaultConfig = {
|
|
|
18
18
|
globalPrefix: "",
|
|
19
19
|
compilePrefix: "static_",
|
|
20
20
|
runtimePagePrefix: "dynamic_",
|
|
21
|
+
antdClassPrefix: "ant",
|
|
21
22
|
popupPrefixMap: {
|
|
22
23
|
modal: "modal_",
|
|
23
24
|
drawer: "drawer_",
|
|
@@ -139,15 +140,23 @@ function buildPopupTestId(type, tag, counterId) {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
// src/utils/testIdObserver.ts
|
|
142
|
-
var
|
|
143
|
-
modal: ".
|
|
144
|
-
drawer: ".
|
|
145
|
-
select: ".
|
|
146
|
-
datePicker: ".
|
|
147
|
-
popconfirm: ".
|
|
148
|
-
dropdown: ".
|
|
149
|
-
tooltip: ".
|
|
143
|
+
var POPUP_CLASS_SUFFIX_MAP = {
|
|
144
|
+
modal: ".{prefix}-modal",
|
|
145
|
+
drawer: ".{prefix}-drawer",
|
|
146
|
+
select: ".{prefix}-select-dropdown",
|
|
147
|
+
datePicker: ".{prefix}-picker-dropdown",
|
|
148
|
+
popconfirm: ".{prefix}-popover.{prefix}-popconfirm",
|
|
149
|
+
dropdown: ".{prefix}-dropdown",
|
|
150
|
+
tooltip: ".{prefix}-tooltip"
|
|
150
151
|
};
|
|
152
|
+
function buildPopupClassMap(prefix) {
|
|
153
|
+
const result = {};
|
|
154
|
+
const entries = Object.entries(POPUP_CLASS_SUFFIX_MAP);
|
|
155
|
+
for (const [type, template] of entries) {
|
|
156
|
+
result[type] = template.replace(/\{prefix\}/g, prefix);
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
151
160
|
var TestIdObserver = class {
|
|
152
161
|
constructor() {
|
|
153
162
|
// ==========================================================
|
|
@@ -166,6 +175,8 @@ var TestIdObserver = class {
|
|
|
166
175
|
});
|
|
167
176
|
}
|
|
168
177
|
};
|
|
178
|
+
const config = getConfig();
|
|
179
|
+
this.popupClassMap = buildPopupClassMap(config.antdClassPrefix);
|
|
169
180
|
this.state = {
|
|
170
181
|
observer: null,
|
|
171
182
|
isRunning: false,
|
|
@@ -399,7 +410,7 @@ var TestIdObserver = class {
|
|
|
399
410
|
matchPopupClass(node) {
|
|
400
411
|
const classStr = node.className || "";
|
|
401
412
|
if (typeof classStr !== "string") return null;
|
|
402
|
-
const entries = Object.entries(
|
|
413
|
+
const entries = Object.entries(this.popupClassMap);
|
|
403
414
|
for (const [type, selector] of entries) {
|
|
404
415
|
const classes = selector.replace(/^\./, "").split(".");
|
|
405
416
|
const allMatch = classes.every(
|