test: 覆盖手部诊断关闭弹窗后的迟到响应隔离

This commit is contained in:
GouJ committed 2026-10-16 10:08:23 +08:00
1 parent beb39479f2
commit cde5322cab
1 file changed
+33
@@ -478,6 +478,39 @@ describe('拆解页内容滚动', () => {
expect(panel.text()).toContain('证据不足')
})
it('关闭弹窗后迟到的诊断响应不会污染再次打开的状态', async () => {
let resolveRequest: ((value: Response) => void) | undefined
const fetcher = vi.fn<typeof fetch>().mockImplementation(() => new Promise<Response>(resolve => {
resolveRequest = resolve
}))
vi.stubGlobal('fetch', fetcher)
mountPage()
await wrapper!.get('[data-workspace-tools]').trigger('click')
await flushPromises()
const action = drawerPanel().findAll('button').find(button => button.text() === '查看诊断')
expect(action).toBeDefined()
await action!.trigger('click')
expect(fetcher).toHaveBeenCalledTimes(1)
await drawerPanel().get('.n-card-header__close').trigger('click')
await flushPromises()
resolveRequest!(new Response(JSON.stringify({
data: {
projectId: 'breakdown-scroll-test', episodeCount: 1,
shotCount: 25, validSnapshotCount: 25,
evidenceShotCount: 25, invalidEvidenceShotCount: 0,
missingEvidenceShotCount: 0, evidenceCoverage: 1,
assessment: 'complete_evidence', warningCount: 0,
diagnostics: [], willCallModel: false, willModifyAssets: false
}
}), { status: 200, headers: { 'Content-Type': 'application/json' } }))
await flushPromises()
await wrapper!.get('[data-workspace-tools]').trigger('click')
await flushPromises()
expect(drawerPanel().text()).not.toContain('有效证据 25 / 25')
expect(drawerPanel().findAll('button').some(button => button.text() === '查看诊断')).toBe(true)
expect(fetcher).toHaveBeenCalledTimes(1)
})
it('没有正式剧集时保留可滚动的空状态,不显示拆解设置与结果', () => {
mountPage([], 0)
expect(wrapper!.get('.panel-scroll .n-scrollbar-container').text()).toContain('还没有可拆解的剧集')