WIP: unverified Codex job issue-485-obzs08at
このコミットが含まれているのは:
@@ -418,6 +418,37 @@ test ('YouTube posts return HTTP 200 with the embed rendered by SSR', async t =>
|
||||
}
|
||||
})
|
||||
|
||||
test ('post history HTTP requests preserve filters for every role', async t => {
|
||||
const accounts = [
|
||||
{ role: 'guest', cookie: null },
|
||||
{ role: 'member', cookie: await authenticatedCookie ('second-recovery-secret') },
|
||||
{ role: 'admin', cookie: await authenticatedCookie () }]
|
||||
for (const account of accounts) {
|
||||
for (const prefix of ['', '/ja', '/ain-Kana']) {
|
||||
await t.test (`${account.role} ${prefix || 'no locale prefix'}`, async () => {
|
||||
for (const query of ['', '?id=1&page=2&limit=5']) {
|
||||
const start = requests.length
|
||||
const response = await fetch (
|
||||
`${httpOrigin}${prefix}/posts/changes${query}`, {
|
||||
headers: account.cookie == null ? {} : { Cookie: account.cookie } })
|
||||
assert.equal (response.status, 200)
|
||||
const html = await response.text ()
|
||||
assert.match (html, /<table/)
|
||||
assert.doesNotMatch (html, /Switched to client rendering|template id="B:/)
|
||||
const calls = requests.slice (start).map (request => new URL (request.url, apiURL))
|
||||
.filter (url => url.pathname === '/posts/versions')
|
||||
assert.equal (calls.length, 1)
|
||||
assert.equal (calls[0].searchParams.get ('post'), query ? '1' : null)
|
||||
assert.equal (calls[0].searchParams.get ('page'), query ? '2' : '1')
|
||||
assert.equal (calls[0].searchParams.get ('limit'), query ? '5' : '20')
|
||||
assert.equal (calls[0].searchParams.get ('locale'), prefix === '/ain-Kana'
|
||||
? 'ain-Kana' : 'ja')
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
test ('parallel localized requests keep list data isolated', async () => {
|
||||
const start = requests.length
|
||||
const pages = await Promise.all (['ja', 'ain-Kana', 'ja', 'ain-Kana'].map (locale =>
|
||||
|
||||
@@ -127,15 +127,23 @@ describe ('prefetchForURL', () => {
|
||||
.toEqual ({ versions: [], count: 0 })
|
||||
})
|
||||
|
||||
it ('prefetches unfiltered post history with its own cache key', async () => {
|
||||
it ('keeps one post history separate from unfiltered history in the cache', async () => {
|
||||
const client = qc ()
|
||||
const params = { page: 2, limit: 5 }
|
||||
const postParams = { ...params, post: '12' }
|
||||
const history = { versions: [], count: 7 }
|
||||
postsApi.fetchPostChanges.mockResolvedValueOnce (history)
|
||||
|
||||
await prefetchForURL (client, '/ja/posts/changes?id=12&page=2&limit=5')
|
||||
await prefetchForURL (client, '/ja/posts/changes?page=2&limit=5')
|
||||
|
||||
expect (postsApi.fetchPostChanges).toHaveBeenCalledExactlyOnceWith (params, 'ja')
|
||||
expect (postsApi.fetchPostChanges).toHaveBeenCalledTimes (2)
|
||||
expect (postsApi.fetchPostChanges).toHaveBeenNthCalledWith (1, postParams, 'ja')
|
||||
expect (postsApi.fetchPostChanges).toHaveBeenNthCalledWith (2, params, 'ja')
|
||||
expect (client.getQueryData (postsKeys.changes (postParams, 'ja'))).toEqual (history)
|
||||
expect (client.getQueryData (postsKeys.changes (params, 'ja')))
|
||||
.toEqual ({ versions: [], count: 0 })
|
||||
expect (client.getQueryCache ().getAll ()).toHaveLength (2)
|
||||
})
|
||||
|
||||
it ('prefetches tag indexes from query parameters', async () => {
|
||||
|
||||
@@ -21,7 +21,9 @@ if (typeof originalTransform === 'function')
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig ({
|
||||
export default defineConfig (({ command }) => ({
|
||||
// Production React does not provide jsxDEV, regardless of the build environment.
|
||||
esbuild: command === 'build' ? { jsxDev: false } : undefined,
|
||||
plugins: [{ name: 'request-render-context', enforce: 'pre',
|
||||
resolveId (id, _importer, options) {
|
||||
const contextPath = path.resolve (__dirname, './src/lib/renderContext')
|
||||
@@ -40,4 +42,4 @@ export default defineConfig ({
|
||||
rewrite: requestPath => requestPath.replace (/^\/api/, ''),
|
||||
secure: false } },
|
||||
watch: { usePolling: true,
|
||||
interval: 100 } } })
|
||||
interval: 100 } } }))
|
||||
|
||||
@@ -3,11 +3,10 @@ import { defineConfig, mergeConfig } from 'vitest/config'
|
||||
import viteConfig from './vite.config'
|
||||
|
||||
|
||||
export default mergeConfig (
|
||||
viteConfig,
|
||||
defineConfig ({
|
||||
test: { environment: 'jsdom',
|
||||
testTimeout: 30_000,
|
||||
exclude: ['**/node_modules/**', '**/dist/**', 'server.ssr.test.mjs'],
|
||||
setupFiles: './src/test/setup.ts',
|
||||
globals: false } }))
|
||||
export default defineConfig (env => mergeConfig (
|
||||
viteConfig (env),
|
||||
{ test: { environment: 'jsdom',
|
||||
testTimeout: 30_000,
|
||||
exclude: ['**/node_modules/**', '**/dist/**', 'server.ssr.test.mjs'],
|
||||
setupFiles: './src/test/setup.ts',
|
||||
globals: false } }))
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする