AI: #487 noindex の劇場詳細ページが sitemap に掲載される #490

オープン
テツノニジカ が feature/487 から main への 5 コミットのマージを希望しています
5個のファイルの変更、31行の追加、9行の削除
+21 -2
ファイルの表示
@@ -1,10 +1,11 @@
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import { createServer } from 'node:http'
import { spawn } from 'node:child_process'
import { after, before, test } from 'node:test'
import { createServer as createViteServer } from 'vite'
import { render } from './dist/server/entry-server.js'
import { render, renderSitemap } from './dist/server/entry-server.js'
const origin = 'https://ssr.example.invalid'
const date = '2026-09-15T00:00:00+09:00'
@@ -332,6 +333,12 @@ after (async () => {
if (errors.length) throw new AggregateError (errors, 'SSR teardown failed')
})
test ('SSR bundle uses JSX compatible with production React', async () => {
const bundle = await readFile (
new URL ('./dist/server/entry-server.js', import.meta.url), 'utf8')
assert.doesNotMatch (bundle, /react\/jsx-dev-runtime|\bjsxDEV\b/)
})
test ('counts SSR renders the shell without result requests or embedded results', async () => {
for (const locale of ['ja', 'ain-Kana']) {
for (const [resource, mode] of ['posts', 'tags'].flatMap (resource =>
@@ -366,6 +373,15 @@ test ('counts SSR renders the shell without result requests or embedded results'
}
})
test ('noindex theatre routes are absent from sitemap', async () => {
const start = requests.length
const result = await renderSitemap ('/sitemap-ja-theatres-1.xml', origin, apiURL)
const calls = requests.slice (start).map (request => new URL (request.url, origin))
assert.equal (result.status, 404)
assert.equal (calls.some (url => url.pathname === '/sitemap_entries/theatres'), false)
})
test ('every canonical screen route returns page HTML without JavaScript', async t => {
const cookie = await authenticatedCookie ()
for (const route of routes) {
@@ -393,7 +409,10 @@ test ('every canonical screen route returns page HTML without JavaScript', async
if (route.path === 'posts/:id')
assert.match (result.head, new RegExp (`SSR post ${locale}`))
if (route.path === 'theatres/:id')
assert.match (result.html.replace (/<[^>]*>/g, ''), /SSR[  ]theatre/)
{
assert.match (result.html.replace (/<[^>]*>/g, ''), /SSR[  ]theatre/)
assert.equal (route.handle?.robots, 'noindex')
}
if (route.path === 'wiki' || route.path === 'wiki/:title')
assert.match (result.html, new RegExp (`SSR wiki body ${locale}|SSR`))
assert.doesNotMatch (result.html, /Switched to client rendering|template id="B:/)
+2 -1
ファイルの表示
@@ -152,7 +152,8 @@ export const pageRoutes = (
{ path: 'tags/changes', element: <TagHistoryPage/>,
handle: { preload: TagHistoryPage.preload } },
{ path: 'theatres/:id', element: <TheatreDetailPage user={user}/>,
handle: { preload: TheatreDetailPage.preload, sitemap: ['theatres'] } },
handle: { preload: TheatreDetailPage.preload, robots: 'noindex',
sitemap: ['theatres'] } },
{ path: 'materials', element: <MaterialBasePage/>,
handle: { preload: MaterialBasePage.preload }, children: [
{ index: true, element: <MaterialListPage/>,
+2 -1
ファイルの表示
@@ -10,7 +10,8 @@ type Transform = (source: string, id: string) => Promise<{ code: string } | null
export const transformMdx = async (source: string, suffix = '.mdx') => {
const plugins = viteConfig.plugins?.flat () as { name: string; transform: Transform }[]
const config = viteConfig ({ command: 'serve', mode: 'test' })
const plugins = config.plugins?.flat () as { name: string; transform: Transform }[]
const plugin = plugins.find (entry => entry.name === '@mdx-js/rollup')
if (plugin == null)
throw new Error ('The application MDX compiler is not registered')
+3 -2
ファイルの表示
@@ -21,7 +21,8 @@ if (typeof originalTransform === 'function')
}
}
export default defineConfig ({
export default defineConfig (({ command }) => ({
esbuild: { jsxDev: command === 'build' ? false : undefined },
plugins: [{ name: 'request-render-context', enforce: 'pre',
resolveId (id, _importer, options) {
const contextPath = path.resolve (__dirname, './src/lib/renderContext')
@@ -40,4 +41,4 @@ export default defineConfig ({
rewrite: requestPath => requestPath.replace (/^\/api/, ''),
secure: false } },
watch: { usePolling: true,
interval: 100 } } })
interval: 100 } } }))
+3 -3
ファイルの表示
@@ -3,11 +3,11 @@ import { defineConfig, mergeConfig } from 'vitest/config'
import viteConfig from './vite.config'
export default mergeConfig (
viteConfig,
export default defineConfig (environment => mergeConfig (
viteConfig (environment),
defineConfig ({
test: { environment: 'jsdom',
testTimeout: 30_000,
exclude: ['**/node_modules/**', '**/dist/**', 'server.ssr.test.mjs'],
setupFiles: './src/test/setup.ts',
globals: false } }))
globals: false } })))