|
| 1 | +import { expect, test } from "bun:test" |
| 2 | +import { createAppFixture } from "./fixture/app" |
| 3 | +import { directory, json } from "./fixture/tui-client" |
| 4 | + |
| 5 | +test("Home and End navigate a subagent transcript", async () => { |
| 6 | + const session = { |
| 7 | + id: "ses_subagent_navigation", |
| 8 | + parentID: "ses_parent", |
| 9 | + title: "Subagent", |
| 10 | + agent: "build", |
| 11 | + projectID: "proj_test", |
| 12 | + location: { directory }, |
| 13 | + cost: 0, |
| 14 | + tokens: { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } }, |
| 15 | + time: { created: 0, updated: 0 }, |
| 16 | + } |
| 17 | + const messages = Array.from({ length: 20 }, (_, index) => ({ |
| 18 | + id: `message-${index}`, |
| 19 | + type: "user", |
| 20 | + text: `Message ${index}`, |
| 21 | + time: { created: index }, |
| 22 | + })) |
| 23 | + await using setup = await createAppFixture({ |
| 24 | + width: 100, |
| 25 | + height: 30, |
| 26 | + config: { animations: false, tabs: { mode: "off" } }, |
| 27 | + args: { sessionID: session.id }, |
| 28 | + fetch: (url) => { |
| 29 | + if (url.pathname === "/api/session") return json({ data: [session], cursor: {} }) |
| 30 | + if (url.pathname === `/api/session/${session.id}`) return json({ data: session }) |
| 31 | + if (url.pathname === `/api/session/${session.id}/message`) |
| 32 | + return json({ data: messages.toReversed(), cursor: {} }) |
| 33 | + if (url.pathname === `/api/session/${session.id}/inbox`) return json({ data: [] }) |
| 34 | + }, |
| 35 | + }) |
| 36 | + await setup.ready |
| 37 | + expect( |
| 38 | + await setup.waitForFrame((frame) => frame.includes("Message 19") && frame.includes("Subagents")), |
| 39 | + ).not.toContain("Message 0") |
| 40 | + setup.mockInput.pressKey("HOME") |
| 41 | + expect(await setup.waitForFrame((frame) => frame.includes("Message 0"))).not.toContain("Message 19") |
| 42 | + setup.mockInput.pressKey("END") |
| 43 | + expect(await setup.waitForFrame((frame) => frame.includes("Message 19"))).not.toContain("Message 0") |
| 44 | +}) |
0 commit comments