The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { getQuestionAnswerPreview, getQuestionAnswerText } from "./userInput.js"; |
| 4 | |
| 5 | // Shape the web client submits for an answer holding a review-comment chip. |
| 6 | const answerWithReviewComment = [ |
| 7 | "See my note: [Review comment: notes.md L2; ref=review-comment_c1]", |
| 8 | "", |
| 9 | '<t3_context version="1">', |
| 10 | '<context kind="review-comment" id="review-comment_c1">', |
| 11 | "file: notes.md", |
| 12 | "range: L2 (2-2)", |
| 13 | "comment:", |
| 14 | " Rename this", |
| 15 | "diff:", |
| 16 | " +line changed", |
| 17 | "</context>", |
| 18 | "</t3_context>", |
| 19 | ].join("\n"); |
| 20 | |
| 21 | describe("question answer display", () => { |
| 22 | it("keeps the provider context envelope out of answer history and preview", () => { |
| 23 | const history = getQuestionAnswerText(answerWithReviewComment); |
| 24 | const preview = getQuestionAnswerPreview({ |
| 25 | requestId: "request-1", |
| 26 | answers: { q1: answerWithReviewComment }, |
| 27 | attachmentsByQuestionId: {}, |
| 28 | questionTextById: { q1: "What should change?" }, |
| 29 | }); |
| 30 | |
| 31 | expect(history).toBe("See my note: [Review comment: notes.md L2]"); |
| 32 | expect(preview).toContain("See my note:"); |
| 33 | expect(preview).not.toContain("<t3_context"); |
| 34 | |
| 35 | const typedXml = |
| 36 | 'Use this XML literally: <t3_context version="1"><context kind="review-comment" id="example">keep me</context></t3_context>'; |
| 37 | expect(getQuestionAnswerText(typedXml)).toBe(typedXml); |
| 38 | }); |
| 39 | }); |