hololake-system-architecture/product-source/hololake-native-desktop/scripts/persona-language-chat.test.mjs
冰朔 add00a0377 fix: integrate language channel through numbered IPC and isolate education module
正向合并正律化(2026-08-20):
- 语言人格频道与执行手脚训练按编号 IPC 正律接入(MOD-0035/0036,OP-0158..0163),
  剥离直连 tauri::command,恢复单一 numbered 网关铁律
- 教育模块按冰朔谕与 2026-08-19 隔离回执整体移出(证据归隔离区),留空模块占位
- 光湖主域门户挂公告与版本中心(冰朔要求的公告与版本更新主阵地)
- 知识工作台内嵌共同工作频道(PersonaChannelBody embedded + knowledgeFocus)
- foundation/stage-one 合同补聊天运行时验收声明;版本对齐 0.9.1
- 测试名册计数与断言更新至合并后现实:JS 180/180,Rust 194/194
2026-08-20 12:23:02 +08:00

45 lines
2.8 KiB
JavaScript

import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'
const main = await readFile(new URL('../src/main.tsx', import.meta.url), 'utf8')
const channel = await readFile(new URL('../src/modules/persona-channel-body/index.tsx', import.meta.url), 'utf8')
const runtime = await readFile(new URL('../src-tauri/src/persona_language_channel.rs', import.meta.url), 'utf8')
test('light lake exposes a first-class human conversation entrance', () => {
assert.match(main, /type ViewId = [^\n]*'persona'/)
assert.match(main, /knowledge-chat-entry/)
assert.match(main, />共同工作</)
assert.match(main, /view === 'persona' \? renderPersonaBody\(\)/)
assert.match(main, /<PersonaChannelBody/)
assert.match(channel, /<textarea[\s\S]*?form\?\.requestSubmit\(\)/)
assert.match(channel, /\{sending \? '正在回应…' : '发送'\}/)
})
test('knowledge workspace keeps the chat visible and binds the exact active page', () => {
assert.match(main, /hololake-knowledge-chat-open'\) !== '0'/)
assert.match(main, /knowledge-persona-collaboration/)
assert.match(main, /knowledgeFocus=\{activeDocument \? \{ source: activeDocument\.source, path: activeDocument\.path, title: activeDocument\.title, contentSha256: activeDocument\.contentSha256 \}/)
assert.match(channel, /activeKnowledgeSource: knowledgeFocus\?\.source/)
assert.match(channel, /activeKnowledgePath: knowledgeFocus\?\.path/)
assert.match(channel, /引用知识 · \{receipt\.path\} · \{shortHash\(receipt\.contentSha256\)\}/)
assert.match(runtime, /collect_knowledge_context\([\s\S]*?input\.active_knowledge_source\.as_deref\(\)[\s\S]*?input\.active_knowledge_path\.as_deref\(\)/)
assert.match(runtime, /append_knowledge_document\(&mut context, &mut seen, document\)/)
assert.match(runtime, /let secret = read_secret_bounded\(app, provider_id\)\.await\.ok\(\)/)
assert.doesNotMatch(runtime, /fn read_secret\(/)
})
test('model configuration remains secondary to the conversation surface', () => {
assert.match(channel, /const \[settingsOpen, setSettingsOpen\] = useState\(false\)/)
assert.match(channel, /直接输入消息开始对话;知识引用、模型设置和运行回执按需展开/)
assert.match(channel, /\{settingsOpen && <aside className="persona-chat-settings">/)
assert.match(channel, /API 密钥 · 只进钥匙串/)
})
test('the chosen model route survives restart and prefers explicit user configuration', () => {
assert.match(channel, /const PROVIDER_SELECTION_KEY = 'hololake-persona-provider-id'/)
assert.match(channel, /localStorage\.getItem\(PROVIDER_SELECTION_KEY\)/)
assert.match(channel, /item\.source === 'EXPLICIT_USER_CONFIG'/)
assert.match(channel, /rememberProvider\(nextProviderId\)/)
assert.match(channel, /onChange=\{\(event\) => selectProvider\(event\.target\.value\)\}/)
})