#419 フロントのテスト追加

このコミットが含まれているのは:
2026-09-23 18:22:24 +09:00
コミット d1bab299ab
8個のファイルの変更247行の追加3行の削除
+44
ファイルの表示
@@ -0,0 +1,44 @@
import { waitFor } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import PostHistoryPage from '@/pages/posts/PostHistoryPage'
import { renderWithProviders } from '@/test/render'
const postsApi = vi.hoisted (() => ({
fetchPostChanges: vi.fn (),
updatePost: vi.fn (),
}))
const tagsApi = vi.hoisted (() => ({
fetchTag: vi.fn (),
}))
vi.mock ('@/lib/posts', () => postsApi)
vi.mock ('@/lib/tags', () => tagsApi)
describe ('PostHistoryPage', () => {
beforeEach (() => {
vi.clearAllMocks ()
postsApi.fetchPostChanges.mockResolvedValue ({
versions: [],
count: 0,
})
})
it ('filters by external_tag without resolving the id as an internal tag', async () => {
renderWithProviders (
<PostHistoryPage/>,
{ route: '/posts/changes?external_tag=7' },
)
await waitFor (() => {
expect (postsApi.fetchPostChanges).toHaveBeenCalledWith ({
externalTag: '7',
page: 1,
limit: 20,
})
})
expect (tagsApi.fetchTag).not.toHaveBeenCalled ()
})
})