Files
t3code/apps/mobile/src/features/threads/worktree-setup-state.test.ts
T
+36 de34391427 feat(orchestrator): introduce new orchestrator (#2829)
Co-authored-by: maria-rcks <[email protected]>
Co-authored-by: Bilal Bakr <[email protected]>
Co-authored-by: shivam <[email protected]>
Co-authored-by: Vitalii Yehorov <[email protected]>
Co-authored-by: Jake Leventhal <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Alex Southwell <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nicholas Wasmiller <[email protected]>
Co-authored-by: PB <[email protected]>
Co-authored-by: Exotic <[email protected]>
Co-authored-by: Yash Singh <[email protected]>
Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Theo Browne <[email protected]>
Co-authored-by: Gabriel De Andrade <[email protected]>
Co-authored-by: Dara Adedeji <[email protected]>
Co-authored-by: scratchyone <[email protected]>
Co-authored-by: Dominic Roy <[email protected]>
Co-authored-by: chukfinley <[email protected]>
Co-authored-by: Primož Ajdišek <[email protected]>
Co-authored-by: benthecarman <[email protected]>
Co-authored-by: NaveDanan <[email protected]>
Co-authored-by: aaditagrawal <[email protected]>
Co-authored-by: Aditya Garud <[email protected]>
Co-authored-by: Nick Anisimov <[email protected]>
Co-authored-by: MacKinley Smith <[email protected]>
Co-authored-by: Yordis Prieto <[email protected]>
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: AKolenda <[email protected]>
Co-authored-by: Guillermo Casanova <[email protected]>
Co-authored-by: Otavio Salvador <[email protected]>
Co-authored-by: Shirish Pothi <[email protected]>
Co-authored-by: Ishaan Kothari <[email protected]>
Co-authored-by: Bob Fowler <[email protected]>
Co-authored-by: Anton Bezdenezhnykh <[email protected]>
Co-authored-by: ValeraZSD <[email protected]>
Co-authored-by: Ephraim <[email protected]>
Co-authored-by: Ryan Ilano <[email protected]>
Co-authored-by: Alex <[email protected]>
Co-authored-by: maco <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Tristan Knight <[email protected]>
Co-authored-by: PR Batch Tester <[email protected]>
Co-authored-by: oliver <[email protected]>
Co-authored-by: kamkm <[email protected]>
Signed-off-by: Yordis Prieto <[email protected]>
2026-10-02 12:22:22 -07:00

79 lines
2.5 KiB
TypeScript

import { ThreadId, type WorktreeSetupSnapshot } from "@t3tools/contracts";
import { resolveVisibleWorktreeSetup } from "@t3tools/client-runtime/worktree-setup";
import { describe, expect, it } from "vite-plus/test";
import { resolveWorktreeSetupSnapshot } from "./worktree-setup-state";
const threadId = ThreadId.make("setup-thread");
const running: WorktreeSetupSnapshot = {
threadId,
sequence: 1,
phase: "running",
startedAt: "2026-09-17T00:00:00.000Z",
endedAt: null,
branch: "feature",
baseRef: "main",
worktreePath: null,
setupScript: null,
stages: [],
error: null,
};
describe("mobile worktree setup handoff", () => {
it("keeps the setup identity after its card retires so the working header can take over", () => {
const done = { ...running, phase: "done" as const, sequence: 2 };
const held = resolveWorktreeSetupSnapshot(threadId, done, running);
expect(held).toBe(done);
expect(
resolveVisibleWorktreeSetup({
live: held,
recorded: null,
turnStarted: false,
followUpSent: false,
}),
).toBe(done);
expect(
resolveVisibleWorktreeSetup({
live: held,
recorded: null,
turnStarted: true,
followUpSent: false,
}),
).toBeNull();
// Closing the live query must not lose the handoff anchor.
expect(resolveWorktreeSetupSnapshot(threadId, undefined, held)).toBe(done);
});
it.each(["failed", "cancelled"] as const)(
"retains %s details after the stream closes",
(phase) => {
const settled = { ...running, phase, sequence: 3 };
const held = resolveWorktreeSetupSnapshot(threadId, settled, running);
expect(resolveWorktreeSetupSnapshot(threadId, null, held)).toBe(settled);
expect(resolveWorktreeSetupSnapshot(threadId, running, held)).toBe(settled);
expect(
resolveVisibleWorktreeSetup({
live: held,
recorded: null,
turnStarted: false,
followUpSent: false,
}),
).toBe(settled);
expect(
resolveVisibleWorktreeSetup({
live: held,
recorded: null,
turnStarted: false,
followUpSent: true,
}),
).toBeNull();
},
);
it("does not carry a previous thread's progress across navigation", () => {
const otherId = ThreadId.make("other-thread");
expect(resolveWorktreeSetupSnapshot(otherId, running, running)).toBeNull();
const other = { ...running, threadId: otherId };
expect(resolveWorktreeSetupSnapshot(otherId, other, running)).toBe(other);
});
});