@testid/antd-testid-runtime 1.0.13 → 1.0.15

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 CHANGED
@@ -10,7 +10,7 @@
10
10
  /**
11
11
  * 支持的浮层类型
12
12
  */
13
- type PopupType = 'modal' | 'drawer' | 'select' | 'datePicker' | 'popconfirm' | 'dropdown' | 'tooltip' | 'message';
13
+ type PopupType = 'modal' | 'drawer' | 'select' | 'datePicker' | 'popconfirm' | 'popover' | 'dropdown' | 'tooltip' | 'message';
14
14
  /**
15
15
  * UI 库适配器接口
16
16
  *
@@ -294,7 +294,7 @@ declare class TestIdObserver {
294
294
  private tagPrefixPattern;
295
295
  constructor();
296
296
  /**
297
- * 启动 MutationObserver
297
+ * 启动 MutationObserver (自动执行全量扫描兜底)
298
298
  */
299
299
  start(): void;
300
300
  /**
@@ -429,6 +429,7 @@ declare class TestIdObserver {
429
429
  * - onclick 属性
430
430
  * - role="button" / role="checkbox" / role="radio" / role="switch"
431
431
  * - tabindex 属性
432
+ * - CSS class 匹配 UI 库交互组件 (如 ant-menu-item → 渲染为 <li>,tag 不匹配组件名)
432
433
  */
433
434
  private isInteractive;
434
435
  /**
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  /**
11
11
  * 支持的浮层类型
12
12
  */
13
- type PopupType = 'modal' | 'drawer' | 'select' | 'datePicker' | 'popconfirm' | 'dropdown' | 'tooltip' | 'message';
13
+ type PopupType = 'modal' | 'drawer' | 'select' | 'datePicker' | 'popconfirm' | 'popover' | 'dropdown' | 'tooltip' | 'message';
14
14
  /**
15
15
  * UI 库适配器接口
16
16
  *
@@ -294,7 +294,7 @@ declare class TestIdObserver {
294
294
  private tagPrefixPattern;
295
295
  constructor();
296
296
  /**
297
- * 启动 MutationObserver
297
+ * 启动 MutationObserver (自动执行全量扫描兜底)
298
298
  */
299
299
  start(): void;
300
300
  /**
@@ -429,6 +429,7 @@ declare class TestIdObserver {
429
429
  * - onclick 属性
430
430
  * - role="button" / role="checkbox" / role="radio" / role="switch"
431
431
  * - tabindex 属性
432
+ * - CSS class 匹配 UI 库交互组件 (如 ant-menu-item → 渲染为 <li>,tag 不匹配组件名)
432
433
  */
433
434
  private isInteractive;
434
435
  /**
package/dist/index.js CHANGED
@@ -70,6 +70,7 @@ var popupClassSuffixMap = {
70
70
  // Ant Design Vue 1.x
71
71
  ],
72
72
  popconfirm: [["-popover", "-popconfirm"]],
73
+ popover: [["-popover"]],
73
74
  dropdown: [["-dropdown"]],
74
75
  tooltip: [["-tooltip"]],
75
76
  message: [["-message"]]
@@ -90,7 +91,14 @@ var antdAdapter = {
90
91
  "a-textarea",
91
92
  "a-checkbox",
92
93
  "a-radio",
93
- "a-switch"
94
+ "a-switch",
95
+ "a-menu-item",
96
+ "a-dropdown-button",
97
+ "a-tabs-tab-pane",
98
+ "a-table",
99
+ "a-tag",
100
+ "a-card",
101
+ "a-collapse-panel"
94
102
  ],
95
103
  tagPrefixPattern: /^a-/
96
104
  };
@@ -108,6 +116,7 @@ var defaultConfig = {
108
116
  select: "select_",
109
117
  datePicker: "datePicker_",
110
118
  popconfirm: "popconfirm_",
119
+ popover: "popover_",
111
120
  dropdown: "dropdown_",
112
121
  tooltip: "tooltip_",
113
122
  message: "message_"
@@ -175,13 +184,9 @@ var popupClassSuffixMap2 = {
175
184
  ["-popconfirm"]
176
185
  // Element Popconfirm
177
186
  ],
187
+ popover: [["-popover"]],
178
188
  dropdown: [["-dropdown-menu"]],
179
- tooltip: [
180
- ["-tooltip__popper"],
181
- // Element Tooltip 浮层
182
- ["-popover"]
183
- // Element Popover 浮层 (语义上接近 tooltip)
184
- ],
189
+ tooltip: [["-tooltip__popper"]],
185
190
  message: [["-message"]]
186
191
  };
187
192
  var elementAdapter = {
@@ -225,9 +230,16 @@ function getAnchorCounterMap() {
225
230
  }
226
231
  function parseBaseKey(baseKey) {
227
232
  const match = baseKey.match(
228
- /^common_comp_(.+?)_tag_(.+?)_(\d+)$/
233
+ /^common_comp_(.+?)_tag_(.+)_(\d+)$/
229
234
  );
230
- if (!match) return null;
235
+ if (!match) {
236
+ console.warn(
237
+ "[antd-testid-runtime] parseBaseKey \u5931\u8D25\uFF0CbaseKey \u683C\u5F0F\u4E0D\u5339\u914D:",
238
+ baseKey,
239
+ "\u671F\u671B\u683C\u5F0F: common_comp_{componentName}_tag_{tagName}_{index}"
240
+ );
241
+ return null;
242
+ }
231
243
  return {
232
244
  componentName: match[1],
233
245
  tagName: match[2],
@@ -245,6 +257,7 @@ var popupCounters = {
245
257
  select: 0,
246
258
  datePicker: 0,
247
259
  popconfirm: 0,
260
+ popover: 0,
248
261
  dropdown: 0,
249
262
  tooltip: 0,
250
263
  message: 0
@@ -351,7 +364,7 @@ var TestIdObserver = class {
351
364
  // 生命周期
352
365
  // ==========================================================
353
366
  /**
354
- * 启动 MutationObserver
367
+ * 启动 MutationObserver (自动执行全量扫描兜底)
355
368
  */
356
369
  start() {
357
370
  if (this.state.isRunning) return;
@@ -366,6 +379,7 @@ var TestIdObserver = class {
366
379
  // 监听所有后代节点
367
380
  });
368
381
  this.state.isRunning = true;
382
+ this.fullScan();
369
383
  }
370
384
  /**
371
385
  * 停止 Observer
@@ -661,6 +675,7 @@ var TestIdObserver = class {
661
675
  * - onclick 属性
662
676
  * - role="button" / role="checkbox" / role="radio" / role="switch"
663
677
  * - tabindex 属性
678
+ * - CSS class 匹配 UI 库交互组件 (如 ant-menu-item → 渲染为 <li>,tag 不匹配组件名)
664
679
  */
665
680
  isInteractive(node) {
666
681
  const tag = node.tagName.toLowerCase();
@@ -671,6 +686,15 @@ var TestIdObserver = class {
671
686
  return true;
672
687
  }
673
688
  if (node.hasAttribute("tabindex")) return true;
689
+ const classStr = node.className;
690
+ if (typeof classStr === "string") {
691
+ if (/\bant-(?:menu-item|dropdown-menu-item|select-item|tabs-tab|picker-cell|breadcrumb-link)\b/.test(classStr)) {
692
+ return true;
693
+ }
694
+ if (/\bel-(?:menu-item|dropdown-menu__item|select-dropdown__item|tabs__item)\b/.test(classStr)) {
695
+ return true;
696
+ }
697
+ }
674
698
  return false;
675
699
  }
676
700
  /**
@@ -699,6 +723,7 @@ var GROUP_LABELS = {
699
723
  select: "[Select \u6D6E\u5C42]",
700
724
  datePicker: "[DatePicker \u6D6E\u5C42]",
701
725
  popconfirm: "[Popconfirm \u6D6E\u5C42]",
726
+ popover: "[Popover \u6D6E\u5C42]",
702
727
  dropdown: "[Dropdown \u6D6E\u5C42]",
703
728
  tooltip: "[Tooltip \u6D6E\u5C42]",
704
729
  message: "[Message \u6D6E\u5C42]"
@@ -712,6 +737,7 @@ var GROUP_SUGGESTIONS = {
712
737
  select: "Select \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
713
738
  datePicker: "DatePicker \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
714
739
  popconfirm: "Popconfirm \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
740
+ popover: "Popover \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
715
741
  dropdown: "Dropdown \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
716
742
  tooltip: "Tooltip \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
717
743
  message: "Message \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548"
@@ -810,6 +836,7 @@ var TestIdChecker = class {
810
836
  "select",
811
837
  "datePicker",
812
838
  "popconfirm",
839
+ "popover",
813
840
  "dropdown",
814
841
  "tooltip",
815
842
  "message"
package/dist/index.mjs CHANGED
@@ -30,6 +30,7 @@ var popupClassSuffixMap = {
30
30
  // Ant Design Vue 1.x
31
31
  ],
32
32
  popconfirm: [["-popover", "-popconfirm"]],
33
+ popover: [["-popover"]],
33
34
  dropdown: [["-dropdown"]],
34
35
  tooltip: [["-tooltip"]],
35
36
  message: [["-message"]]
@@ -50,7 +51,14 @@ var antdAdapter = {
50
51
  "a-textarea",
51
52
  "a-checkbox",
52
53
  "a-radio",
53
- "a-switch"
54
+ "a-switch",
55
+ "a-menu-item",
56
+ "a-dropdown-button",
57
+ "a-tabs-tab-pane",
58
+ "a-table",
59
+ "a-tag",
60
+ "a-card",
61
+ "a-collapse-panel"
54
62
  ],
55
63
  tagPrefixPattern: /^a-/
56
64
  };
@@ -68,6 +76,7 @@ var defaultConfig = {
68
76
  select: "select_",
69
77
  datePicker: "datePicker_",
70
78
  popconfirm: "popconfirm_",
79
+ popover: "popover_",
71
80
  dropdown: "dropdown_",
72
81
  tooltip: "tooltip_",
73
82
  message: "message_"
@@ -135,13 +144,9 @@ var popupClassSuffixMap2 = {
135
144
  ["-popconfirm"]
136
145
  // Element Popconfirm
137
146
  ],
147
+ popover: [["-popover"]],
138
148
  dropdown: [["-dropdown-menu"]],
139
- tooltip: [
140
- ["-tooltip__popper"],
141
- // Element Tooltip 浮层
142
- ["-popover"]
143
- // Element Popover 浮层 (语义上接近 tooltip)
144
- ],
149
+ tooltip: [["-tooltip__popper"]],
145
150
  message: [["-message"]]
146
151
  };
147
152
  var elementAdapter = {
@@ -185,9 +190,16 @@ function getAnchorCounterMap() {
185
190
  }
186
191
  function parseBaseKey(baseKey) {
187
192
  const match = baseKey.match(
188
- /^common_comp_(.+?)_tag_(.+?)_(\d+)$/
193
+ /^common_comp_(.+?)_tag_(.+)_(\d+)$/
189
194
  );
190
- if (!match) return null;
195
+ if (!match) {
196
+ console.warn(
197
+ "[antd-testid-runtime] parseBaseKey \u5931\u8D25\uFF0CbaseKey \u683C\u5F0F\u4E0D\u5339\u914D:",
198
+ baseKey,
199
+ "\u671F\u671B\u683C\u5F0F: common_comp_{componentName}_tag_{tagName}_{index}"
200
+ );
201
+ return null;
202
+ }
191
203
  return {
192
204
  componentName: match[1],
193
205
  tagName: match[2],
@@ -205,6 +217,7 @@ var popupCounters = {
205
217
  select: 0,
206
218
  datePicker: 0,
207
219
  popconfirm: 0,
220
+ popover: 0,
208
221
  dropdown: 0,
209
222
  tooltip: 0,
210
223
  message: 0
@@ -311,7 +324,7 @@ var TestIdObserver = class {
311
324
  // 生命周期
312
325
  // ==========================================================
313
326
  /**
314
- * 启动 MutationObserver
327
+ * 启动 MutationObserver (自动执行全量扫描兜底)
315
328
  */
316
329
  start() {
317
330
  if (this.state.isRunning) return;
@@ -326,6 +339,7 @@ var TestIdObserver = class {
326
339
  // 监听所有后代节点
327
340
  });
328
341
  this.state.isRunning = true;
342
+ this.fullScan();
329
343
  }
330
344
  /**
331
345
  * 停止 Observer
@@ -621,6 +635,7 @@ var TestIdObserver = class {
621
635
  * - onclick 属性
622
636
  * - role="button" / role="checkbox" / role="radio" / role="switch"
623
637
  * - tabindex 属性
638
+ * - CSS class 匹配 UI 库交互组件 (如 ant-menu-item → 渲染为 <li>,tag 不匹配组件名)
624
639
  */
625
640
  isInteractive(node) {
626
641
  const tag = node.tagName.toLowerCase();
@@ -631,6 +646,15 @@ var TestIdObserver = class {
631
646
  return true;
632
647
  }
633
648
  if (node.hasAttribute("tabindex")) return true;
649
+ const classStr = node.className;
650
+ if (typeof classStr === "string") {
651
+ if (/\bant-(?:menu-item|dropdown-menu-item|select-item|tabs-tab|picker-cell|breadcrumb-link)\b/.test(classStr)) {
652
+ return true;
653
+ }
654
+ if (/\bel-(?:menu-item|dropdown-menu__item|select-dropdown__item|tabs__item)\b/.test(classStr)) {
655
+ return true;
656
+ }
657
+ }
634
658
  return false;
635
659
  }
636
660
  /**
@@ -659,6 +683,7 @@ var GROUP_LABELS = {
659
683
  select: "[Select \u6D6E\u5C42]",
660
684
  datePicker: "[DatePicker \u6D6E\u5C42]",
661
685
  popconfirm: "[Popconfirm \u6D6E\u5C42]",
686
+ popover: "[Popover \u6D6E\u5C42]",
662
687
  dropdown: "[Dropdown \u6D6E\u5C42]",
663
688
  tooltip: "[Tooltip \u6D6E\u5C42]",
664
689
  message: "[Message \u6D6E\u5C42]"
@@ -672,6 +697,7 @@ var GROUP_SUGGESTIONS = {
672
697
  select: "Select \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
673
698
  datePicker: "DatePicker \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
674
699
  popconfirm: "Popconfirm \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
700
+ popover: "Popover \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
675
701
  dropdown: "Dropdown \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
676
702
  tooltip: "Tooltip \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548",
677
703
  message: "Message \u72EC\u7ACB\u8BA1\u6570\u5668\u81EA\u589E\u903B\u8F91\u5931\u6548"
@@ -770,6 +796,7 @@ var TestIdChecker = class {
770
796
  "select",
771
797
  "datePicker",
772
798
  "popconfirm",
799
+ "popover",
773
800
  "dropdown",
774
801
  "tooltip",
775
802
  "message"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testid/antd-testid-runtime",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "运行时兜底打标模块 — MutationObserver + 锚点计数器 + 浮层计数器 + ID 重复检测",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",