feat(settings): 知识库绑定按环境一次保存连接与内外库
原「知识库映射 → WeKnora 连接」把地址、文件和绑定分散在多处,页面无法输入密钥, 也看不到候选实例真实可读的库。现在测试 090 / 生产 090 各自一个工作区:草稿填地址 与 API Key,服务器真实分页列库并区分空库/无权限/不可达,选内外库后一次保存连接与 绑定,回读真实生效值。 服务端以修订号 + 行锁 + 单事务写连接、绑定与待入库重排;旧部署无新行时继续使用文件 凭据/默认绑定。密钥只存 AES-256-GCM 密文,主密钥在独立文件;换地址必须重录,旧密钥 不转发、不跨环境取用。消费端(readiness/上传轮询/列库/探活/生产列库)统一从该存储 解析当前连接,避免只保存了页面数据。 验证:go test ./...;前端 606 项;隔离 PostgreSQL 集成用例覆盖保存/冲突/重排/拒错; make verify 在本提交上执行(结果见交付说明)。
This commit is contained in:
@@ -141,13 +141,13 @@ describe('SystemSettingsView AI 模型连接', () => {
|
||||
/>
|
||||
</AuthContext.Provider>
|
||||
)
|
||||
it('keeps the model connection alone in AI 模型连接 and points WeKnora to 知识库映射', () => {
|
||||
it('keeps the model connection alone in AI 模型连接 and points WeKnora to 知识库绑定', () => {
|
||||
const adminHtml = view('admin')
|
||||
for (const text of [
|
||||
'AI 模型连接',
|
||||
'正在读取已保存的模型连接',
|
||||
'问答四字段分析与中文问题翻译共用此连接',
|
||||
'WeKnora 的知识库连接已移到「知识库映射」',
|
||||
'WeKnora 的知识库连接已移到「知识库绑定」',
|
||||
]) {
|
||||
expect(adminHtml).toContain(text)
|
||||
}
|
||||
@@ -179,7 +179,7 @@ describe('SystemSettingsView', () => {
|
||||
onRefresh={vi.fn()}
|
||||
/>
|
||||
)
|
||||
for (const text of ['系统设置', '数据源配置', 'AI 模型连接', '知识库映射', '存储与备份', '刷新策略'])
|
||||
for (const text of ['系统设置', '数据源配置', 'AI 模型连接', '知识库绑定', '存储与备份', '刷新策略'])
|
||||
expect(html).toContain(text)
|
||||
// 主人 2026-10-26 要求去掉的噪声:页头副标题、刷新状态、权限条、活动版本横幅。
|
||||
for (const removed of [
|
||||
@@ -202,7 +202,7 @@ describe('SystemSettingsView', () => {
|
||||
expect(html).not.toContain(removed)
|
||||
// 需求(2026-10-10):新增入口只剩「可加入的来源」勾选,粘贴链接的按钮已下线。
|
||||
for (const removed of ['+ 新增钉钉知识库', '新增钉钉知识库']) expect(html).not.toContain(removed)
|
||||
// WeKnora 连接已迁到「知识库映射」:地址与核验参数跟入库/封存/生产目标同屏。
|
||||
// WeKnora 连接已迁到「知识库绑定」:主表单保存连接+绑定,诊断折叠保留。
|
||||
const mapHtml = renderToStaticMarkup(
|
||||
<AuthContext.Provider value={authValue('admin')}>
|
||||
<SystemSettingsView
|
||||
@@ -224,18 +224,19 @@ describe('SystemSettingsView', () => {
|
||||
</AuthContext.Provider>
|
||||
)
|
||||
for (const text of [
|
||||
'WeKnora 连接',
|
||||
'知识库绑定',
|
||||
'测试 090',
|
||||
'生产 090',
|
||||
'正在读取知识库绑定…',
|
||||
'连接与绑定诊断',
|
||||
'测试 WeKnora',
|
||||
'生产 WeKnora',
|
||||
'测试地址',
|
||||
'生产地址',
|
||||
'生产租户 ID',
|
||||
'知识库 ID',
|
||||
'保存并校验连接',
|
||||
'生产核验参数',
|
||||
'整库发布目标',
|
||||
])
|
||||
expect(mapHtml).toContain(text)
|
||||
// 凭据是服务器文件引用:连接卡只报状态,页面不提供 API Key 录入。
|
||||
// 旧连接表单已被单一保存入口取代;SSR 尚未读到绑定时不渲染密钥输入。
|
||||
for (const removed of ['保存并校验连接', '测试地址', '生产租户 ID', '生产核验参数'])
|
||||
expect(mapHtml).not.toContain(removed)
|
||||
expect(mapHtml).not.toContain('API Key')
|
||||
const storageHtml = renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
@@ -332,14 +333,16 @@ describe('SystemSettingsView', () => {
|
||||
/>
|
||||
</AuthContext.Provider>
|
||||
)
|
||||
// 测试绑定与生产目标已合并为「知识库映射」:入库目标、封存源、生产目标同屏。
|
||||
expect(view('sources')).toContain('知识库映射')
|
||||
// 旧入口(bindings / production-bindings)都落到「知识库绑定」:新主表单 + 折叠诊断。
|
||||
expect(view('sources')).toContain('知识库绑定')
|
||||
const bound = view('bindings')
|
||||
expect(bound).toContain('id="settings-kb-bindings"')
|
||||
expect(bound).toContain('知识库绑定')
|
||||
expect(bound).toContain('正在读取知识库绑定…')
|
||||
expect(bound).toContain('连接与绑定诊断')
|
||||
// 诊断区保留原链路:测试入库绑定与生产目标入口仍在,但不再提供第二个保存路径。
|
||||
expect(bound).toContain('id="settings-routing-bindings"')
|
||||
expect(bound).toContain('分发到对应的测试 WeKnora 知识库')
|
||||
// 未读到绑定数据时(SSR 不跑 effect)面板也要如实存在,而不是空白。
|
||||
expect(bound).toContain('读取中…')
|
||||
// 发布目标(源库 → 目标库)是独立分区,与测试端收件库分开。
|
||||
const target = view('production-bindings')
|
||||
expect(target).toContain('id="settings-production-bindings"')
|
||||
expect(target).toContain('整库发布目标')
|
||||
@@ -437,7 +440,7 @@ describe('SystemSettingsView', () => {
|
||||
expect(on).toContain('延迟 86ms')
|
||||
expect(on).toContain('已启用 · 可提交生产请求')
|
||||
expect(on).toContain('生产写入:开启')
|
||||
expect(on).toContain('凭据:服务器文件引用,页面不回读')
|
||||
expect(on).toContain('凭据:服务器文件/加密存储,页面不回读')
|
||||
const off = view(false, false)
|
||||
expect(off).toContain('未启用')
|
||||
expect(off).toContain('生产写入:关闭')
|
||||
|
||||
Reference in New Issue
Block a user