feat: 开始任务直接跳转并补会话页加载
This commit is contained in:
@@ -8,6 +8,7 @@ import router from '@/router'
|
||||
import {
|
||||
continueSession,
|
||||
endSession,
|
||||
getActiveSession,
|
||||
getExpectation,
|
||||
getSessionDetail,
|
||||
pauseSession,
|
||||
@@ -18,6 +19,7 @@ import { getFragmentsBySession } from '@/api/reportFragments'
|
||||
vi.mock('@/api/studySessions', () => ({
|
||||
continueSession: vi.fn(),
|
||||
endSession: vi.fn(),
|
||||
getActiveSession: vi.fn(),
|
||||
getExpectation: vi.fn(),
|
||||
getReportDraft: vi.fn(),
|
||||
getSessionDetail: vi.fn(),
|
||||
@@ -78,6 +80,7 @@ describe('StartTask.vue', () => {
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks()
|
||||
localStorage.clear()
|
||||
vi.mocked(getActiveSession).mockResolvedValue({ code: 200, data: null } as any)
|
||||
vi.mocked(startOrContinueStudySession).mockResolvedValue({ code: 200, data: defaultSessionData } as any)
|
||||
vi.mocked(getExpectation).mockResolvedValue({ code: 200, data: { description: '本次学习预期' } } as any)
|
||||
vi.mocked(getFragmentsBySession).mockResolvedValue({ code: 200, data: [] } as any)
|
||||
@@ -142,6 +145,19 @@ describe('StartTask.vue', () => {
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('redirects to another active task when one exists', async () => {
|
||||
vi.mocked(getActiveSession).mockResolvedValue({
|
||||
code: 200,
|
||||
data: { taskNum: 'T002', taskName: '其他任务', sessionNum: 'S002' },
|
||||
} as any)
|
||||
const wrapper = await mountTask()
|
||||
await flushPromises()
|
||||
|
||||
expect(startOrContinueStudySession).not.toHaveBeenCalled()
|
||||
expect(router.currentRoute.value.path).toBe('/start-task/T002')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('endTimer refuses empty content without calling API', async () => {
|
||||
const wrapper = await mountTask()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user