All checks were successful
CI / test (push) Successful in 3m58s
评估列表页(v4.2): - 顶部状态统计条(stat-chip 点击筛选,后端列表接口新增 stats 状态分布 + status 筛选参数) - 单行表格(名称/评测对象 ellipsis 省略)+ 会话进度迷你进度条 + 最后一列醒目查看按钮 + 整行可点击 - 详情/报告合一单层抽屉(1000px,Tabs:概览/决策过程/配置历史/报告), 审批/取消在抽屉头部;移除独立详情页 /intelligent-evals/detail 与 intelligentEvalNav store 任务队列页: - 与列表页统一 stat-chip 统计条 + 单行表格(评估状态小标、失败原因 tooltip) 清理:删除 IntelligentEvalDetail.tsx / intelligentEvalNav.ts;App.tsx 移除 detail 路由。任务队列保持独立菜单页。tsc 0 错误 vitest 19 passed 895 passed
81 lines
2.7 KiB
TypeScript
81 lines
2.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
initialIntelligentEvalReadState,
|
|
intelligentEvalReadReducer,
|
|
type IntelligentEvalReadState,
|
|
} from './intelligentEval'
|
|
|
|
const evaluation = { id: 'eval-1', name: '评估', status: 'planning' } as never
|
|
|
|
describe('intelligent evaluation read state', () => {
|
|
it('represents initial loading and a complete list snapshot', () => {
|
|
const loading = intelligentEvalReadReducer(initialIntelligentEvalReadState, { type: 'list_requested' })
|
|
expect(loading.list.phase).toBe('loading')
|
|
|
|
const ready = intelligentEvalReadReducer(loading, {
|
|
type: 'list_succeeded',
|
|
value: [evaluation],
|
|
total: 42,
|
|
stats: { planning: 1 },
|
|
})
|
|
expect(ready.list).toEqual({ phase: 'ready', value: [evaluation], error: null, total: 42, stats: { planning: 1 } })
|
|
})
|
|
|
|
it('keeps the last list snapshot during silent refresh and failure', () => {
|
|
const ready: IntelligentEvalReadState = {
|
|
...initialIntelligentEvalReadState,
|
|
list: { phase: 'ready', value: [evaluation], error: null, total: 1, stats: null },
|
|
}
|
|
const refreshing = intelligentEvalReadReducer(ready, { type: 'list_requested', silent: true })
|
|
expect(refreshing.list.phase).toBe('refreshing')
|
|
expect(refreshing.list.total).toBe(1)
|
|
|
|
const afterFailure = intelligentEvalReadReducer(refreshing, { type: 'list_failed', error: '网络错误' })
|
|
expect(afterFailure.list).toEqual({ phase: 'ready', value: [evaluation], error: null, total: 1, stats: null })
|
|
})
|
|
|
|
it('surfaces an initial detail failure without an existing snapshot', () => {
|
|
const loading = intelligentEvalReadReducer(initialIntelligentEvalReadState, {
|
|
type: 'detail_requested',
|
|
id: 'eval-1',
|
|
requestId: 1,
|
|
})
|
|
const failed = intelligentEvalReadReducer(loading, {
|
|
type: 'detail_failed',
|
|
id: 'eval-1',
|
|
requestId: 1,
|
|
error: '不存在',
|
|
})
|
|
expect(failed.detail).toEqual({
|
|
phase: 'error',
|
|
value: null,
|
|
error: '不存在',
|
|
selectedId: 'eval-1',
|
|
requestId: 1,
|
|
})
|
|
})
|
|
|
|
it('ignores a stale detail response after the selection changes', () => {
|
|
const first = intelligentEvalReadReducer(initialIntelligentEvalReadState, {
|
|
type: 'detail_requested',
|
|
id: 'eval-1',
|
|
requestId: 1,
|
|
})
|
|
const second = intelligentEvalReadReducer(first, {
|
|
type: 'detail_requested',
|
|
id: 'eval-2',
|
|
requestId: 2,
|
|
})
|
|
const stale = intelligentEvalReadReducer(second, {
|
|
type: 'detail_succeeded',
|
|
id: 'eval-1',
|
|
requestId: 1,
|
|
value: evaluation,
|
|
})
|
|
|
|
expect(stale).toBe(second)
|
|
expect(stale.detail.value).toBeNull()
|
|
expect(stale.detail.selectedId).toBe('eval-2')
|
|
})
|
|
})
|