主人要求:去掉入口,统一成 dws 导入与 PP 导入;其他来源连数据一起下架,之后用 dws 重新获取。
界面(web):
- 「数据源配置」只剩两块:**dws 导入(钉钉)**(按当前钉钉账号列出可访问的知识库与钉盘空间)
与 **PP 导入**(PP 资料下载中心)。上一步加的「显示 AList/钉钉知识库来源」折叠开关删除。
- 来源卡片新增管理员可见的「去掉来源」(带确认弹窗,说明是归档下架、数据保留可恢复)。
- 侧栏文案改成"只留两个入口";发现面板标题改为「dws 导入(钉钉)」。
后端(归档语义,可逆):
- 迁移 000047:source_connections 增 archived_at / archived_by + 只覆盖未归档行的部分索引。
- store:ArchiveSourceConnection / RestoreSourceConnection(幂等;归档同时停用并清空
next_refresh_at,避免被手工改回后立刻带着旧调度跑)。列表、目录、计划刷新(claimDue)、
手动扫描(triggerBlock/inspect)四类查询一律排除归档行。
- 注册路径(dws 重新获取):RegisterDingtalkSpace 的 ON CONFLICT 清掉归档标记 ——
重新登记同一个空间**原地复活同一行**,不产生重复,历史快照仍属于同一行。
- HTTP:POST /api/v1/source-connections/{id}/archive|restore(管理员专属,写意图头
source-archive / source-restore + Idempotency-Key;404 区分"不存在"与"已是目标状态");
openapi 同步两条契约。
验证:
- 集成测试(真 postgres):归档从列表消失但 source_items 一行不少、重复归档不漂移归档时间与人、
未知 ID 报 ErrSourceConnectionNotFound、归档来源不能再被扫描、恢复后回到列表但保持停用;
dws 重新登记同一空间复活同一行。
- httpapi:写意图/幂等键门禁、200/403/404/500、错误体不回显内部细节、classifyRole 管理员专属。
- 迁移护栏:000047 结构 + 四类 SQL 必须含 archived_at is null(漏一条就是入口没去掉)。
- make verify 15/15。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { SystemSettingsView, splitSourceConnections, visibleSaveMessage } from './SystemSettings'
|
||||
import { SystemSettingsView, ppSourceConnections, visibleSaveMessage } from './SystemSettings'
|
||||
import { AuthContext } from './auth'
|
||||
import type { MonitorOverview } from './monitor'
|
||||
import type { CatalogSource } from './sourceCatalog'
|
||||
@@ -193,18 +193,16 @@ describe('SystemSettingsView', () => {
|
||||
'刷新策略',
|
||||
'设置服务已启用',
|
||||
'当前活动版本',
|
||||
'端点与凭据',
|
||||
'文档工程师可调整',
|
||||
'管理员设置已锁定',
|
||||
])
|
||||
expect(html).toContain(text)
|
||||
// 需求(2026-10-14):数据源配置默认只列 PP 资料 + 「可加入的来源」;AList 与钉钉知识库来源
|
||||
// 不删除,收进折叠开关,展开后才渲染(原来它们默认就在列表里)。
|
||||
// 折叠开关自己的文案里就含“钉钉知识库”,所以只核对来源卡片才有的标记。
|
||||
for (const folded of ['公司级技术支持知识库', '专用浏览器扫码会话', '直连 API Token'])
|
||||
expect(html).not.toContain(folded)
|
||||
expect(html).toContain('显示 AList/钉钉知识库来源(1)')
|
||||
expect(html).toContain('这 1 个已接入来源未删除,数据不变')
|
||||
// 需求(2026-10-14 收敛):数据源配置只剩两个入口 —— dws 导入(按当前钉钉账号发现)
|
||||
// 与 PP 导入;AList/静态钉钉知识库等来源类型不再出现在这里(也没有折叠开关兜着)。
|
||||
for (const hidden of ['公司级技术支持知识库', '专用浏览器扫码会话', '显示 AList/钉钉知识库来源'])
|
||||
expect(html).not.toContain(hidden)
|
||||
expect(html).toContain('dws 导入')
|
||||
expect(html).toContain('PP 导入')
|
||||
// 需求(2026-10-10):数据源配置不再做文件格式筛选(格式由目录级标注决定)。
|
||||
for (const removed of ['文件格式筛选', '未勾选的一律不取件', '保存保留格式', '恢复继承上级规则'])
|
||||
expect(html).not.toContain(removed)
|
||||
@@ -293,13 +291,11 @@ describe('SystemSettingsView', () => {
|
||||
expect(servicesHtml).toContain('端点探测:暂无真实探测结果')
|
||||
// V1: left-nav section controls, per-source schedule editing, danger modal & history affordances.
|
||||
expect(html).toContain('settings-nav')
|
||||
expect(html).toContain('查看修订历史')
|
||||
expect(html).toContain('保存并启用')
|
||||
expect(html).toContain('停用中(不入队)')
|
||||
// 卡片级调度/停用按钮仍在,只是默认只对可见来源渲染(钉钉/AList 卡片已折起)。
|
||||
for (const foldedControl of ['下次自动刷新', '保存并启用调度', '停用来源'])
|
||||
expect(html).not.toContain(foldedControl)
|
||||
expect(html).toContain('本地手工导入来源不支持定时刷新')
|
||||
// 非 PP 来源在这里根本不渲染卡片:连它们卡片上的调度、停用、修订入口一起消失。
|
||||
for (const gone of ['查看修订历史', '保存并启用调度', '停用来源', '下次自动刷新']) expect(html).not.toContain(gone)
|
||||
expect(html).toContain('本页只列 PP 来源')
|
||||
// 手工来源(本地手工验收)也不再列在这里,它的专属提示自然不出现。
|
||||
expect(html).not.toContain('本地手工导入来源不支持定时刷新')
|
||||
// dead buttons removed
|
||||
expect(html).not.toContain('添加内容源')
|
||||
expect(html).not.toContain('管理员编辑')
|
||||
@@ -537,38 +533,48 @@ describe('SystemSettingsView 数据源配置的默认清单', () => {
|
||||
next_refresh_at: null,
|
||||
},
|
||||
]
|
||||
const view = () =>
|
||||
const view = (role: 'admin' | 'engineer' = 'admin') =>
|
||||
renderToStaticMarkup(
|
||||
<SystemSettingsView
|
||||
sources={[]}
|
||||
connections={withPP}
|
||||
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()}
|
||||
/>
|
||||
<AuthContext.Provider value={authValue(role)}>
|
||||
<SystemSettingsView
|
||||
sources={[]}
|
||||
connections={withPP}
|
||||
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()}
|
||||
/>
|
||||
</AuthContext.Provider>
|
||||
)
|
||||
it('默认只列 PP 资料:AList 与钉钉知识库来源折起来但没删', () => {
|
||||
it('只有两个入口:PP 来源列在 PP 导入下,AList/钉钉知识库/手工都不出现', () => {
|
||||
const html = view()
|
||||
expect(html).toContain('PP资料下载中心')
|
||||
expect(html).toContain('PP 资料下载中心')
|
||||
expect(html).not.toContain('国内工业')
|
||||
expect(html).not.toContain('ATOM知识库')
|
||||
expect(html).toContain('显示 AList/钉钉知识库来源(2)')
|
||||
// 登记路径说清楚:新来源一律走「可加入的来源」;格式筛选与旧的新增入口继续不存在。
|
||||
expect(html).toContain('可加入的来源')
|
||||
expect(html).toContain('钉盘文件已替代 AList')
|
||||
// 三个非 PP 来源一个都不该渲染,也没有任何折叠开关。
|
||||
for (const hidden of ['国内工业', 'ATOM知识库', '本地手工验收', '显示 AList', '折叠'])
|
||||
expect(html).not.toContain(hidden)
|
||||
expect(html).toContain('dws 导入(钉钉)')
|
||||
expect(html).toContain('PP 导入')
|
||||
expect(html).toContain('去掉来源</button>')
|
||||
expect(html).toContain('端点与凭据')
|
||||
// PP 来源的卡片操作照旧:改刷新周期、启停、看修订历史。
|
||||
for (const kept of ['查看修订历史', '保存并启用调度', '停用来源', '自动刷新周期']) expect(html).toContain(kept)
|
||||
for (const removed of ['+ 新增钉钉知识库', '文件格式筛选']) expect(html).not.toContain(removed)
|
||||
// 文档工程师看不到 dws 导入面板与「去掉来源」:两者都是管理员动作。
|
||||
const engineer = view('engineer')
|
||||
expect(engineer).not.toContain('dws 导入(钉钉)')
|
||||
expect(engineer).not.toContain('去掉来源</button>')
|
||||
expect(engineer).toContain('PP 导入')
|
||||
})
|
||||
})
|
||||
describe('splitSourceConnections(数据源配置的默认清单规则)', () => {
|
||||
describe('ppSourceConnections(数据源配置的清单规则)', () => {
|
||||
const rows: SourceConnectionListItem[] = [
|
||||
{
|
||||
id: 'a',
|
||||
@@ -614,13 +620,20 @@ describe('splitSourceConnections(数据源配置的默认清单规则)', ()
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
{
|
||||
id: 'e',
|
||||
source_type: 'pp',
|
||||
name: 'PP legacy',
|
||||
enabled: false,
|
||||
schedule_configured: false,
|
||||
health_status: 'unknown',
|
||||
item_count: 5,
|
||||
updated_at: '2026-09-09T09:30:32Z',
|
||||
next_refresh_at: null,
|
||||
},
|
||||
]
|
||||
it('默认折起 AList 与钉钉知识库,展开后原样返回(顺序不变、一个不少)', () => {
|
||||
const folded = splitSourceConnections(rows, false)
|
||||
expect(folded.visible.map((item) => item.id)).toEqual(['a', 'd'])
|
||||
expect(folded.legacy.map((item) => item.id)).toEqual(['b', 'c'])
|
||||
const expanded = splitSourceConnections(rows, true)
|
||||
expect(expanded.visible.map((item) => item.id)).toEqual(['a', 'b', 'c', 'd'])
|
||||
expect(expanded.legacy.length).toBe(2)
|
||||
it('只放行 PP 来源,顺序不变,其余类型一条都不放行', () => {
|
||||
expect(ppSourceConnections(rows).map((item) => item.id)).toEqual(['a', 'e'])
|
||||
expect(ppSourceConnections([])).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user