@testid/antd-testid-runtime 1.0.3 → 1.0.4
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 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +12 -9
- package/dist/index.mjs +12 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -176,11 +176,13 @@ declare function resetPopupCounter(type: PopupType): void;
|
|
|
176
176
|
*/
|
|
177
177
|
declare function getPopupCounterSnapshot(): Record<PopupType, number>;
|
|
178
178
|
/**
|
|
179
|
-
*
|
|
179
|
+
* 生成浮层根节点 testid
|
|
180
180
|
*
|
|
181
|
-
* 格式: ${
|
|
181
|
+
* 格式: ${runtimePagePrefix}${popupPrefix}${tag}_${counterId}
|
|
182
|
+
* 例: hall_dynamic_modal_div_0, hall_dynamic_select_div_2
|
|
182
183
|
*
|
|
183
|
-
*
|
|
184
|
+
* 浮层均为运行时注入,因此统一使用 runtimePagePrefix 作为前缀,
|
|
185
|
+
* 与页面内动态节点保持一致。
|
|
184
186
|
*
|
|
185
187
|
* @param type - 浮层类型
|
|
186
188
|
* @param tag - HTML 标签名 (简化后)
|
|
@@ -308,8 +310,10 @@ declare class TestIdObserver {
|
|
|
308
310
|
/**
|
|
309
311
|
* 处理浮层内部子节点 (Modal/Drawer/Dropdown 内的按钮、输入框等)
|
|
310
312
|
*
|
|
311
|
-
* ID 格式: ${
|
|
312
|
-
* 例:
|
|
313
|
+
* ID 格式: ${runtimePagePrefix}${popupPrefix}${tag}_${counter}
|
|
314
|
+
* 例: hall_dynamic_modal_button_0, hall_dynamic_select_div_2
|
|
315
|
+
*
|
|
316
|
+
* 浮层子元素均为运行时注入,统一使用 runtimePagePrefix 前缀。
|
|
313
317
|
*/
|
|
314
318
|
private handlePopupChildNode;
|
|
315
319
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -176,11 +176,13 @@ declare function resetPopupCounter(type: PopupType): void;
|
|
|
176
176
|
*/
|
|
177
177
|
declare function getPopupCounterSnapshot(): Record<PopupType, number>;
|
|
178
178
|
/**
|
|
179
|
-
*
|
|
179
|
+
* 生成浮层根节点 testid
|
|
180
180
|
*
|
|
181
|
-
* 格式: ${
|
|
181
|
+
* 格式: ${runtimePagePrefix}${popupPrefix}${tag}_${counterId}
|
|
182
|
+
* 例: hall_dynamic_modal_div_0, hall_dynamic_select_div_2
|
|
182
183
|
*
|
|
183
|
-
*
|
|
184
|
+
* 浮层均为运行时注入,因此统一使用 runtimePagePrefix 作为前缀,
|
|
185
|
+
* 与页面内动态节点保持一致。
|
|
184
186
|
*
|
|
185
187
|
* @param type - 浮层类型
|
|
186
188
|
* @param tag - HTML 标签名 (简化后)
|
|
@@ -308,8 +310,10 @@ declare class TestIdObserver {
|
|
|
308
310
|
/**
|
|
309
311
|
* 处理浮层内部子节点 (Modal/Drawer/Dropdown 内的按钮、输入框等)
|
|
310
312
|
*
|
|
311
|
-
* ID 格式: ${
|
|
312
|
-
* 例:
|
|
313
|
+
* ID 格式: ${runtimePagePrefix}${popupPrefix}${tag}_${counter}
|
|
314
|
+
* 例: hall_dynamic_modal_button_0, hall_dynamic_select_div_2
|
|
315
|
+
*
|
|
316
|
+
* 浮层子元素均为运行时注入,统一使用 runtimePagePrefix 前缀。
|
|
313
317
|
*/
|
|
314
318
|
private handlePopupChildNode;
|
|
315
319
|
/**
|
package/dist/index.js
CHANGED
|
@@ -101,9 +101,10 @@ function applyGlobalPrefix(cfg) {
|
|
|
101
101
|
...cfg,
|
|
102
102
|
compilePrefix: prepend(cfg.compilePrefix),
|
|
103
103
|
runtimePagePrefix: prepend(cfg.runtimePagePrefix),
|
|
104
|
-
popupPrefixMap
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
// 注意: popupPrefixMap 不拼接 globalPrefix
|
|
105
|
+
// 浮层 testid 格式为 ${runtimePagePrefix}${popupPrefixMap[type]}...,
|
|
106
|
+
// runtimePagePrefix 已携带 globalPrefix,避免重复
|
|
107
|
+
popupPrefixMap: { ...cfg.popupPrefixMap }
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
110
|
var globalConfig = { ...defaultConfig };
|
|
@@ -177,8 +178,8 @@ function getPopupCounterSnapshot() {
|
|
|
177
178
|
}
|
|
178
179
|
function buildPopupTestId(type, tag, counterId) {
|
|
179
180
|
const config = getConfig();
|
|
180
|
-
const
|
|
181
|
-
return `${
|
|
181
|
+
const popupPrefix = config.popupPrefixMap[type] || `${type}_`;
|
|
182
|
+
return `${config.runtimePagePrefix}${popupPrefix}${tag}_${counterId}`;
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
// src/utils/testIdObserver.ts
|
|
@@ -485,8 +486,10 @@ var TestIdObserver = class {
|
|
|
485
486
|
/**
|
|
486
487
|
* 处理浮层内部子节点 (Modal/Drawer/Dropdown 内的按钮、输入框等)
|
|
487
488
|
*
|
|
488
|
-
* ID 格式: ${
|
|
489
|
-
* 例:
|
|
489
|
+
* ID 格式: ${runtimePagePrefix}${popupPrefix}${tag}_${counter}
|
|
490
|
+
* 例: hall_dynamic_modal_button_0, hall_dynamic_select_div_2
|
|
491
|
+
*
|
|
492
|
+
* 浮层子元素均为运行时注入,统一使用 runtimePagePrefix 前缀。
|
|
490
493
|
*/
|
|
491
494
|
handlePopupChildNode(node, popupType, config) {
|
|
492
495
|
if (config.onlyInteractive && !this.isInteractive(node)) return;
|
|
@@ -494,8 +497,8 @@ var TestIdObserver = class {
|
|
|
494
497
|
const key = `${popupType}_${tag}`;
|
|
495
498
|
const current = this.state.popupChildCounter.get(key) ?? 0;
|
|
496
499
|
this.state.popupChildCounter.set(key, current + 1);
|
|
497
|
-
const
|
|
498
|
-
const testId = `${
|
|
500
|
+
const popupPrefix = config.popupPrefixMap[popupType] || `${popupType}_`;
|
|
501
|
+
const testId = `${config.runtimePagePrefix}${popupPrefix}${tag}_${current}`;
|
|
499
502
|
node.setAttribute("data-testid", testId);
|
|
500
503
|
}
|
|
501
504
|
// ==========================================================
|
package/dist/index.mjs
CHANGED
|
@@ -59,9 +59,10 @@ function applyGlobalPrefix(cfg) {
|
|
|
59
59
|
...cfg,
|
|
60
60
|
compilePrefix: prepend(cfg.compilePrefix),
|
|
61
61
|
runtimePagePrefix: prepend(cfg.runtimePagePrefix),
|
|
62
|
-
popupPrefixMap
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
// 注意: popupPrefixMap 不拼接 globalPrefix
|
|
63
|
+
// 浮层 testid 格式为 ${runtimePagePrefix}${popupPrefixMap[type]}...,
|
|
64
|
+
// runtimePagePrefix 已携带 globalPrefix,避免重复
|
|
65
|
+
popupPrefixMap: { ...cfg.popupPrefixMap }
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
var globalConfig = { ...defaultConfig };
|
|
@@ -135,8 +136,8 @@ function getPopupCounterSnapshot() {
|
|
|
135
136
|
}
|
|
136
137
|
function buildPopupTestId(type, tag, counterId) {
|
|
137
138
|
const config = getConfig();
|
|
138
|
-
const
|
|
139
|
-
return `${
|
|
139
|
+
const popupPrefix = config.popupPrefixMap[type] || `${type}_`;
|
|
140
|
+
return `${config.runtimePagePrefix}${popupPrefix}${tag}_${counterId}`;
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
// src/utils/testIdObserver.ts
|
|
@@ -443,8 +444,10 @@ var TestIdObserver = class {
|
|
|
443
444
|
/**
|
|
444
445
|
* 处理浮层内部子节点 (Modal/Drawer/Dropdown 内的按钮、输入框等)
|
|
445
446
|
*
|
|
446
|
-
* ID 格式: ${
|
|
447
|
-
* 例:
|
|
447
|
+
* ID 格式: ${runtimePagePrefix}${popupPrefix}${tag}_${counter}
|
|
448
|
+
* 例: hall_dynamic_modal_button_0, hall_dynamic_select_div_2
|
|
449
|
+
*
|
|
450
|
+
* 浮层子元素均为运行时注入,统一使用 runtimePagePrefix 前缀。
|
|
448
451
|
*/
|
|
449
452
|
handlePopupChildNode(node, popupType, config) {
|
|
450
453
|
if (config.onlyInteractive && !this.isInteractive(node)) return;
|
|
@@ -452,8 +455,8 @@ var TestIdObserver = class {
|
|
|
452
455
|
const key = `${popupType}_${tag}`;
|
|
453
456
|
const current = this.state.popupChildCounter.get(key) ?? 0;
|
|
454
457
|
this.state.popupChildCounter.set(key, current + 1);
|
|
455
|
-
const
|
|
456
|
-
const testId = `${
|
|
458
|
+
const popupPrefix = config.popupPrefixMap[popupType] || `${popupType}_`;
|
|
459
|
+
const testId = `${config.runtimePagePrefix}${popupPrefix}${tag}_${current}`;
|
|
457
460
|
node.setAttribute("data-testid", testId);
|
|
458
461
|
}
|
|
459
462
|
// ==========================================================
|