Files
Jyotisha/frontend/tests/consultation-smalltalk-ui.test.tsx
T

34 lines
2.5 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import React from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { ChatMessageRow } from "../src/components/chat-message-row.tsx";
import { settledChatMessageViews, streamingChatMessageView } from "../src/lib/chat-message-view.ts";
test("settled and streaming smalltalk render text without thinking, activity or evidence", () => {
const settled = settledChatMessageViews([{ role: "assistant", text: "你好", responseKind: "smalltalk", thinkingText: "must stay hidden" }])[0]!;
const streaming = streamingChatMessageView([{ role: "user", text: "你好" }], true, "你好", undefined, undefined, undefined, [], "smalltalk")!;
for (const message of [settled, streaming]) {
const html = renderToStaticMarkup(<ChatMessageRow message={message} />);
assert.match(html, /你好/);
assert.doesNotMatch(html, /consultation-thinking-report|agent-activity|must stay hidden|已完成|技法|正在分析/);
}
});
// 原值: 分类结果回来之前整行静默——不渲染时间线,不出现「正在处理 / 正在分析」
// 新值: 从发送那一帧起就渲染时间线的排队行「收到,正在看你的问题…」;只有 responseKind 为 smalltalk 的行才静默
// 原因: TASK-consult-first-frame-and-pacing-20260928 D1 / BUG-1074:静默让每一轮在服务端首事件前都是空白(BUG-976 的副作用)
test("the classification wait shows the queued row from the send frame; only a smalltalk reply is quiet", () => {
const message = streamingChatMessageView([{ role: "user", text: "你好" }], true, "", undefined, undefined, undefined, [])!;
const html = renderToStaticMarkup(<ChatMessageRow message={message} showActivity />);
assert.match(html, /consultation-thinking-report/);
assert.match(html, /收到,正在看你的问题…/);
assert.match(html, /inline-spinner/);
assert.doesNotMatch(html, /已完成|正在处理…/);
// No invented step: the queued row is the only row, and it is not a think or write step.
assert.equal((html.match(/consultation-run-timeline__row/g) ?? []).length, 1);
const smalltalk = streamingChatMessageView([{ role: "user", text: "你好" }], true, "", undefined, undefined, undefined, [], "smalltalk")!;
const quiet = renderToStaticMarkup(<ChatMessageRow message={smalltalk} showActivity />);
assert.doesNotMatch(quiet, /consultation-thinking-report|收到,正在看你的问题|正在分析|已完成/);
});