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
@@ -106,7 +106,66 @@ async function openProject(initialPath: string) {
|
||||
}
|
||||
|
||||
describe('剧本完成前的下游访问限制', () => {
|
||||
it.each(['breakdown', 'visual-style'] as const)(
|
||||
it('身份请求加载、成功和失败均使用临时消息,切换主体不遗留横幅', async () => {
|
||||
vi.useFakeTimers()
|
||||
const id = 'identity-message-test'
|
||||
vi.spyOn(projectsApi, 'detail').mockResolvedValue(project(id, 'completed'))
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([])
|
||||
const operation = getOperation(id)
|
||||
Object.assign(operation, { pending: false, label: 'AI 生成主体身份', error: '', notice: '旧成功提示' })
|
||||
const { router } = await openProject(`/projects/${id}/subject-identity`)
|
||||
expect(wrapper!.text()).not.toContain('旧成功提示')
|
||||
expect(document.querySelector('.n-message')).toBeNull()
|
||||
Object.assign(operation, { pending: true, notice: '' })
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.project-notices').exists()).toBe(false)
|
||||
expect(document.querySelector('.n-message--loading-type')!.textContent).toContain('AI 生成主体身份,请稍候')
|
||||
await router.replace({ query: { subjectId: 'second-subject' } })
|
||||
Object.assign(operation, {
|
||||
pending: false,
|
||||
notice: '请求已返回,正在重新读取后端状态;最终结果以下方记录为准。'
|
||||
})
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.n-message--success-type')!.textContent).toContain('身份文本已生成并保存')
|
||||
expect(wrapper!.find('.project-notices').exists()).toBe(false)
|
||||
expect(operation.notice).toBe('')
|
||||
await vi.advanceTimersByTimeAsync(4000)
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.n-message')).toBeNull()
|
||||
await router.replace({ query: { subjectId: 'third-subject' } })
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.n-message')).toBeNull()
|
||||
expect(wrapper!.find('.project-notices').exists()).toBe(false)
|
||||
operation.error = '模型不可用,请稍后重试'
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('.operation-guide').exists()).toBe(false)
|
||||
expect(document.querySelector('.n-message--error-type')!.textContent).toContain('模型不可用')
|
||||
Object.assign(operation, { error: '', notice: '', pending: false })
|
||||
})
|
||||
|
||||
it('图片校验未通过显示警告而非成功,关闭消息后不遗留校验结果块', async () => {
|
||||
vi.useFakeTimers()
|
||||
const id = 'identity-warning-test'
|
||||
vi.spyOn(projectsApi, 'detail').mockResolvedValue(project(id, 'completed'))
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([])
|
||||
await openProject(`/projects/${id}/subject-identity`)
|
||||
const operation = getOperation(id)
|
||||
Object.assign(operation, {
|
||||
label: '校验林夏身份图片',
|
||||
noticeType: 'warning',
|
||||
notice: '林夏的身份图片校验未通过:面部模糊'
|
||||
})
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.n-message--warning-type')!.textContent).toContain('校验未通过:面部模糊')
|
||||
expect(document.querySelector('.n-message--success-type')).toBeNull()
|
||||
expect(wrapper!.find('.project-notices').exists()).toBe(false)
|
||||
expect(operation).toMatchObject({ notice: '', noticeType: null })
|
||||
await vi.advanceTimersByTimeAsync(9000)
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.n-message')).toBeNull()
|
||||
})
|
||||
|
||||
it.each(['breakdown', 'visual-style', 'subject-identity'] as const)(
|
||||
'%s 首次读取显示骨架,刷新保留已有内容,切换项目完成后仍遵守访问限制',
|
||||
async section => {
|
||||
/** 延迟真实查询入口,覆盖初次读取、后台刷新和跨项目读取三个阶段。 */
|
||||
@@ -118,7 +177,12 @@ describe('剧本完成前的下游访问限制', () => {
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([])
|
||||
vi.mocked(projectsApi.stageReadiness).mockImplementation(async id => readiness(id, id === 'skeleton-first'))
|
||||
const { router, mounted } = await openProject(`/projects/skeleton-first/${section}`)
|
||||
const skeleton = section === 'breakdown' ? '.breakdown-skeleton' : '.visual-style-skeleton'
|
||||
const skeleton =
|
||||
section === 'subject-identity'
|
||||
? '.subject-identity-skeleton'
|
||||
: section === 'breakdown'
|
||||
? '.breakdown-skeleton'
|
||||
: '.visual-style-skeleton'
|
||||
expect(wrapper!.get(skeleton).attributes('aria-busy')).toBe('true')
|
||||
expect(wrapper!.find('.workspace-loading').exists()).toBe(false)
|
||||
expect(wrapper!.get('.project-title').text()).toBe('')
|
||||
|
||||
Reference in new issue
Block a user