feat: 活跃会话拦截补结束与放弃出口

This commit is contained in:
2026-10-09 12:42:59 +08:00
parent 87e4ceab11
commit 25fbc67ad2
4 changed files with 372 additions and 15 deletions
+13 -2
View File
@@ -149,16 +149,27 @@ describe('StartTask.vue', () => {
wrapper.unmount()
})
it('redirects to another active task when one exists', async () => {
it('redirects to another active task only after the user picks 前往继续', async () => {
vi.mocked(getActiveSession).mockResolvedValue({
code: 200,
data: { taskNum: 'T002', taskName: '其他任务', sessionNum: 'S002' },
} as any)
const pushSpy = vi.spyOn(router, 'push').mockResolvedValue()
const wrapper = await mountTask()
await flushPromises()
// 会话-05:拦截弹窗出现,用户未选出口前不开始、也不跳转
expect(wrapper.vm.conflictSession?.taskNum).toBe('T002')
expect(startOrContinueStudySession).not.toHaveBeenCalled()
expect(router.currentRoute.value.path).toBe('/start-task/T002')
expect(pushSpy).not.toHaveBeenCalled()
// 执行「前往继续」出口
wrapper.vm.resolveConflict('continue')
await flushPromises()
expect(pushSpy).toHaveBeenCalledWith('/start-task/T002')
expect(startOrContinueStudySession).not.toHaveBeenCalled()
pushSpy.mockRestore()
wrapper.unmount()
})