feat: add tweet detail page

This commit is contained in:
2026-07-14 00:50:08 +09:00
parent 8e6ff70d81
commit da72094e07
9 changed files with 272 additions and 30 deletions
+27
View File
@@ -88,4 +88,31 @@ describe('post feed route wiring', () => {
}),
)
})
it('turns a decimal status path into a deliberate thread request', async () => {
await renderRoute('/status/123')
expect(await screen.findByRole('heading', { name: '会話' })).toBeVisible()
await waitFor(() =>
expect(usePostFeed).toHaveBeenCalledWith({
kind: 'thread',
tweetId: '123',
}),
)
expect(
screen.queryByRole('link', { name: 'ユーザー', current: 'page' }),
).toBeNull()
expect(
screen.queryByRole('link', { name: '検索', current: 'page' }),
).toBeNull()
})
it('keeps an invalid status path local and idle', async () => {
await renderRoute('/status/not-a-tweet')
expect(await screen.findByRole('alert')).toHaveTextContent(
'投稿 ID を確認してください。',
)
expect(usePostFeed).toHaveBeenCalledWith(undefined)
})
})
+36
View File
@@ -0,0 +1,36 @@
import { createFileRoute } from '@tanstack/react-router'
import { AppShell } from '#/components/app-shell'
import { PostFeed } from '#/features/posts/components/post-feed'
import { InputError, normalizeTweetId } from '#/features/posts/inputs'
export const Route = createFileRoute('/status/$tweetId')({
component: StatusRoute,
})
function StatusRoute() {
const { tweetId: rawTweetId } = Route.useParams()
let tweetId: string | undefined
let error: string | undefined
try {
tweetId = normalizeTweetId(rawTweetId)
} catch (cause) {
error =
cause instanceof InputError
? cause.message
: '投稿 ID を確認してください。'
}
return (
<AppShell>
<h1>会話</h1>
<p className="intro">選んだ投稿と、その会話だけを表示します。</p>
{error ? (
<p className="state" role="alert">
{error}
</p>
) : null}
<PostFeed request={tweetId ? { kind: 'thread', tweetId } : undefined} />
</AppShell>
)
}