Files
t3code/apps/web/src/components/chat/QueuedRunsControl.test.tsx
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

172 lines
4.8 KiB
TypeScript

import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it, vi } from "vite-plus/test";
const state = vi.hoisted(() => ({
projection: null as unknown,
workflow: null as unknown,
}));
vi.mock("@t3tools/client-runtime/environment", () => ({
scopeThreadRef: () => ({}) as never,
}));
vi.mock("@t3tools/client-runtime/state/thread-workflows", () => ({
deriveThreadQueueWorkflowState: () => state.workflow,
}));
vi.mock("../../state/entities", () => ({
useThreadProjection: () => state.projection,
}));
vi.mock("../../state/threads", () => ({
threadEnvironment: {
cancelQueuedRun: Symbol("cancelQueuedRun"),
promoteQueuedRun: Symbol("promoteQueuedRun"),
reorderQueuedRun: Symbol("reorderQueuedRun"),
},
}));
vi.mock("../../state/use-atom-command", () => ({
useAtomCommand: () => async () => undefined,
}));
vi.mock("../../assets/assetUrls", () => ({
useAssetUrls: (_environmentId: never, resources: ReadonlyArray<{ attachmentId: string }>) =>
resources.map((resource) => `https://assets.test/${resource.attachmentId}`),
}));
import { QueuedRunsControl } from "./QueuedRunsControl";
describe("QueuedRunsControl automatic completion delivery", () => {
it("does not render a queue control when only hidden delivery remains", () => {
state.projection = {
projection: {
messages: [
{
delegatedCompletion: {
parentRunId: "run:parent",
generation: 1,
taskIds: ["task:child"],
},
id: "message:completion",
},
],
},
};
state.workflow = {
activeRun: { id: "run:active" },
canPromoteToSteer: true,
canReorder: true,
queuedRuns: [],
};
const html = renderToStaticMarkup(
<QueuedRunsControl
environmentId={"environment:test" as never}
optimisticMessages={[]}
threadId={"thread:test" as never}
editingRunId={null}
onEditQueuedRun={() => undefined}
onCancelEdit={() => undefined}
/>,
);
expect(html).toBe("");
});
});
describe("QueuedRunsControl attachments and edit mode", () => {
const workflowWithAttachment = () => ({
activeRun: { id: "run:active" },
canPromoteToSteer: true,
canReorder: true,
queuedRuns: [
{
run: { id: "run:queued", userMessageId: "message:queued" },
text: "Queued with a screenshot",
attachments: [
{
type: "image",
id: "attachment-1",
name: "screenshot.png",
mimeType: "image/png",
sizeBytes: 128,
},
],
},
],
});
it("renders an attachment thumbnail on the queued row", () => {
state.projection = { projection: { messages: [] } };
state.workflow = workflowWithAttachment();
const html = renderToStaticMarkup(
<QueuedRunsControl
environmentId={"environment:test" as never}
optimisticMessages={[]}
threadId={"thread:test" as never}
editingRunId={null}
onEditQueuedRun={() => undefined}
onCancelEdit={() => undefined}
/>,
);
expect(html).toContain("https://assets.test/attachment-1");
expect(html).toContain("Queued with a screenshot");
expect(html).toContain("Edit queued message");
expect(html).toContain("Reorder queued message");
expect(html).not.toContain("Move queued message up");
});
it("drops the optimistic pending row once the projection holds its message", () => {
state.projection = {
projection: { messages: [{ id: "message:acknowledged", text: "hello" }] },
};
state.workflow = {
activeRun: { id: "run:active" },
canPromoteToSteer: true,
canReorder: true,
queuedRuns: [],
};
const html = renderToStaticMarkup(
<QueuedRunsControl
environmentId={"environment:test" as never}
optimisticMessages={[
{
id: "message:acknowledged" as never,
inputIntent: "queued_turn",
text: "hello",
attachments: [],
},
]}
threadId={"thread:test" as never}
editingRunId={null}
onEditQueuedRun={() => undefined}
onCancelEdit={() => undefined}
/>,
);
expect(html).toBe("");
});
it("keeps the original queued message visible while editing", () => {
state.projection = { projection: { messages: [] } };
state.workflow = workflowWithAttachment();
const html = renderToStaticMarkup(
<QueuedRunsControl
environmentId={"environment:test" as never}
optimisticMessages={[]}
threadId={"thread:test" as never}
editingRunId={"run:queued" as never}
onEditQueuedRun={() => undefined}
onCancelEdit={() => undefined}
/>,
);
expect(html).toContain("Queued with a screenshot");
});
});