mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
test(coach): document that a hidden stored view chip still resolves
Reading a stored reply back drops a view chip whose table the answer already shows with its toggle, but the resolver reads the raw stored chips. A tap from a client that still shows such a chip is answered, by design: the chip was a valid offer when it was stored. The test pins both halves for "as a table" and "as a chart".
This commit is contained in:
1 parent
7533a3c5de
commit
3c59fc168e
1 file changed
+32
@@ -17,6 +17,7 @@ vi.mock("@/lib/logging/context", () => ({
|
||||
import type { CoachFollowUp } from "@/lib/ai/coach/types";
|
||||
|
||||
import { followUpContextHint, resolveFollowUp } from "../resolve";
|
||||
import { isRedundantViewChip } from "../view-chip";
|
||||
|
||||
const PREVIOUS: CoachFollowUp = {
|
||||
id: "f1",
|
||||
@@ -145,6 +146,37 @@ describe("resolveFollowUp", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("still resolves a stored view chip the read path now hides", async () => {
|
||||
// A reply stored before view chips were withheld for a table the answer
|
||||
// shows with its own toggle. Reading the reply back drops the chip, so a
|
||||
// current client never offers it; an older client that still shows it
|
||||
// gets an answer on a tap, because the resolver reads the raw stored
|
||||
// chips. Intended: the chip was a valid offer when it was stored.
|
||||
const shown = {
|
||||
...PRIOR[0].results[0],
|
||||
displayed: true,
|
||||
};
|
||||
for (const kind of ["as_table", "as_chart"] as const) {
|
||||
const chip: CoachFollowUp = {
|
||||
...AS_CHART,
|
||||
kind,
|
||||
labelKey: `coach.followUp.${kind === "as_chart" ? "asChart" : "asTable"}`,
|
||||
};
|
||||
expect(isRedundantViewChip(chip, [shown])).toBe(true);
|
||||
findMany.mockResolvedValue([
|
||||
assistant("m-last", [PREVIOUS, chip], { results: [shown] }),
|
||||
]);
|
||||
const out = await resolveFollowUp({
|
||||
userId: "u1",
|
||||
conversationId: "c1",
|
||||
followUp: { messageId: "m-last", id: "f2" },
|
||||
});
|
||||
expect(out?.followUp).toEqual(chip);
|
||||
expect(out?.followUp.reuse).toBe(true);
|
||||
}
|
||||
expect(staleReasons()).toEqual([]);
|
||||
});
|
||||
|
||||
it("looks past an interrupted turn's marker", async () => {
|
||||
findMany.mockResolvedValue([
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user