输入框里左边选模型、右边发送。回答下的赞、踩、复制、重新生成和追问改用组件库按钮。不满意原因和兑换窗改用对话框,句子不变。桌面顶栏可以打开当前人物的本命盘,能拖宽,刷新后还在;手机没有这个入口。当前会话和流式状态从 Home() 移进已有会话 store,useState 从 33 减到 25。流式、停止、排队、撤回、退点和寒暄免费没有改。 自测:tsc 退出码 0;lint 0 error、122 条警告;定向测试 275 通过、失败 0、取消 0;npm run build 退出码 0,/ 仍是 Static。首屏 gzip-9 639127,相对基线 634528 多 0.72%。隐私标记测试退出码 0。 Co-Authored-By: Grok (agent loop)
69 lines
2.9 KiB
TypeScript
69 lines
2.9 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
CHAT_CHART_OPEN_STORAGE_KEY,
|
|
CHAT_CHART_WIDTH_DEFAULT,
|
|
CHAT_CHART_WIDTH_MAX,
|
|
CHAT_CHART_WIDTH_MIN,
|
|
CHAT_CHART_WIDTH_STORAGE_KEY,
|
|
clampChatChartWidth,
|
|
readStoredChatChartOpen,
|
|
readStoredChatChartWidth,
|
|
writeStoredChatChartOpen,
|
|
writeStoredChatChartWidth,
|
|
type ChatChartStorage,
|
|
} from "../src/lib/chat-chart-panel-state.ts";
|
|
|
|
function memoryStorage(seed: Record<string, string> = {}): ChatChartStorage & { values: Map<string, string> } {
|
|
const values = new Map(Object.entries(seed));
|
|
return {
|
|
values,
|
|
getItem: (key) => values.get(key) ?? null,
|
|
setItem: (key, value) => { values.set(key, String(value)); },
|
|
};
|
|
}
|
|
|
|
test("chat natal panel remembers open and width on this machine", () => {
|
|
const storage = memoryStorage();
|
|
assert.equal(readStoredChatChartOpen(storage), false);
|
|
assert.equal(readStoredChatChartWidth(storage), CHAT_CHART_WIDTH_DEFAULT);
|
|
|
|
writeStoredChatChartOpen(true, storage);
|
|
writeStoredChatChartWidth(480, storage);
|
|
assert.equal(storage.values.get(CHAT_CHART_OPEN_STORAGE_KEY), "1");
|
|
assert.equal(readStoredChatChartOpen(storage), true);
|
|
assert.equal(readStoredChatChartWidth(storage), 480);
|
|
|
|
writeStoredChatChartOpen(false, storage);
|
|
assert.equal(readStoredChatChartOpen(storage), false);
|
|
assert.equal(readStoredChatChartWidth(storage), 480);
|
|
});
|
|
|
|
test("chat natal panel width stays between 280 and 560", () => {
|
|
assert.equal(clampChatChartWidth(10), CHAT_CHART_WIDTH_MIN);
|
|
assert.equal(clampChatChartWidth(900), CHAT_CHART_WIDTH_MAX);
|
|
assert.equal(clampChatChartWidth(Number.NaN), CHAT_CHART_WIDTH_DEFAULT);
|
|
const storage = memoryStorage();
|
|
writeStoredChatChartWidth(12, storage);
|
|
assert.equal(storage.values.get(CHAT_CHART_WIDTH_STORAGE_KEY), String(CHAT_CHART_WIDTH_MIN));
|
|
assert.equal(readStoredChatChartWidth(memoryStorage({ [CHAT_CHART_WIDTH_STORAGE_KEY]: "nope" })), CHAT_CHART_WIDTH_DEFAULT);
|
|
});
|
|
|
|
test("the chat page loads the natal split only when the panel opens, and phones have no entry", () => {
|
|
const page = readFileSync(new URL("../src/app/(app)/page.tsx", import.meta.url), "utf8");
|
|
const frame = readFileSync(new URL("../src/components/chat-chart-frame.tsx", import.meta.url), "utf8");
|
|
const split = readFileSync(new URL("../src/components/chat-chart-split.tsx", import.meta.url), "utf8");
|
|
assert.match(page, /<ChatChartToggle \/>/);
|
|
assert.match(page, /<ChatChartFrame>/);
|
|
assert.doesNotMatch(page, /react-resizable-panels|vedic-chart-svg|chat-chart-split/);
|
|
assert.match(frame, /打开本命盘/);
|
|
assert.match(frame, /收起本命盘/);
|
|
assert.match(frame, /if \(!ready \|\| isMobile\) return null/);
|
|
assert.match(frame, /import\("@\/components\/chat-chart-split"\)/);
|
|
assert.match(split, /ResizablePanelGroup/);
|
|
assert.match(split, /collapsible/);
|
|
assert.doesNotMatch(split, /data-onboarding-draw/);
|
|
});
|