Test the details panel's status block, tasks and changes in the app
This commit is contained in:
1 parent
bbf8ff49e1
commit
46e0588359
2 files changed
+51
-2
No files matched your search
+48
-1
@@ -1,8 +1,9 @@
|
|||||||
import { afterEach, describe, expect, test } from "bun:test";
|
import { afterEach, describe, expect, test } from "bun:test";
|
||||||
|
import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts";
|
||||||
|
|
||||||
import { omittedCommand, withApproval, withCompletedTurn, withOmittedOutput, withQuestion, withWorking } from "./fixtures.ts";
|
import { omittedCommand, withApproval, withCompletedTurn, withOmittedOutput, withQuestion, withWorking } from "./fixtures.ts";
|
||||||
import { loadLayout } from "../../src/layout.ts";
|
import { loadLayout } from "../../src/layout.ts";
|
||||||
import { fakeSession, renderApp, v2ThreadId } from "./harness.tsx";
|
import { fakeSession, renderApp, v2Projection, v2ThreadId } from "./harness.tsx";
|
||||||
|
|
||||||
let app: Awaited<ReturnType<typeof renderApp>> | null = null;
|
let app: Awaited<ReturnType<typeof renderApp>> | null = null;
|
||||||
const open = async (...args: Parameters<typeof renderApp>) => (app = await renderApp(...args));
|
const open = async (...args: Parameters<typeof renderApp>) => (app = await renderApp(...args));
|
||||||
@@ -331,6 +332,52 @@ describe("command output", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("details panel", () => {
|
||||||
|
const steps = Array.from({ length: 8 }, (_, index) => ({ id: `s${index}`, text: `Step ${index}`, status: index < 2 ? "completed" : index === 2 ? "running" : "pending" }));
|
||||||
|
const projection = {
|
||||||
|
...v2Projection,
|
||||||
|
providerTurns: [{ tokenUsage: { usedTokens: 62_000, maxTokens: 100_000, updatedAt: "2026-06-20T00:00:00.000Z" } }],
|
||||||
|
turnItems: [{ id: "todo", type: "todo_list", planId: "p", steps }],
|
||||||
|
} as unknown as OrchestrationV2ThreadProjection;
|
||||||
|
const vcs = {
|
||||||
|
status: "live",
|
||||||
|
local: {
|
||||||
|
isRepo: true,
|
||||||
|
hasPrimaryRemote: true,
|
||||||
|
isDefaultRef: true,
|
||||||
|
refName: "main",
|
||||||
|
hasWorkingTreeChanges: true,
|
||||||
|
workingTree: { files: [{ path: "README.md", insertions: 29, deletions: 167 }, { path: "docs/", insertions: 0, deletions: 0 }], insertions: 29, deletions: 167 },
|
||||||
|
},
|
||||||
|
remote: { hasUpstream: true, aheadCount: 0, behindCount: 0, pr: null },
|
||||||
|
};
|
||||||
|
|
||||||
|
test("shows the context left, tasks, changes and branch", async () => {
|
||||||
|
const app = await open({ width: 200, session: fakeSession({ projection, vcs }) });
|
||||||
|
const frame = app.frame();
|
||||||
|
expect(frame).toContain("Context ████░░░░░░ 38% left");
|
||||||
|
expect(frame).toMatch(/Tasks +2\/8/);
|
||||||
|
expect(frame).toContain("◐ Step 2");
|
||||||
|
expect(frame).not.toContain("Step 7");
|
||||||
|
expect(frame).toMatch(/M README\.md +\+29 −167/);
|
||||||
|
expect(frame).toMatch(/\? docs\/ +new/);
|
||||||
|
expect(frame).toContain("▸ View diff");
|
||||||
|
// Up to date: no ahead/behind counts, no hint.
|
||||||
|
expect(frame).toMatch(/┃ main +\n/);
|
||||||
|
expect(frame).not.toContain("↑0");
|
||||||
|
const more = app.find("› 3 more");
|
||||||
|
await app.click(more.x, more.y);
|
||||||
|
expect(app.frame()).toContain("Step 7");
|
||||||
|
expect(app.frame()).toContain("‹ fewer");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("leaves out the context line without usage reports", async () => {
|
||||||
|
const app = await open({ width: 200 });
|
||||||
|
expect(app.frame()).not.toContain("Context");
|
||||||
|
expect(app.frame()).not.toContain("Tasks");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("mouse", () => {
|
describe("mouse", () => {
|
||||||
test("the header button opens the palette", async () => {
|
test("the header button opens the palette", async () => {
|
||||||
const app = await open();
|
const app = await open();
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ export function fakeSession(
|
|||||||
readonly snapshot?: OrchestrationV2ShellSnapshot;
|
readonly snapshot?: OrchestrationV2ShellSnapshot;
|
||||||
readonly projection?: OrchestrationV2ThreadProjection;
|
readonly projection?: OrchestrationV2ThreadProjection;
|
||||||
readonly status?: ConnectionStatus;
|
readonly status?: ConnectionStatus;
|
||||||
|
/** Git status for every folder; loading by default. */
|
||||||
|
readonly vcs?: unknown;
|
||||||
readonly results?: Record<string, unknown>;
|
readonly results?: Record<string, unknown>;
|
||||||
readonly failures?: Record<string, string>;
|
readonly failures?: Record<string, string>;
|
||||||
} = {},
|
} = {},
|
||||||
@@ -57,7 +59,7 @@ export function fakeSession(
|
|||||||
watchServers: live({ status: "live", items: [] }),
|
watchServers: live({ status: "live", items: [] }),
|
||||||
watchAutomations: live({ status: "live", items: [] }),
|
watchAutomations: live({ status: "live", items: [] }),
|
||||||
watchTerminals: live({ status: "live", items: [] }),
|
watchTerminals: live({ status: "live", items: [] }),
|
||||||
watchVcs: (_cwd: string, listener: (value: unknown) => void) => live({ status: "loading", local: null, remote: null })(listener),
|
watchVcs: (_cwd: string, listener: (value: unknown) => void) => live(state.vcs ?? { status: "loading", local: null, remote: null })(listener),
|
||||||
};
|
};
|
||||||
const session = new Proxy(known, {
|
const session = new Proxy(known, {
|
||||||
get(target, name) {
|
get(target, name) {
|
||||||
|
|||||||
Reference in new issue
Block a user