Skip to content

Commit 7ea2e4d

Browse files
committed
Exercise the real renderer dispatch in the wheel-to-transcript test
Calling the prompt's overridden onMouseEvent directly skipped the renderer's SGR-mouse parse and hit-test, so the test proved the forwarding function works without proving the renderer ever calls it on a genuine wheel scroll. Driving the same bytes through the mock mouse at the prompt's actual screen position closes that gap.
1 parent 6b2a3e3 commit 7ea2e4d

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

src/tui-opentui/shell.test.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Integration: app shell product skin — sticky, queue/steer/interrupt, overlay Esc.
33
*/
44
import { describe, expect, test } from "bun:test"
5-
import { MouseEvent, type KeyEvent } from "@opentui/core"
5+
import type { KeyEvent } from "@opentui/core"
66
import { IDLE_TRANSCRIPT_FLOOR } from "./geometry/index"
77
import { focusOwner, scrollLease } from "./focus/index"
88
import {
@@ -175,21 +175,22 @@ describe("createAppShell", () => {
175175
expect(isTranscriptFollowing(shell)).toBe(true)
176176
const followingTop = shell.transcript.scrollTop
177177

178-
const wheelUp = new MouseEvent(shell.prompt, {
179-
type: "scroll",
180-
button: 0,
181-
x: 0,
182-
y: 0,
183-
modifiers: { shift: false, alt: false, ctrl: false },
184-
scroll: { direction: "up", delta: 3 },
185-
})
186-
;(
187-
shell.prompt as unknown as { onMouseEvent: (event: MouseEvent) => void }
188-
).onMouseEvent(wheelUp)
178+
// Locate the prompt's interior on screen and scroll through the
179+
// renderer's real SGR-mouse parse + hit-test dispatch, the same
180+
// path a live terminal drives — not a direct method call, which
181+
// would pass even if the renderer never routed the event here.
182+
const rows = h.captureCharFrame().split("\n")
183+
const borderRow = rows.findIndex((r) => r.includes("╭"))
184+
const promptX = rows[borderRow]!.indexOf("╭") + 2
185+
const promptY = borderRow + 1
186+
187+
for (let i = 0; i < 5; i++) {
188+
await h.mockMouse.scroll(promptX, promptY, "up")
189+
}
189190
await h.renderOnce()
190191

191-
// The wheel event was dispatched at the prompt, but the transcript
192-
// moved and pinned — the prompt's own (empty) buffer never scrolled.
192+
// The wheel event landed on the prompt, but the transcript moved
193+
// and pinned — the prompt's own (empty) buffer never scrolled.
193194
expect(shell.transcript.scrollTop).toBeLessThan(followingTop)
194195
expect(isTranscriptFollowing(shell)).toBe(false)
195196
expect(stickyMode(shell)).toBe("PINNED")

0 commit comments

Comments
 (0)