22 lines
1.1 KiB
TypeScript
22 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import presentAnswer, { answerUiExamples } from "../../.opencode/tools/present_answer.js";
|
|
import finalAnswer from "../../.opencode/tools/final_answer.js";
|
|
import { AnswerUiPublication } from "../../src/chat/answer-ui-publication.js";
|
|
import { answerUiBlockSchema } from "../../src/chat/answer-ui.js";
|
|
|
|
describe("model-facing answer UI examples", () => {
|
|
for (const example of answerUiExamples) {
|
|
it(`publishes and retains ${example.present_answer.block_id} through the real contracts`, async () => {
|
|
const context = { sessionID: "example-validation" };
|
|
const { recorded, ...output } = JSON.parse(await presentAnswer.execute(example.present_answer, context));
|
|
expect(recorded).toBe(true);
|
|
const block = answerUiBlockSchema.parse(output);
|
|
const publication = new AnswerUiPublication();
|
|
expect(publication.publish(block)).toBeUndefined();
|
|
const final = JSON.parse(await finalAnswer.execute(example.final_answer, context));
|
|
expect(publication.finalize(final.ui_block_ids)).toEqual([block.block_id]);
|
|
expect(block.phase).toBe("final");
|
|
});
|
|
}
|
|
});
|