feat(settings): 服务配置拆为 AI 模型连接,WeKnora 连接并入知识库映射
build / build (push) Failing after 2m22s

- 原「服务配置」更名为「AI 模型连接」,只保留问答分析与中文翻译共用的模型连接
- 测试/生产 WeKnora 地址、生产租户与知识库 ID 迁入「知识库映射」,与入库/封存/生产目标同屏
- 连接配置独立草稿与独立保存,刷新策略不夹带未保存地址
- 同步 README、运维手册、验收清单入口路径
This commit is contained in:
姚章浩
2026-11-18 15:15:13 +08:00
parent afc38c921f
commit 3da82d48d9
17 changed files with 545 additions and 355 deletions
+73 -74
View File
@@ -119,57 +119,40 @@ const authValue = (role: 'admin' | 'engineer') => ({
signedOut: 0,
notifySignedOut: () => {},
})
describe('SystemSettingsView service configuration', () => {
it('lets an administrator edit exactly the four service fields in the web console', () => {
const configured: UISettings = {
...settings,
test_weknora_base_url: 'https://weknora.test.example',
production_weknora_base_url: 'https://weknora.prod.example',
production_tenant_id: '10000',
production_knowledge_base_id: 'kb-abc123',
}
const view = (role: 'admin' | 'engineer') =>
renderToStaticMarkup(
<AuthContext.Provider value={authValue(role)}>
<SystemSettingsView
sources={sources}
connections={connections}
monitor={monitor}
settings={configured}
productionEnabled={false}
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
loading={false}
saving={false}
error={null}
saveMessage={null}
onSave={vi.fn()}
onSourcesChanged={vi.fn()}
onRefresh={vi.fn()}
initialSection="services"
/>
</AuthContext.Provider>
)
describe('SystemSettingsView AI 模型连接', () => {
const view = (role: 'admin' | 'engineer') =>
renderToStaticMarkup(
<AuthContext.Provider value={authValue(role)}>
<SystemSettingsView
sources={sources}
connections={connections}
monitor={monitor}
settings={settings}
productionEnabled={false}
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
loading={false}
saving={false}
error={null}
saveMessage={null}
onSave={vi.fn()}
onSourcesChanged={vi.fn()}
onRefresh={vi.fn()}
initialSection="services"
/>
</AuthContext.Provider>
)
it('keeps the model connection alone in AI 模型连接 and points WeKnora to 知识库映射', () => {
const adminHtml = view('admin')
for (const text of [
'测试地址',
'生产地址',
'生产租户 ID',
'知识库 ID',
'保存并启用服务配置',
'https://weknora.test.example',
'https://weknora.prod.example',
'10000',
'kb-abc123',
'四项留空即表示未配置',
])
for (const text of ['AI 模型连接', '问答评估模型', 'WeKnora 的知识库连接已移到「知识库映射」']) {
expect(adminHtml).toContain(text)
expect(adminHtml).not.toContain('仅管理员可修改')
// 界面只剩这四项:依赖探活矩阵与对内/对外绑定下拉不再出现在服务配置页。
for (const removed of ['MinerU', 'Embedding', 'Redis / MQ', 'PostgreSQL', '测试知识库映射'])
}
// 地址类配置已迁走:这里不再出现 WeKnora 连接表单,也不出现旧的“服务配置”分区名。
for (const removed of ['保存并校验连接', '保存并启用服务配置', '生产租户 ID', '服务配置'])
expect(adminHtml).not.toContain(removed)
const engineerHtml = view('engineer')
expect(engineerHtml).toContain('仅管理员可修改')
expect(engineerHtml).not.toContain('保存并启用服务配置')
expect(engineerHtml).toContain('仅管理员可修改模型连接')
// 工程师看不到模型编辑表单(QAModelSettings 只在管理员下挂载)。
expect(engineerHtml).not.toContain('问答评估模型')
})
})
describe('SystemSettingsView', () => {
@@ -191,7 +174,8 @@ describe('SystemSettingsView', () => {
onRefresh={vi.fn()}
/>
)
for (const text of ['系统设置', '数据源配置', '服务配置', '存储与备份', '刷新策略']) expect(html).toContain(text)
for (const text of ['系统设置', '数据源配置', 'AI 模型连接', '知识库映射', '存储与备份', '刷新策略'])
expect(html).toContain(text)
// 主人 2026-10-26 要求去掉的噪声:页头副标题、刷新状态、权限条、活动版本横幅。
for (const removed of [
'查看内容源、服务与备份状态',
@@ -213,26 +197,41 @@ describe('SystemSettingsView', () => {
expect(html).not.toContain(removed)
// 需求(2026-10-10):新增入口只剩「可加入的来源」勾选,粘贴链接的按钮已下线。
for (const removed of ['+ 新增钉钉知识库', '新增钉钉知识库']) expect(html).not.toContain(removed)
const servicesHtml = renderToStaticMarkup(
<SystemSettingsView
sources={sources}
connections={connections}
monitor={monitor}
settings={settings}
productionEnabled={false}
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
loading={false}
saving={false}
error={null}
saveMessage={null}
onSave={vi.fn()}
onSourcesChanged={vi.fn()}
onRefresh={vi.fn()}
initialSection="services"
/>
// WeKnora 连接已迁到「知识库映射」:地址与核验参数跟入库/封存/生产目标同屏。
const mapHtml = renderToStaticMarkup(
<AuthContext.Provider value={authValue('admin')}>
<SystemSettingsView
sources={sources}
connections={connections}
monitor={monitor}
settings={settings}
productionEnabled={false}
routingCapabilities={{ internal_enabled: true, external_enabled: true }}
loading={false}
saving={false}
error={null}
saveMessage={null}
onSave={vi.fn()}
onSourcesChanged={vi.fn()}
onRefresh={vi.fn()}
initialSection="knowledge-map"
/>
</AuthContext.Provider>
)
for (const text of ['测试 WeKnora', '生产 WeKnora', '测试地址', '生产地址', '生产 ID', '知识库 ID'])
expect(servicesHtml).toContain(text)
for (const text of [
'WeKnora 连接',
'测试 WeKnora',
'生产 WeKnora',
'测试地址',
'生产地址',
'生产租户 ID',
'知识库 ID',
'保存并校验连接',
'生产核验参数',
])
expect(mapHtml).toContain(text)
// 凭据是服务器文件引用:连接卡只报状态,页面不提供 API Key 录入。
expect(mapHtml).not.toContain('API Key')
const storageHtml = renderToStaticMarkup(
<SystemSettingsView
sources={sources}
@@ -291,9 +290,9 @@ describe('SystemSettingsView', () => {
for (const forbidden of ['DATABASE_URL', 'RELEASE_CONFIG_FILE', 'API Key明文', 'secret_ref'])
expect(html).not.toContain(forbidden)
// 两个环境卡仍由真实探测驱动(依赖矩阵搬到总览页,本页不再渲染)。
expect(servicesHtml).toContain('解析队列 对内 已配置 · 对外 已配置')
expect(servicesHtml).not.toContain('PostgreSQL')
expect(servicesHtml).toContain('端点探测:暂无真实探测结果')
expect(mapHtml).toContain('解析队列 对内 已配置 · 对外 已配置')
expect(mapHtml).not.toContain('PostgreSQL')
expect(mapHtml).toContain('端点探测:暂无真实探测结果')
// V1: left-nav section controls, per-source schedule editing, danger modal & history affordances.
expect(html).toContain('settings-nav')
for (const kept of ['更多', '自动刷新中']) expect(html).toContain(kept)
@@ -424,7 +423,7 @@ describe('SystemSettingsView', () => {
onSave={vi.fn()}
onSourcesChanged={vi.fn()}
onRefresh={vi.fn()}
initialSection="services"
initialSection="knowledge-map"
/>
)
const on = view(true, true)
@@ -433,7 +432,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('生产写入:关闭')
@@ -457,7 +456,7 @@ describe('SystemSettingsView', () => {
onSave={vi.fn()}
onSourcesChanged={vi.fn()}
onRefresh={vi.fn()}
initialSection="services"
initialSection="knowledge-map"
/>
)
expect(blocked).toContain('已启用 · 被阻断')
@@ -495,7 +494,7 @@ describe('SystemSettingsView', () => {
onSave={vi.fn()}
onSourcesChanged={vi.fn()}
onRefresh={vi.fn()}
initialSection="services"
initialSection="knowledge-map"
/>
)
expect(unconfigured).toContain('端点探测:未配置')