fix(ui): 已释放窗口不再渲染 held 文案,版本页不再把 500 说成未接线
build / build (push) Failing after 18s

发布管理:maintenanceSummary 只看 job.state === 'failed' 就给 held 处置文案;
窗口已 released 的旧作业(libsync-internal-1793399248431728863)因此自相矛盾。
改为仅 held 时给 recoveryError,已释放时给 releasedFailure(如实记录失败,不提供强制成功)。

版本记录:LoadVersionHistorySyncState 把可空的 finished_at 扫进 time.Time;
部署重启触发的同步在"进行中"时该列为 NULL,扫描失败使整页 500
(nginx access log:GET /api/v1/version-history?limit=30 → 500,74 字节错误体)。
改为指针接值再判空。前端同时区分"未配置/加载失败"并显示服务端 code。

RED/GREEN:新增 Go 集成用例(NULL finished_at)、两条前端用例;
make verify 16/16 通过(local 档案)。
This commit is contained in:
姚章浩
2026-11-01 19:34:31 +08:00
parent 943b617b1f
commit e34306b2db
76 changed files with 12038 additions and 2505 deletions
+55 -10
View File
@@ -5,9 +5,27 @@ import { discoveryCandidates, driveSpaceURL, fetchAvailableDingtalkSources } fro
const payload = {
data: {
knowledge_bases: [
{ name: 'ATOM知识库', space_id: '9JOGOQneRgkneX4Q', space_type: 'orgWikiSpace', url: 'https://alidocs.dingtalk.com/i/spaces/9JOGOQneRgkneX4Q/overview', description: '' },
{ name: '视觉文档', space_id: '9JOGO9EEOMLMWX4Q', space_type: 'orgWikiSpace', url: '', description: '2d/2.5D/3D 视觉' },
{ name: '我的文档', space_id: '9JOGOxeo90ybnz4Q', space_type: 'myWikiSpace', url: 'https://alidocs.dingtalk.com/i/spaces/9JOGOxeo90ybnz4Q/overview', description: '' },
{
name: 'ATOM知识库',
space_id: '9JOGOQneRgkneX4Q',
space_type: 'orgWikiSpace',
url: 'https://alidocs.dingtalk.com/i/spaces/9JOGOQneRgkneX4Q/overview',
description: '',
},
{
name: '视觉文档',
space_id: '9JOGO9EEOMLMWX4Q',
space_type: 'orgWikiSpace',
url: '',
description: '2d/2.5D/3D 视觉',
},
{
name: '我的文档',
space_id: '9JOGOxeo90ybnz4Q',
space_type: 'myWikiSpace',
url: 'https://alidocs.dingtalk.com/i/spaces/9JOGOxeo90ybnz4Q/overview',
description: '',
},
],
drive_spaces: [
{ name: '我的文件', space_id: '28122692916', space_type: 'mySpace', root_folder_id: '65Y1OQX0' },
@@ -25,7 +43,10 @@ afterEach(() => {
describe('fetchAvailableDingtalkSources', () => {
it('parses knowledge bases and drive spaces', async () => {
vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify(payload), { status: 200 })))
vi.stubGlobal(
'fetch',
vi.fn(async () => new Response(JSON.stringify(payload), { status: 200 }))
)
const list = await fetchAvailableDingtalkSources()
expect(list.knowledge_bases).toHaveLength(3)
expect(list.knowledge_bases[1].url).toBe('https://alidocs.dingtalk.com/i/spaces/9JOGO9EEOMLMWX4Q/overview')
@@ -36,16 +57,36 @@ describe('fetchAvailableDingtalkSources', () => {
})
it('explains environment problems instead of pretending the list is empty', async () => {
vi.stubGlobal('fetch', vi.fn(async () => new Response('{"error":"dingtalk_discovery_unavailable"}', { status: 503 })))
vi.stubGlobal(
'fetch',
vi.fn(async () => new Response('{"error":"dingtalk_discovery_unavailable"}', { status: 503 }))
)
await expect(fetchAvailableDingtalkSources()).rejects.toThrow(/暂时列不出来/)
vi.stubGlobal('fetch', vi.fn(async () => new Response('{}', { status: 501 })))
vi.stubGlobal(
'fetch',
vi.fn(async () => new Response('{}', { status: 501 }))
)
await expect(fetchAvailableDingtalkSources()).rejects.toThrow(/后端未接线/)
vi.stubGlobal('fetch', vi.fn(async () => new Response('{}', { status: 403 })))
vi.stubGlobal(
'fetch',
vi.fn(async () => new Response('{}', { status: 403 }))
)
await expect(fetchAvailableDingtalkSources()).rejects.toThrow(/需要管理员身份/)
})
it('carries the drive notice so the page can explain a missing 钉盘 list', async () => {
vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify({ data: { knowledge_bases: [], drive_spaces: [], drive_notice: 'list orgSpace: permission denied' } }), { status: 200 })))
vi.stubGlobal(
'fetch',
vi.fn(
async () =>
new Response(
JSON.stringify({
data: { knowledge_bases: [], drive_spaces: [], drive_notice: 'list orgSpace: permission denied' },
}),
{ status: 200 }
)
)
)
const list = await fetchAvailableDingtalkSources()
expect(list.drive_notice).toContain('permission denied')
})
@@ -55,7 +96,11 @@ describe('discoveryCandidates', () => {
it('flattens both groups and marks the ones already registered as sources', () => {
const candidates = discoveryCandidates(payload.data as never, ['ATOM知识库', ' (空名字) '])
expect(candidates.map((item) => item.key)).toEqual([
'kb:9JOGOQneRgkneX4Q', 'kb:9JOGO9EEOMLMWX4Q', 'kb:9JOGOxeo90ybnz4Q', 'drive:28122692916', 'drive:102571304',
'kb:9JOGOQneRgkneX4Q',
'kb:9JOGO9EEOMLMWX4Q',
'kb:9JOGOxeo90ybnz4Q',
'drive:28122692916',
'drive:102571304',
])
expect(candidates[0].alreadyRegistered).toBe(true)
expect(candidates[1].alreadyRegistered).toBe(false)
@@ -69,4 +114,4 @@ describe('discoveryCandidates', () => {
it('returns nothing for an empty list', () => {
expect(discoveryCandidates(null, ['X'])).toEqual([])
})
})
})