vite-plugin-vue-testid 1.1.2 → 1.1.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.
@@ -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;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"}
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;AAosB7D;;;;;;;;;;;;;;;;;;;;;;;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
@@ -355,6 +355,23 @@ function findActiveTrigger(attrName, pc) {
355
355
  return null;
356
356
  }
357
357
  function injectSubElements(root, attrName, pc) {
358
+ const inputWrapperSelectors = [
359
+ sel(pc, "input-affix-wrapper"),
360
+ sel(pc, "input-search"),
361
+ sel(pc, "input-textarea")
362
+ ];
363
+ for (const wrapperSel of inputWrapperSelectors) {
364
+ const wrappers = root.matches(`${wrapperSel}[${attrName}]`) ? [root] : Array.from(root.querySelectorAll(`${wrapperSel}[${attrName}]`));
365
+ for (const wrapper of wrappers) {
366
+ if (!(wrapper instanceof HTMLElement)) continue;
367
+ const testId = getAttrCompat(wrapper, attrName) || "";
368
+ if (!testId) continue;
369
+ const innerInput = wrapper.querySelector('input:not([type="file"]), textarea');
370
+ if (innerInput && !hasAttrCompat(innerInput, attrName)) {
371
+ innerInput.setAttribute(attrName, `${testId}-input`);
372
+ }
373
+ }
374
+ }
358
375
  const inputNumbers = root.matches(`${sel(pc, "input-number")}[${attrName}]`) ? [root] : Array.from(root.querySelectorAll(`${sel(pc, "input-number")}[${attrName}]`));
359
376
  for (const wrapper of inputNumbers) {
360
377
  if (!(wrapper instanceof HTMLElement)) continue;
@@ -397,6 +414,22 @@ function injectSubElements(root, attrName, pc) {
397
414
  }
398
415
  });
399
416
  }
417
+ const selects = root.matches(`${sel(pc, "select")}[${attrName}]`) ? [root] : Array.from(root.querySelectorAll(`${sel(pc, "select")}[${attrName}]`));
418
+ for (const select of selects) {
419
+ if (!(select instanceof HTMLElement)) continue;
420
+ const testId = getAttrCompat(select, attrName) || "";
421
+ if (!testId) continue;
422
+ const removeIcons = select.querySelectorAll(sel(pc, "select-selection-item-remove"));
423
+ removeIcons.forEach((icon) => {
424
+ const el = icon;
425
+ if (hasAttrCompat(el, attrName)) return;
426
+ const item = el.closest(sel(pc, "select-selection-item"));
427
+ const text = (item?.textContent || "").replace(el.textContent || "", "").trim().replace(/\s+/g, "-");
428
+ if (text) {
429
+ el.setAttribute(attrName, `${testId}-item-remove-${text}`);
430
+ }
431
+ });
432
+ }
400
433
  const uploadByTestId = root.matches(`${sel(pc, "upload")}[${attrName}]`) ? [root] : Array.from(root.querySelectorAll(`${sel(pc, "upload")}[${attrName}]`));
401
434
  const uploadById = uploadByTestId.length === 0 ? root.matches(`${sel(pc, "upload")}[id]`) ? [root] : Array.from(root.querySelectorAll(`${sel(pc, "upload")}[id]`)) : [];
402
435
  for (const upload of [...uploadByTestId, ...uploadById]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vue-testid",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Vite plugin to auto-inject data-testid into Vue component templates for E2E testing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",