vite-plugin-vue-testid 1.1.0 → 1.1.1
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/runtime.d.ts.map +1 -1
- package/dist/runtime.js +40 -1
- package/package.json +1 -1
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEnC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC,CAAA;CACzD;AAED,MAAM,WAAW,YAAY;IAC3B,kBAAkB;IAClB,SAAS,EAAE,WAAW,CAAA;IACtB,iBAAiB;IACjB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,oBAAoB;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEnC;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,CAAC,CAAA;CACzD;AAED,MAAM,WAAW,YAAY;IAC3B,kBAAkB;IAClB,SAAS,EAAE,WAAW,CAAA;IACtB,iBAAiB;IACjB,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;IAC3B,oBAAoB;IACpB,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAA;AAqpB7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,eAAe,CAAC,IAAI,GAAE,cAAmB,GAAG,MAAM,IAAI,CAgFrE;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,wBAAkB,CAAA;AAMtD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,GAAE,cAAmB,GAAG,IAAI,CAmCtE"}
|
package/dist/runtime.js
CHANGED
|
@@ -30,6 +30,8 @@ function buildComponentMatchers(pc) {
|
|
|
30
30
|
{ selector: sel(pc, "modal-wrap"), prefix: "a-modal", withId: true },
|
|
31
31
|
// ── 菜单 ──
|
|
32
32
|
{ selector: sel(pc, "menu"), prefix: "a-menu" },
|
|
33
|
+
// ── 标签页 ──
|
|
34
|
+
{ selector: sel(pc, "tabs"), prefix: "a-tabs" },
|
|
33
35
|
// ── 纯 input / textarea(必须排在最后)──
|
|
34
36
|
{ selector: `input.${cls(pc, "input")}`, prefix: "a-input" },
|
|
35
37
|
{ selector: `textarea.${cls(pc, "input")}`, prefix: "a-textarea" }
|
|
@@ -360,7 +362,7 @@ function injectSubElements(root, attrName, pc) {
|
|
|
360
362
|
if (!testId) continue;
|
|
361
363
|
const input = wrapper.querySelector(sel(pc, "input-number-input"));
|
|
362
364
|
if (input && !hasAttrCompat(input, attrName)) {
|
|
363
|
-
input.setAttribute(attrName, testId);
|
|
365
|
+
input.setAttribute(attrName, `${testId}-input`);
|
|
364
366
|
}
|
|
365
367
|
const upHandler = wrapper.querySelector(sel(pc, "input-number-handler-up"));
|
|
366
368
|
if (upHandler && !hasAttrCompat(upHandler, attrName)) {
|
|
@@ -410,6 +412,41 @@ function injectSubElements(root, attrName, pc) {
|
|
|
410
412
|
}
|
|
411
413
|
}
|
|
412
414
|
}
|
|
415
|
+
function injectTabsSubElements(root, attrName, pc) {
|
|
416
|
+
const tabsContainers = root.matches(`${sel(pc, "tabs")}[${attrName}]`) ? [root] : Array.from(root.querySelectorAll(`${sel(pc, "tabs")}[${attrName}]`));
|
|
417
|
+
for (const tabs of tabsContainers) {
|
|
418
|
+
if (!(tabs instanceof HTMLElement)) continue;
|
|
419
|
+
const testId = getAttrCompat(tabs, attrName) || "";
|
|
420
|
+
if (!testId) continue;
|
|
421
|
+
const tabItems = tabs.querySelectorAll(sel(pc, "tabs-tab"));
|
|
422
|
+
tabItems.forEach((tab, i) => {
|
|
423
|
+
const el = tab;
|
|
424
|
+
if (hasAttrCompat(el, attrName)) return;
|
|
425
|
+
const btn = el.querySelector(sel(pc, "tabs-tab-btn"));
|
|
426
|
+
const text = (btn?.textContent || el.textContent || "").trim().replace(/\s+/g, "-");
|
|
427
|
+
el.setAttribute(attrName, `${testId}-tab-${i}-${text}`);
|
|
428
|
+
});
|
|
429
|
+
const panes = tabs.querySelectorAll(sel(pc, "tabs-tabpane"));
|
|
430
|
+
panes.forEach((pane, i) => {
|
|
431
|
+
const el = pane;
|
|
432
|
+
if (hasAttrCompat(el, attrName)) return;
|
|
433
|
+
const tabBtn = tabItems[i]?.querySelector(sel(pc, "tabs-tab-btn"));
|
|
434
|
+
const text = (tabBtn?.textContent || "").trim().replace(/\s+/g, "-");
|
|
435
|
+
el.setAttribute(attrName, `${testId}-pane-${i}-${text}`);
|
|
436
|
+
});
|
|
437
|
+
const navOps = tabs.querySelector(sel(pc, "tabs-nav-operations"));
|
|
438
|
+
if (navOps instanceof HTMLElement) {
|
|
439
|
+
const addBtn = navOps.querySelector(sel(pc, "tabs-nav-add"));
|
|
440
|
+
if (addBtn instanceof HTMLElement && !hasAttrCompat(addBtn, attrName)) {
|
|
441
|
+
addBtn.setAttribute(attrName, `${testId}-add`);
|
|
442
|
+
}
|
|
443
|
+
const moreBtn = navOps.querySelector(sel(pc, "tabs-nav-more"));
|
|
444
|
+
if (moreBtn instanceof HTMLElement && !hasAttrCompat(moreBtn, attrName)) {
|
|
445
|
+
moreBtn.setAttribute(attrName, `${testId}-more`);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
413
450
|
function setupAntTestIds(opts = {}) {
|
|
414
451
|
const attrName = opts.attributeName ?? "data-testid";
|
|
415
452
|
const pc = opts.prefixCls ?? "ant";
|
|
@@ -436,6 +473,7 @@ function setupAntTestIds(opts = {}) {
|
|
|
436
473
|
}
|
|
437
474
|
}
|
|
438
475
|
injectSubElements(node, attrName, pc);
|
|
476
|
+
injectTabsSubElements(node, attrName, pc);
|
|
439
477
|
}
|
|
440
478
|
let pending = false;
|
|
441
479
|
let pendingNodes = [];
|
|
@@ -486,6 +524,7 @@ function injectCurrentDropdowns(opts = {}) {
|
|
|
486
524
|
});
|
|
487
525
|
}
|
|
488
526
|
injectSubElements(document.body, attrName, pc);
|
|
527
|
+
injectTabsSubElements(document.body, attrName, pc);
|
|
489
528
|
injectMenuItems(attrName, document, pc);
|
|
490
529
|
}
|
|
491
530
|
function mergeMatchers(defaults, customs) {
|