feat(short-drama-agent-front): 完善主体身份骨架屏与交互反馈
This commit is contained in:
1 parent
5fa1c251a9
commit
dd0bd79a35
19 files changed
+1552
-419
No files matched your search
@@ -1,6 +1,18 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { getOperation, runOperation } from '@/features/workflows/operations'
|
||||
|
||||
/**
|
||||
* 根据真实校验值决定消息,不能只依据 Promise 成功。
|
||||
* @param result 后端业务校验结果
|
||||
* @returns 与通过状态相符的临时反馈
|
||||
*/
|
||||
function validationFeedback(result: { passed: boolean }) {
|
||||
return {
|
||||
type: result.passed ? ('success' as const) : ('warning' as const),
|
||||
content: result.passed ? '身份图片校验通过' : '身份图片校验未通过'
|
||||
}
|
||||
}
|
||||
|
||||
describe('项目级长请求互斥', () => {
|
||||
it('同一项目不同时执行两个 graph,错误不伪装成功', async () => {
|
||||
let fail!: (reason: Error) => void
|
||||
@@ -17,4 +29,36 @@ describe('项目级长请求互斥', () => {
|
||||
expect(await first).toBe(false)
|
||||
expect(getOperation('operation-test')).toMatchObject({ pending: false, error: '连接中断', notice: '' })
|
||||
})
|
||||
|
||||
it('HTTP 成功但业务校验未通过时保留警告语义,再次通过时更新结果', async () => {
|
||||
const projectId = 'operation-validation-test'
|
||||
expect(await runOperation(projectId, '校验', async () => ({ passed: false }), validationFeedback)).toBe(true)
|
||||
expect(getOperation(projectId)).toMatchObject({
|
||||
noticeType: 'warning',
|
||||
notice: '身份图片校验未通过',
|
||||
pending: false
|
||||
})
|
||||
expect(await runOperation(projectId, '校验', async () => ({ passed: true }), validationFeedback)).toBe(true)
|
||||
expect(getOperation(projectId)).toMatchObject({ noticeType: 'success', notice: '身份图片校验通过' })
|
||||
expect(
|
||||
await runOperation(
|
||||
projectId,
|
||||
'校验',
|
||||
async () => {
|
||||
throw new Error('服务不可用')
|
||||
},
|
||||
validationFeedback
|
||||
)
|
||||
).toBe(false)
|
||||
expect(getOperation(projectId)).toMatchObject({ noticeType: null, notice: '', error: '服务不可用' })
|
||||
})
|
||||
|
||||
it('异步任务提交只提示已提交,不提前提示生成完成', async () => {
|
||||
const projectId = 'operation-submission-test'
|
||||
await runOperation(projectId, '提交图片生成', async () => ({ status: 'pending' }), {
|
||||
type: 'info',
|
||||
content: '任务已提交生成'
|
||||
})
|
||||
expect(getOperation(projectId)).toMatchObject({ noticeType: 'info', notice: '任务已提交生成' })
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user