Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline (Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/* packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { latestAnswerableAskMessageId, selectedAskActionLabel } from "./answerable-ask.js";
|
|
|
|
describe("latestAnswerableAskMessageId", () => {
|
|
it("finds a waiting prompt even when a newer group run is active", () => {
|
|
expect(
|
|
latestAnswerableAskMessageId({
|
|
run: { id: "run-newer", status: "running" },
|
|
activeRuns: [
|
|
{ id: "run-newer", status: "running" },
|
|
{ id: "run-waiting", status: "waiting_input" },
|
|
],
|
|
messages: [
|
|
{
|
|
id: "ask-1",
|
|
runId: "run-waiting",
|
|
blocks: [{ kind: "ask", status: "pending" }],
|
|
},
|
|
],
|
|
}),
|
|
).toBe("ask-1");
|
|
});
|
|
|
|
it("ignores answered prompts and prompts from non-waiting runs", () => {
|
|
expect(
|
|
latestAnswerableAskMessageId({
|
|
run: { id: "run-1", status: "running" },
|
|
messages: [{ id: "ask-1", runId: "run-1", blocks: [{ kind: "ask", status: "pending" }] }],
|
|
}),
|
|
).toBeNull();
|
|
expect(
|
|
latestAnswerableAskMessageId({
|
|
run: { id: "run-1", status: "waiting_input" },
|
|
messages: [{ id: "ask-1", runId: "run-1", blocks: [{ kind: "ask", status: "answered" }] }],
|
|
}),
|
|
).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("selectedAskActionLabel", () => {
|
|
it("maps a choice answer id to its user-facing label", () => {
|
|
expect(
|
|
selectedAskActionLabel("choice-2", [
|
|
{ id: "choice-1", label: "Berlin" },
|
|
{ id: "choice-2", label: "Seoul" },
|
|
]),
|
|
).toBe("Seoul");
|
|
});
|
|
|
|
it("falls back to the answer when an action is unavailable", () => {
|
|
expect(selectedAskActionLabel("custom", undefined)).toBe("custom");
|
|
});
|
|
});
|