@testspectra/react 1.2.8 → 1.2.10

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.js CHANGED
@@ -1,6 +1,29 @@
1
1
  // src/dom_driver_bridge.ts
2
2
  import { userEvent } from "@testing-library/user-event";
3
3
 
4
+ // ../../core/worker-runtime/src/dsl/keyboard.ts
5
+ var SPECIAL_KEYS = {
6
+ Backspace: { code: "Backspace", windowsVirtualKeyCode: 8 },
7
+ Tab: { code: "Tab", windowsVirtualKeyCode: 9 },
8
+ Enter: { code: "Enter", windowsVirtualKeyCode: 13, text: "\r" },
9
+ Escape: { code: "Escape", windowsVirtualKeyCode: 27 },
10
+ Delete: { code: "Delete", windowsVirtualKeyCode: 46 },
11
+ ArrowLeft: { code: "ArrowLeft", windowsVirtualKeyCode: 37 },
12
+ ArrowUp: { code: "ArrowUp", windowsVirtualKeyCode: 38 },
13
+ ArrowRight: { code: "ArrowRight", windowsVirtualKeyCode: 39 },
14
+ ArrowDown: { code: "ArrowDown", windowsVirtualKeyCode: 40 },
15
+ Home: { code: "Home", windowsVirtualKeyCode: 36 },
16
+ End: { code: "End", windowsVirtualKeyCode: 35 },
17
+ PageUp: { code: "PageUp", windowsVirtualKeyCode: 33 },
18
+ PageDown: { code: "PageDown", windowsVirtualKeyCode: 34 }
19
+ };
20
+ function describePressKey(input) {
21
+ if (typeof input !== "string") return null;
22
+ const special = SPECIAL_KEYS[input];
23
+ if (special) return { key: input, ...special };
24
+ return null;
25
+ }
26
+
4
27
  // ../../core/worker-runtime/src/dsl/mock_intercept.ts
5
28
  function matchesUrlPattern(pattern, url) {
6
29
  if (!pattern || pattern === "*" || pattern === "**" || pattern === "ALL") {
@@ -815,6 +838,11 @@ var DomDriverBridge = class {
815
838
  }
816
839
  // ─── Gestures & Keys ─────────────────────────────────────────────────────
817
840
  async pressKey(key) {
841
+ const desc = describePressKey(key);
842
+ if (desc?.code) {
843
+ await getUser().keyboard(`{${desc.code}}`);
844
+ return;
845
+ }
818
846
  const active = document.activeElement || document.body;
819
847
  const keyName = String(key);
820
848
  active.dispatchEvent(new KeyboardEvent("keydown", { key: keyName, bubbles: true }));