このコミットが含まれているのは:
@@ -162,4 +162,40 @@ describe ('api helpers', () => {
|
||||
await apiPatch ('/posts/1')
|
||||
expect (mocks.client.get).toHaveBeenCalledTimes (2)
|
||||
})
|
||||
it ('aborts one write while a shared CSRF lookup remains pending for another write', async () => {
|
||||
let complete!: (value: { data: { token: string } }) => void
|
||||
mocks.client.get.mockReturnValueOnce (new Promise (resolve => { complete = resolve }))
|
||||
const { apiPost } = await import ('@/lib/api')
|
||||
const controller = new AbortController ()
|
||||
const first = apiPost ('/counts/export/jobs', {}, { signal: controller.signal })
|
||||
const second = apiPost ('/posts', {})
|
||||
const rejected = expect (first).rejects.toMatchObject ({ name: 'AbortError' })
|
||||
controller.abort ()
|
||||
await rejected
|
||||
complete ({ data: { token: 'shared' } })
|
||||
await second
|
||||
expect (mocks.client.get).toHaveBeenCalledWith ('/users/csrf',
|
||||
expect.objectContaining ({ timeout: 15_000 }))
|
||||
expect (mocks.client.post).toHaveBeenCalledTimes (1)
|
||||
expect (mocks.client.post.mock.calls[0][0]).toBe ('/posts')
|
||||
})
|
||||
|
||||
it ('releases native download frames after failure or explicit cancellation', async () => {
|
||||
const { startAPIDownload } = await import ('@/lib/api')
|
||||
const failure = vi.fn ()
|
||||
const release = startAPIDownload ('/counts/export', 'file', failure,
|
||||
new URLSearchParams ({ job: 'job', attempt: 'attempt' }))
|
||||
const frame = document.querySelector ('iframe')!
|
||||
expect (new URL (frame.src).searchParams.get ('attempt')).toBe ('attempt')
|
||||
frame.dispatchEvent (new Event ('error'))
|
||||
frame.dispatchEvent (new Event ('error'))
|
||||
expect (failure).toHaveBeenCalledTimes (1)
|
||||
expect (frame).not.toBeInTheDocument ()
|
||||
release ()
|
||||
const cancel = startAPIDownload ('/counts/export', 'file', failure)
|
||||
cancel ()
|
||||
expect (document.querySelector ('iframe')).toBeNull ()
|
||||
expect (failure).toHaveBeenCalledTimes (1)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする