WIP: preserve failed Codex job issue-485-5cicl5k1
このコミットが含まれているのは:
@@ -2,6 +2,7 @@ import { QueryClient } from '@tanstack/react-query'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { prefetchForURL } from '@/lib/prefetchers'
|
||||
import { postsKeys } from '@/lib/queryKeys'
|
||||
|
||||
const postsApi = vi.hoisted (() => ({
|
||||
fetchPost: vi.fn (),
|
||||
@@ -88,6 +89,42 @@ describe ('prefetchForURL', () => {
|
||||
expect (postsApi.fetchPost).toHaveBeenCalledWith ('12', 'ja')
|
||||
})
|
||||
|
||||
it.each (['/posts/changes', '/ja/posts/changes']) (
|
||||
'prefetches post history with matching filters and cache key at %s', async path => {
|
||||
const client = qc ()
|
||||
const params = { post: '12', page: 2, limit: 5 }
|
||||
const history = { versions: [], count: 7 }
|
||||
postsApi.fetchPostChanges.mockResolvedValueOnce (history)
|
||||
|
||||
await prefetchForURL (client, `${path}?id=12&page=2&limit=5`)
|
||||
|
||||
expect (postsApi.fetchPostChanges).toHaveBeenCalledExactlyOnceWith (params, 'ja')
|
||||
expect (client.getQueryData (postsKeys.changes (params, 'ja'))).toEqual (history)
|
||||
expect (client.getQueryCache ().getAll ()).toHaveLength (1)
|
||||
})
|
||||
|
||||
it ('preserves a tag filter when prefetching one post history', async () => {
|
||||
const client = qc ()
|
||||
const params = { post: '12', tag: '7', page: 1, limit: 20 }
|
||||
|
||||
await prefetchForURL (client, '/ja/posts/changes?id=12&tag=7')
|
||||
|
||||
expect (postsApi.fetchPostChanges).toHaveBeenCalledExactlyOnceWith (params, 'ja')
|
||||
expect (client.getQueryData (postsKeys.changes (params, 'ja')))
|
||||
.toEqual ({ versions: [], count: 0 })
|
||||
})
|
||||
|
||||
it ('prefetches unfiltered post history with its own cache key', async () => {
|
||||
const client = qc ()
|
||||
const params = { page: 2, limit: 5 }
|
||||
|
||||
await prefetchForURL (client, '/ja/posts/changes?page=2&limit=5')
|
||||
|
||||
expect (postsApi.fetchPostChanges).toHaveBeenCalledExactlyOnceWith (params, 'ja')
|
||||
expect (client.getQueryData (postsKeys.changes (params, 'ja')))
|
||||
.toEqual ({ versions: [], count: 0 })
|
||||
})
|
||||
|
||||
it ('prefetches tag indexes from query parameters', async () => {
|
||||
await prefetchForURL (
|
||||
qc (),
|
||||
|
||||
@@ -214,11 +214,11 @@ const prefetchPostChanges: Prefetcher = async (qc, url, locale) => {
|
||||
}
|
||||
|
||||
await qc.prefetchQuery ({
|
||||
queryKey: postsKeys.changes ({ ...(id && { id }),
|
||||
queryKey: postsKeys.changes ({ ...(id && { post: id }),
|
||||
...(tag && { tag }),
|
||||
...(externalTag && { externalTag }),
|
||||
page, limit }, locale),
|
||||
queryFn: () => fetchPostChanges ({ ...(id && { id }),
|
||||
queryFn: () => fetchPostChanges ({ ...(id && { post: id }),
|
||||
...(tag && { tag }),
|
||||
...(externalTag && { externalTag }),
|
||||
page, limit }, locale) })
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする