2026-11-10 21:36:09 +08:00
|
|
|
import { afterEach, expect, it, vi } from 'vitest'
|
|
|
|
|
import { createSSRApp, defineComponent, h } from 'vue'
|
|
|
|
|
import { renderToString } from 'vue/server-renderer'
|
|
|
|
|
import { createPinia } from 'pinia'
|
|
|
|
|
import JobDetail from './JobDetail.vue'
|
|
|
|
|
import { api } from '../api'
|
|
|
|
|
|
|
|
|
|
vi.mock('./AssetPreview.vue', () => ({ default: { render: () => null } }))
|
|
|
|
|
|
|
|
|
|
afterEach(() => vi.restoreAllMocks())
|
|
|
|
|
|
|
|
|
|
it('fetches an initially selected deep-linked task without depending on recent-list cache', async () => {
|
|
|
|
|
const request = vi.spyOn(api, 'job').mockReturnValue(new Promise(() => {}))
|
|
|
|
|
const application = createSSRApp(JobDetail, { jobId: 'archived-owned-job' })
|
|
|
|
|
application.use(createPinia())
|
2026-11-14 14:07:26 +08:00
|
|
|
application.component(
|
|
|
|
|
'ElDrawer',
|
|
|
|
|
defineComponent({
|
|
|
|
|
setup:
|
|
|
|
|
(_, { slots }) =>
|
|
|
|
|
() =>
|
|
|
|
|
h('aside', slots.default?.()),
|
|
|
|
|
}),
|
|
|
|
|
)
|
2026-11-10 21:36:09 +08:00
|
|
|
application.component('ElProgress', { render: () => null })
|
|
|
|
|
application.component('ElButton', { render: () => null })
|
|
|
|
|
application.directive('loading', {})
|
|
|
|
|
await renderToString(application)
|
|
|
|
|
expect(request).toHaveBeenCalledExactlyOnceWith('archived-owned-job')
|
|
|
|
|
})
|