@celestia-island/hikari 0.55.520 → 0.55.521

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.
@@ -25,6 +25,7 @@ import HkScrollProgressDock, {
25
25
  type HkScrollProgressRegistrar,
26
26
  } from "./HkScrollProgressDock";
27
27
  import { setLocale } from "../i18n/context";
28
+ import { __teardownMediaQueries } from "../runtime/useMediaQuery";
28
29
 
29
30
  const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
30
31
  const rects: Array<ReturnType<typeof vi.spyOn>> = [];
@@ -1103,6 +1104,478 @@ describe("HkCardList scroll-progress registration", () => {
1103
1104
  });
1104
1105
 
1105
1106
 
1107
+ // ── Jump surface (user direction 2026-11-30) ─────────────────────────
1108
+ // The pill is a real trigger now: hover/click opens a popover (mobile:
1109
+ // sheet) with the band, a scrub slider and a row field; the pill
1110
+ // captures its own clicks (no pass-through to the rows underneath).
1111
+ describe("HkScrollProgressDock jump surface", () => {
1112
+ /** Like mountScroller, but the viewport's scrollTop is SETTABLE (the
1113
+ * jump executor writes it — strict-mode assignment throws on a
1114
+ * getter-only override) and the helpers target the teleported
1115
+ * popover panel. Geometry stubs mirror stubRows/stubRootRect but
1116
+ * re-derive from the CURRENT scroll cell on every call. */
1117
+ function mountInteractive(rowsCount: number, total?: number) {
1118
+ let top = 0;
1119
+ let lastScrollTo: { top?: number; behavior?: string } | null = null;
1120
+ const List = makeList({ rows: rowsCount, total });
1121
+ const Wrapper = defineComponent({
1122
+ setup() {
1123
+ return () =>
1124
+ h(HkScrollContainer, {}, {
1125
+ default: () => h(HkScrollProgressDock, {}, { default: () => h(List) }),
1126
+ });
1127
+ },
1128
+ });
1129
+ const container = mountTree(h(Wrapper));
1130
+ const viewport = container.querySelector<HTMLElement>(".hk-scroll-container-viewport");
1131
+ if (!viewport) throw new Error("container did not render its viewport");
1132
+ Object.defineProperties(viewport, {
1133
+ scrollHeight: { configurable: true, get: () => 2000 },
1134
+ clientHeight: { configurable: true, get: () => 400 },
1135
+ scrollWidth: { configurable: true, get: () => 300 },
1136
+ clientWidth: { configurable: true, get: () => 300 },
1137
+ scrollLeft: { configurable: true, get: () => 0, set: () => {} },
1138
+ scrollTop: {
1139
+ configurable: true,
1140
+ get: () => top,
1141
+ set: (v: number) => {
1142
+ top = v;
1143
+ },
1144
+ },
1145
+ // The jump executor lands through `vp.scrollTo({ top })` (the
1146
+ // container's own jump shape); happy-dom's builtin is a no-op. The
1147
+ // last call's options are captured so tests can assert the
1148
+ // BEHAVIOR argument too (R4: `"instant"` had no pin — a dropped
1149
+ // behavior arg stayed green).
1150
+ scrollTo: {
1151
+ configurable: true,
1152
+ writable: true,
1153
+ value: (options: { top?: number; behavior?: string }) => {
1154
+ lastScrollTo = options;
1155
+ if (options && typeof options.top === "number") top = options.top;
1156
+ },
1157
+ },
1158
+ // The offset walk (layoutOffset) starts at the frame itself — pin
1159
+ // its layout position so `laidOffsetWithin(row, vp)` sums
1160
+ // deterministically instead of reading happy-dom defaults.
1161
+ offsetTop: { configurable: true, get: () => 0 },
1162
+ offsetLeft: { configurable: true, get: () => 0 },
1163
+ offsetParent: { configurable: true, get: () => null },
1164
+ });
1165
+ rects.push(vi.spyOn(viewport, "getBoundingClientRect").mockReturnValue({
1166
+ left: 0, top: 0, right: 300, bottom: 400, width: 300, height: 400, x: 0, y: 0,
1167
+ } as DOMRect));
1168
+ return {
1169
+ container,
1170
+ viewport,
1171
+ top: () => top,
1172
+ lastScrollTo: () => lastScrollTo,
1173
+ pill: () => {
1174
+ const pill = container.querySelector<HTMLElement>(".hk-scroll-progress-dock");
1175
+ if (!pill) throw new Error("pill missing");
1176
+ return pill;
1177
+ },
1178
+ panel: () => document.querySelector<HTMLElement>(".hk-scroll-progress-dock-jump"),
1179
+ dialog: () => document.querySelector<HTMLElement>(".hk-popover-panel"),
1180
+ field: () => document.querySelector<HTMLInputElement>(".hk-scroll-progress-dock-jump .hk-number-input-field"),
1181
+ go: () => document.querySelector<HTMLButtonElement>(".hk-scroll-progress-dock-jump .hk-btn"),
1182
+ slider: () => document.querySelector<HTMLElement>(".hk-scroll-progress-dock-jump .hk-slider"),
1183
+ /** 40px rows stacked from the content top; the registered root
1184
+ * (the list's wrapper div) spans the whole content. The offset
1185
+ * chain (row → viewport, layout space) rides the SAME numbers so
1186
+ * `laidOffsetWithin` — the jump executor's primary path — reads
1187
+ * the zoom-1 truth happy-dom's non-layout cannot produce. */
1188
+ stubGeometry(cur: number) {
1189
+ container.querySelectorAll<HTMLElement>("tr").forEach((row, i) => {
1190
+ const rtop = i * 40 - cur;
1191
+ rects.push(vi.spyOn(row, "getBoundingClientRect").mockReturnValue({
1192
+ left: 0, top: rtop, right: 100, bottom: rtop + 40, width: 100, height: 40, x: 0, y: rtop,
1193
+ } as DOMRect));
1194
+ Object.defineProperties(row, {
1195
+ offsetTop: { configurable: true, get: () => i * 40 },
1196
+ offsetLeft: { configurable: true, get: () => 0 },
1197
+ offsetParent: { configurable: true, get: () => viewport },
1198
+ });
1199
+ });
1200
+ const table = container.querySelector<HTMLElement>(".probe-table");
1201
+ if (!table) throw new Error("probe table missing");
1202
+ rects.push(vi.spyOn(table.parentElement!, "getBoundingClientRect").mockReturnValue({
1203
+ left: 0, top: -cur, right: 100, bottom: 2000 - cur, width: 100, height: 2000, x: 0, y: -cur,
1204
+ } as DOMRect));
1205
+ },
1206
+ /** The zoom split layoutGeometry documents: drawn boxes scale by
1207
+ * `k` (transforms/zoom), the offset chain does not. Rows drawn at
1208
+ * three× but LAID OUT at 40px — the jump must land by layout
1209
+ * math, so the drawn boxes are decoys.
1210
+ * MUT:zoom-naive (naive drawn-box math lands 1320 where 440 is
1211
+ * correct — replayed red by author and R3/R5). */
1212
+ stubGeometryZoomed(cur: number, k: number) {
1213
+ this.stubGeometry(cur);
1214
+ container.querySelectorAll<HTMLElement>("tr").forEach((row, i) => {
1215
+ const rtop = (i * 40 - cur) * k;
1216
+ rects.push(vi.spyOn(row, "getBoundingClientRect").mockReturnValue({
1217
+ left: 0, top: rtop, right: 100 * k, bottom: rtop + 40 * k, width: 100 * k, height: 40 * k, x: 0, y: rtop,
1218
+ } as DOMRect));
1219
+ });
1220
+ },
1221
+ async scrollPass() {
1222
+ viewport.dispatchEvent(new Event("scroll"));
1223
+ await flushSense();
1224
+ },
1225
+ async openByClick() {
1226
+ this.pill().click();
1227
+ await flushSense();
1228
+ },
1229
+ };
1230
+ }
1231
+
1232
+ it("is a real trigger: role, aria wiring, and it keeps its own clicks", async () => {
1233
+ const sc = mountInteractive(40, 340);
1234
+ sc.stubGeometry(0);
1235
+ await sc.scrollPass();
1236
+ const pill = sc.pill();
1237
+ expect(pill.getAttribute("role")).toBe("button");
1238
+ expect(pill.getAttribute("tabindex")).toBe("0");
1239
+ expect(pill.getAttribute("aria-haspopup")).toBe("dialog");
1240
+ expect(pill.getAttribute("aria-expanded")).toBe("false");
1241
+ expect(pill.getAttribute("aria-label")).toBe("Jump to row");
1242
+ // The old bug shape: the pill was pointer-events:none, so a click on
1243
+ // it LANDED on the row underneath (an app copy-toast fired from a
1244
+ // pill click). Two layers pin the fix: (a) the pill is a hit target
1245
+ // at all — the `pointer-events: auto` SCSS text pin (happy-dom does
1246
+ // not lay out, so that layer is textual); (b) the pill's own click
1247
+ // handler stops propagation, asserted here against the pill's
1248
+ // PARENT — the teleport HOST, the first ancestor a pill click can
1249
+ // actually reach (the row is never an ancestor of the teleported
1250
+ // pill, so a row-listener canary would be vacuous — R3 M4).
1251
+ // MUT:M4 (R3 replay: stopPropagation removed → this red)
1252
+ const host = pill.parentElement!;
1253
+ const hostClick = vi.fn();
1254
+ host.addEventListener("click", hostClick);
1255
+ pill.dispatchEvent(new MouseEvent("click", { bubbles: true }));
1256
+ await nextTick();
1257
+ expect(hostClick).not.toHaveBeenCalled();
1258
+ expect(pill.getAttribute("aria-expanded")).toBe("true");
1259
+ // The jump panel mounts in the overlay root (the popover's
1260
+ // teleport), never inside the list.
1261
+ // comment-gate-ok: placement is owned by HkPopover's own teleport
1262
+ // contract (its rootzoom/aboveChrome tests); this assert pins only
1263
+ // the dock-side containment, no dock mutation reaches it.
1264
+ expect(sc.panel()).not.toBeNull();
1265
+ expect(sc.container.contains(sc.panel()!)).toBe(false);
1266
+ host.removeEventListener("click", hostClick);
1267
+ });
1268
+
1269
+ it("does not open on a synthesized pointerenter without hover capability", async () => {
1270
+ // The touch contract: a touch pointer's synthesized pointerenter
1271
+ // must NOT open the panel — touch opens through click, which pins;
1272
+ // a hover-opened sheet would fight its own synthetic leave. NOTE:
1273
+ // happy-dom's matchMedia answers TRUE for every query, so the
1274
+ // touch-like environment must be stubbed explicitly, not assumed
1275
+ // (R3 M12: the negative side of this gate had no pin).
1276
+ __teardownMediaQueries();
1277
+ const mqlSpy = vi.spyOn(window, "matchMedia").mockImplementation((() => ({
1278
+ matches: false,
1279
+ addEventListener() {},
1280
+ removeEventListener() {},
1281
+ })) as unknown as typeof window.matchMedia);
1282
+ try {
1283
+ const sc = mountInteractive(40, 340);
1284
+ sc.stubGeometry(0);
1285
+ await sc.scrollPass();
1286
+ const pill = sc.pill();
1287
+ pill.dispatchEvent(new PointerEvent("pointerenter"));
1288
+ await nextTick();
1289
+ expect(pill.getAttribute("aria-expanded")).toBe("false");
1290
+ expect(sc.panel()).toBeNull();
1291
+ // The tap itself still opens (pinned): the touch open path.
1292
+ pill.click();
1293
+ await flushSense();
1294
+ expect(pill.getAttribute("aria-expanded")).toBe("true");
1295
+ } finally {
1296
+ __teardownMediaQueries();
1297
+ mqlSpy.mockRestore();
1298
+ }
1299
+ });
1300
+
1301
+ it("re-checks ownership when the band moves under an open unpinned panel", async () => {
1302
+ // R3 2026-11-30: a scroll / list reload can strand the pointer off
1303
+ // both surfaces without any enter/leave — the band watch re-arms
1304
+ // the ownership check so the surface does not linger ownerless.
1305
+ // MUT:M10b (R3: watch body voided → this red; replayed by author)
1306
+ __teardownMediaQueries();
1307
+ const mqlSpy = vi.spyOn(window, "matchMedia").mockImplementation(((query: string) => ({
1308
+ matches: query === "(hover: hover) and (pointer: fine)",
1309
+ addEventListener() {},
1310
+ removeEventListener() {},
1311
+ })) as unknown as typeof window.matchMedia);
1312
+ try {
1313
+ const sc = mountInteractive(40, 340);
1314
+ sc.stubGeometry(0);
1315
+ await sc.scrollPass();
1316
+ const pill = sc.pill();
1317
+ pill.dispatchEvent(new PointerEvent("pointerenter"));
1318
+ await nextTick();
1319
+ expect(pill.getAttribute("aria-expanded")).toBe("true");
1320
+ // The pointer travels into the panel (cancelling the open-edge
1321
+ // timer) and then content moves under it — no leave ever fires.
1322
+ sc.dialog()!.dispatchEvent(new MouseEvent("mouseenter"));
1323
+ sc.viewport.scrollTop = 400;
1324
+ sc.stubGeometry(400);
1325
+ await sc.scrollPass();
1326
+ await new Promise((resolve) => setTimeout(resolve, 220));
1327
+ expect(pill.getAttribute("aria-expanded")).toBe("false");
1328
+ } finally {
1329
+ __teardownMediaQueries();
1330
+ mqlSpy.mockRestore();
1331
+ }
1332
+ });
1333
+
1334
+ it("jumps via the row field + Go button and closes on commit", async () => {
1335
+ const sc = mountInteractive(40, 340);
1336
+ sc.stubGeometry(0);
1337
+ await sc.scrollPass();
1338
+ await sc.openByClick();
1339
+ const input = sc.field();
1340
+ expect(input).not.toBeNull();
1341
+ input!.value = "12";
1342
+ input!.dispatchEvent(new Event("input", { bubbles: true }));
1343
+ await nextTick();
1344
+ sc.go()!.click();
1345
+ await nextTick();
1346
+ // Row 12's top edge at the viewport top: scrollTop = (12-1)*40.
1347
+ expect(sc.top()).toBe(11 * 40);
1348
+ // The commit closes the surface so the destination is visible.
1349
+ expect(sc.pill().getAttribute("aria-expanded")).toBe("false");
1350
+ });
1351
+
1352
+ it("Enter in the panel commits the field value too", async () => {
1353
+ const sc = mountInteractive(40, 340);
1354
+ sc.stubGeometry(0);
1355
+ await sc.scrollPass();
1356
+ await sc.openByClick();
1357
+ sc.field()!.value = "7";
1358
+ sc.field()!.dispatchEvent(new Event("input", { bubbles: true }));
1359
+ await nextTick();
1360
+ sc.panel()!.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
1361
+ await nextTick();
1362
+ expect(sc.top()).toBe(6 * 40);
1363
+ expect(sc.pill().getAttribute("aria-expanded")).toBe("false");
1364
+ });
1365
+
1366
+ it("clamps the jump to the loaded rows (a declared total is not scrollable yet)", async () => {
1367
+ const sc = mountInteractive(40, 500);
1368
+ sc.stubGeometry(0);
1369
+ await sc.scrollPass();
1370
+ await sc.openByClick();
1371
+ sc.field()!.value = "400";
1372
+ sc.field()!.dispatchEvent(new Event("input", { bubbles: true }));
1373
+ await nextTick();
1374
+ sc.go()!.click();
1375
+ await nextTick();
1376
+ // Row 400 does not exist: the jump parks at the last loaded row.
1377
+ // MUT:M3 (R3: clamp removed → this red)
1378
+ expect(sc.top()).toBe(39 * 40);
1379
+ });
1380
+
1381
+ it("jumps in layout space: a drawn-box zoom must not scale the landing", async () => {
1382
+ // The wheel audit (2026-11-30): the drawn-box delta is `k` times too
1383
+ // large at root zoom `k` — the family's layoutGeometry doc states it
1384
+ // verbatim, and HkScrollContainer.scrollToElement targets the layout
1385
+ // offset for exactly this reason. Rows DRAWN at 3× but LAID OUT at
1386
+ // 40px: the landing must be the layout number (the drawn boxes are
1387
+ // decoys — the naive `scrollTop += drawn delta` writes 1320 here).
1388
+ const sc = mountInteractive(40, 340);
1389
+ sc.stubGeometryZoomed(0, 3);
1390
+ await sc.scrollPass();
1391
+ await sc.openByClick();
1392
+ sc.field()!.value = "12";
1393
+ sc.field()!.dispatchEvent(new Event("input", { bubbles: true }));
1394
+ await nextTick();
1395
+ sc.go()!.click();
1396
+ await nextTick();
1397
+ expect(sc.top()).toBe(11 * 40);
1398
+ // The landing is instant, not "auto": a bare dict falls back to the
1399
+ // used `scroll-behavior`, which a consumer stylesheet could set to
1400
+ // smooth — that would animate the scrub's every tick.
1401
+ expect(sc.lastScrollTo()?.behavior).toBe("instant");
1402
+ });
1403
+
1404
+ it("falls back to the drawn-box math when the offset chain cannot be summed", async () => {
1405
+ // An offset walk that cannot be summed (an undefined offset in the
1406
+ // chain — layoutGeometry's `<svg>` boundary analogue) must engage the
1407
+ // drawn-box fallback, not drop the jump. At zoom 1 the fallback lands
1408
+ // the same number the primary path would (R2 2026-11-30: this path
1409
+ // had no pin — a +999999 poison stayed green).
1410
+ const sc = mountInteractive(40, 340);
1411
+ // A non-zero starting offset makes the pin a FORMULA pin, not just a
1412
+ // branch pin (R4): at zoom 1 primary and fallback land identically,
1413
+ // but only the real drawn-box formula — current offset PLUS the
1414
+ // drawn delta — lands 440 from a 137 start. A fallback that ignores
1415
+ // the current offset (absolute rect.top) lands 303; the +999999
1416
+ // poison lands 1000576. Both mutants must read red here.
1417
+ sc.viewport.scrollTop = 137;
1418
+ sc.stubGeometry(137);
1419
+ sc.container.querySelectorAll<HTMLElement>("tr").forEach((row) => {
1420
+ Object.defineProperty(row, "offsetTop", { configurable: true, get: () => undefined });
1421
+ });
1422
+ await sc.scrollPass();
1423
+ await sc.openByClick();
1424
+ sc.field()!.value = "12";
1425
+ sc.field()!.dispatchEvent(new Event("input", { bubbles: true }));
1426
+ await nextTick();
1427
+ sc.go()!.click();
1428
+ await nextTick();
1429
+ expect(sc.top()).toBe(11 * 40);
1430
+ // MUT:fallback-nan (poisoning the fallback with +999999 → this red)
1431
+ });
1432
+
1433
+ it("jumps live while the slider scrubs and keeps the panel open", async () => {
1434
+ const sc = mountInteractive(40, 40);
1435
+ sc.stubGeometry(0);
1436
+ await sc.scrollPass();
1437
+ await sc.openByClick();
1438
+ const track = sc.slider();
1439
+ expect(track).not.toBeNull();
1440
+ rects.push(vi.spyOn(track!, "getBoundingClientRect").mockReturnValue({
1441
+ left: 0, top: 0, right: 200, bottom: 18, width: 200, height: 18, x: 0, y: 0,
1442
+ } as DOMRect));
1443
+ track!.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, clientX: 100, pointerId: 1, pointerType: "mouse" }));
1444
+ window.dispatchEvent(new PointerEvent("pointerup", { bubbles: true, pointerId: 1 }));
1445
+ await nextTick();
1446
+ // The scrub jumped the band (mid-rail press of a 40-row list lands
1447
+ // past the first row) and the panel is STILL open — the drag is the
1448
+ // travel; dismissing it under the pointer would fight the gesture.
1449
+ expect(sc.top()).toBeGreaterThan(0);
1450
+ expect(sc.pill().getAttribute("aria-expanded")).toBe("true");
1451
+ });
1452
+
1453
+ it("Escape closes the pinned panel", async () => {
1454
+ const sc = mountInteractive(40, 340);
1455
+ sc.stubGeometry(0);
1456
+ await sc.scrollPass();
1457
+ await sc.openByClick();
1458
+ expect(sc.pill().getAttribute("aria-expanded")).toBe("true");
1459
+ sc.dialog()!.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true }));
1460
+ await nextTick();
1461
+ expect(sc.pill().getAttribute("aria-expanded")).toBe("false");
1462
+ });
1463
+
1464
+ it("Space toggles the panel from the keyboard too", async () => {
1465
+ const sc = mountInteractive(40, 340);
1466
+ sc.stubGeometry(0);
1467
+ await sc.scrollPass();
1468
+ sc.pill().dispatchEvent(new KeyboardEvent("keydown", { key: " ", bubbles: true }));
1469
+ await nextTick();
1470
+ expect(sc.pill().getAttribute("aria-expanded")).toBe("true");
1471
+ expect(sc.panel()).not.toBeNull();
1472
+ // The keyboard path pins (like click): a second toggle closes.
1473
+ sc.pill().dispatchEvent(new KeyboardEvent("keydown", { key: " ", bubbles: true }));
1474
+ await nextTick();
1475
+ expect(sc.pill().getAttribute("aria-expanded")).toBe("false");
1476
+ });
1477
+
1478
+ it("leaves no panel behind when unmounted while open", async () => {
1479
+ const sc = mountInteractive(40, 340);
1480
+ sc.stubGeometry(0);
1481
+ await sc.scrollPass();
1482
+ await sc.openByClick();
1483
+ expect(sc.panel()).not.toBeNull();
1484
+ mounts[0].app.unmount();
1485
+ await nextTick();
1486
+ // The popover's unmount cleanup (registry handle, overlay panel)
1487
+ // must release with the pill — no dead jump panel may survive it.
1488
+ expect(document.querySelector(".hk-scroll-progress-dock-jump")).toBeNull();
1489
+ expect(document.querySelector(".hk-popover-panel")).toBeNull();
1490
+ });
1491
+
1492
+ it("closes a hover-opened panel that has no pointer owner (no leave event)", async () => {
1493
+ // R2 2026-11-30: the flag-only ownership check admitted an "open,
1494
+ // no owner" state — the open edge armed nothing, so a panel whose
1495
+ // pointer vanished without a leave event (content shifted under a
1496
+ // stationary pointer) lingered until the next click. The open edge
1497
+ // arms the ownership check now, and the freshness gate keeps stale
1498
+ // flags from claiming ownership.
1499
+ __teardownMediaQueries();
1500
+ const mqlSpy = vi.spyOn(window, "matchMedia").mockImplementation(((query: string) => ({
1501
+ matches: query === "(hover: hover) and (pointer: fine)",
1502
+ addEventListener() {},
1503
+ removeEventListener() {},
1504
+ })) as unknown as typeof window.matchMedia);
1505
+ try {
1506
+ const sc = mountInteractive(40, 340);
1507
+ sc.stubGeometry(0);
1508
+ await sc.scrollPass();
1509
+ const pill = sc.pill();
1510
+ pill.dispatchEvent(new PointerEvent("pointerenter"));
1511
+ await nextTick();
1512
+ expect(pill.getAttribute("aria-expanded")).toBe("true");
1513
+ // No leave ever fires: the grace elapses with no owner and the
1514
+ // panel closes itself.
1515
+ await new Promise((resolve) => setTimeout(resolve, 220));
1516
+ expect(pill.getAttribute("aria-expanded")).toBe("false");
1517
+ } finally {
1518
+ __teardownMediaQueries();
1519
+ mqlSpy.mockRestore();
1520
+ }
1521
+ });
1522
+
1523
+ it("opens as a bottom sheet on mobile viewports", async () => {
1524
+ const prevWidth = window.innerWidth;
1525
+ Object.defineProperty(window, "innerWidth", { configurable: true, value: 390 });
1526
+ try {
1527
+ const sc = mountInteractive(40, 340);
1528
+ sc.stubGeometry(0);
1529
+ await sc.scrollPass();
1530
+ await sc.openByClick();
1531
+ const dialog = sc.dialog()!;
1532
+ expect(dialog.classList.contains("hk-is-sheet")).toBe(true);
1533
+ // The sheet carries a scrim (tap to dismiss); the anchored panel
1534
+ // has none.
1535
+ expect(document.querySelector(".hk-popover-scrim")).not.toBeNull();
1536
+ } finally {
1537
+ Object.defineProperty(window, "innerWidth", { configurable: true, value: prevWidth });
1538
+ }
1539
+ });
1540
+
1541
+ it("hover opens immediately, survives the pill↔panel trip, closes on leave", async () => {
1542
+ // Reset the shared matchMedia registry, then stub hover-capable for
1543
+ // THIS test (the pill's useMediaQuery("(hover: hover)…") reads it at
1544
+ // setup; happy-dom's default answer is false = touch-like).
1545
+ __teardownMediaQueries();
1546
+ const mqlSpy = vi.spyOn(window, "matchMedia").mockImplementation(((query: string) => ({
1547
+ matches: query === "(hover: hover) and (pointer: fine)",
1548
+ addEventListener() {},
1549
+ removeEventListener() {},
1550
+ })) as unknown as typeof window.matchMedia);
1551
+ try {
1552
+ const sc = mountInteractive(40, 340);
1553
+ sc.stubGeometry(0);
1554
+ await sc.scrollPass();
1555
+ const pill = sc.pill();
1556
+ // Enter: opens IMMEDIATELY (no delay), unpinned.
1557
+ pill.dispatchEvent(new PointerEvent("pointerenter"));
1558
+ await nextTick();
1559
+ expect(pill.getAttribute("aria-expanded")).toBe("true");
1560
+ expect(sc.panel()).not.toBeNull();
1561
+ // Leaving the pill starts the grace; entering the panel cancels
1562
+ // it — the pointer trip pill→panel never closes the surface.
1563
+ // MUT:M14 (panel enter without cancelHoverGrace → this red)
1564
+ pill.dispatchEvent(new PointerEvent("pointerleave"));
1565
+ sc.dialog()!.dispatchEvent(new MouseEvent("mouseenter"));
1566
+ await new Promise((resolve) => setTimeout(resolve, 220));
1567
+ expect(pill.getAttribute("aria-expanded")).toBe("true");
1568
+ // Leaving both surfaces closes after the grace.
1569
+ sc.dialog()!.dispatchEvent(new MouseEvent("mouseleave"));
1570
+ await new Promise((resolve) => setTimeout(resolve, 220));
1571
+ expect(pill.getAttribute("aria-expanded")).toBe("false");
1572
+ } finally {
1573
+ __teardownMediaQueries();
1574
+ mqlSpy.mockRestore();
1575
+ }
1576
+ });
1577
+ });
1578
+
1106
1579
  // ── SCSS contract (textual pins — happy-dom does not lay out) ────────
1107
1580
  // The house style pins sheet claims with readFileSync probes
1108
1581
  // (HkButton.test.tsx icon-only precedent): these guard the paint
@@ -1120,7 +1593,41 @@ describe("HkScrollProgressDock SCSS contract", () => {
1120
1593
  const rule = scss.match(/\.hk-scroll-progress-dock\s*{[^}]*}/)?.[0] ?? "";
1121
1594
  expect(rule, "pill rule must exist").toBeTruthy();
1122
1595
  expect(rule).toContain("transition: opacity 200ms ease");
1123
- expect(rule).toContain("pointer-events: none");
1596
+ // The pill is the jump surface's trigger (2026-11-30): it captures
1597
+ // its own clicks — the old decorative pass-through let them land on
1598
+ // whatever row sat underneath (an app copy-toast fired from a pill
1599
+ // click) — and hover must be able to surface it at all.
1600
+ // TEXT PIN (happy-dom does not lay out): the behavioral layer of
1601
+ // this contract is pinned by the host-listener click test in the
1602
+ // jump-surface describe, not here.
1603
+ // MUT:M1 (R3: `pointer-events: auto` line deleted → this pin red)
1604
+ expect(rule).toContain("pointer-events: auto");
1605
+ expect(rule).toContain("cursor: pointer");
1606
+ });
1607
+
1608
+ it("reveals the idle pill on hover, keyboard focus and an open panel", () => {
1609
+ // Idle is opacity 0 but must stay findable: the trigger affordance
1610
+ // works without a prior scroll. (The combined selector is matched
1611
+ // directly — the pill rule slice stops at its first nested block.)
1612
+ const reveal = scss.match(/&:hover,\s*&:focus-visible,\s*&\.is-open\s*{[^}]*}/)?.[0] ?? "";
1613
+ expect(reveal, "hover/focus/open reveal rule must exist").toBeTruthy();
1614
+ expect(reveal).toContain("opacity: 1");
1615
+ expect(scss).toContain("&:focus-visible {\n outline: 2px solid var(--hi-border-color-focus");
1616
+ });
1617
+
1618
+ it("carries the jump panel styles (strip width, sheet-agnostic body)", () => {
1619
+ const panel = scss.match(/\.hk-scroll-progress-dock-jump\s*{[^}]*}/)?.[0] ?? "";
1620
+ expect(panel, "jump panel rule must exist").toBeTruthy();
1621
+ expect(panel).toContain("width: 264px");
1622
+ // The mobile sheet spans the viewport: the strip width AND its
1623
+ // viewport clamp must both reset under `.hk-is-sheet` (the
1624
+ // HkNotificationBell #1333 round-2 precedent — a surviving clamp
1625
+ // shrinks the sheet body into a centred block with dead bands).
1626
+ const sheet = scss.match(/\.hk-is-sheet &\s*{[^}]*}/)?.[0] ?? "";
1627
+ expect(sheet, "sheet override rule must exist").toBeTruthy();
1628
+ expect(sheet).toContain("max-width: none");
1629
+ expect(scss).toContain(".hk-scroll-progress-dock-jump-position");
1630
+ expect(scss).toContain(".hk-scroll-progress-dock-jump-row");
1124
1631
  });
1125
1632
 
1126
1633
  it("hangs bottom-center with the safe-area inset and the autotag z-tier", () => {