このコミットが含まれているのは:
@@ -10,6 +10,7 @@ import {
|
||||
import PostImportResultPage from '@/pages/posts/PostImportResultPage'
|
||||
import { buildUser } from '@/test/factories'
|
||||
import { buildPostImportRow } from '@/test/postImportFactories'
|
||||
import { originalCreatedAtString } from '@/lib/utils'
|
||||
|
||||
import type { PostImportRow } from '@/lib/postImportSession'
|
||||
import type { DialogueFormAction, DialogueFormControls } from '@/lib/dialogues/useDialogue'
|
||||
@@ -56,7 +57,10 @@ describe ('PostImportResultPage', () => {
|
||||
importErrors: { base: ['hard failed'] } }),
|
||||
buildPostImportRow ({
|
||||
sourceRow: 3,
|
||||
attributes: { title: 'created row' },
|
||||
attributes: {
|
||||
title: 'created row',
|
||||
originalCreatedFrom: '2024-01-01T00:00:00Z',
|
||||
originalCreatedBefore: '2024-01-02T00:00:00Z' },
|
||||
importStatus: 'created',
|
||||
createdPostId: 3,
|
||||
fieldWarnings: {
|
||||
@@ -77,6 +81,9 @@ describe ('PostImportResultPage', () => {
|
||||
expect (screen.getAllByRole ('button', { name: '再試行' })).toHaveLength (1)
|
||||
expect (screen.getByText ('サムネール画像を取得できませんでした.'))
|
||||
.toBeInTheDocument ()
|
||||
expect (screen.getByText (
|
||||
originalCreatedAtString ('2024-01-01T00:00:00Z', '2024-01-02T00:00:00Z'),
|
||||
)).toBeInTheDocument ()
|
||||
})
|
||||
|
||||
it ('keeps recoverable pending rows actionable and hides actions for hard failures', () => {
|
||||
@@ -317,4 +324,46 @@ describe ('PostImportResultPage', () => {
|
||||
expect (saved?.rows[0]?.recoverable).toBe (true)
|
||||
})
|
||||
})
|
||||
|
||||
it ('restores the failed row when the retry import response is incomplete', async () => {
|
||||
savePostImportSession ('result-retry-missing-row', {
|
||||
source: '',
|
||||
repairMode: 'failed',
|
||||
rows: [buildPostImportRow ({
|
||||
sourceRow: 1,
|
||||
importStatus: 'failed',
|
||||
recoverable: true,
|
||||
importErrors: { base: ['failed'] } })] })
|
||||
api.apiPost
|
||||
.mockResolvedValueOnce ({
|
||||
rows: [buildPostImportRow ({
|
||||
sourceRow: 1,
|
||||
importStatus: 'pending',
|
||||
recoverable: true })] })
|
||||
.mockResolvedValueOnce ({
|
||||
created: 1,
|
||||
skipped: 0,
|
||||
failed: 0,
|
||||
rows: [] })
|
||||
|
||||
render (
|
||||
<HelmetProvider>
|
||||
<MemoryRouter initialEntries={['/posts/import/result-retry-missing-row/result']}>
|
||||
<Routes>
|
||||
<Route
|
||||
path="/posts/import/:sessionId/result"
|
||||
element={<PostImportResultPage user={buildUser ()}/>}/>
|
||||
</Routes>
|
||||
</MemoryRouter>
|
||||
</HelmetProvider>)
|
||||
|
||||
fireEvent.click (screen.getByRole ('button', { name: '再試行' }))
|
||||
|
||||
await waitFor (() => {
|
||||
const saved = loadPostImportSession ('result-retry-missing-row')
|
||||
expect (saved?.rows[0]?.importStatus).toBe ('failed')
|
||||
expect (toastApi.toast).toHaveBeenCalledWith (
|
||||
expect.objectContaining ({ title: '登録結果が不完全でした' }))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
新しい課題から参照
ユーザをブロックする