このコミットが含まれているのは:
@@ -66,4 +66,27 @@ describe ('PostEditForm', () => {
|
|||||||
expect (onSave).toHaveBeenCalledWith (expect.objectContaining ({ versionNo: 5 }))
|
expect (onSave).toHaveBeenCalledWith (expect.objectContaining ({ versionNo: 5 }))
|
||||||
expect (toastApi.toast).toHaveBeenCalledWith ({ description: '更新しました.' })
|
expect (toastApi.toast).toHaveBeenCalledWith ({ description: '更新しました.' })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it ('preserves duration while the video tag is temporarily removed', () => {
|
||||||
|
const post = buildPost ({
|
||||||
|
videoMs: 180_500,
|
||||||
|
tags: [
|
||||||
|
buildTag ({ id: 1, name: '動画', category: 'general' }),
|
||||||
|
buildTag ({ id: 2, name: 'general-tag', category: 'general' }),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
render (<PostEditForm post={post} onSave={vi.fn ()}/>)
|
||||||
|
|
||||||
|
expect (screen.getByRole ('spinbutton')).toHaveValue (180.5)
|
||||||
|
|
||||||
|
const tags = screen.getAllByRole ('textbox')[2]
|
||||||
|
fireEvent.change (tags, { target: { value: 'general-tag' } })
|
||||||
|
expect (screen.queryByRole ('spinbutton')).not.toBeInTheDocument ()
|
||||||
|
|
||||||
|
fireEvent.change (tags, {
|
||||||
|
target: { value: '動画 general-tag' },
|
||||||
|
})
|
||||||
|
expect (screen.getByRole ('spinbutton')).toHaveValue (180.5)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -153,11 +153,6 @@ const PostEditForm: FC<Props> = ({ post, onSave }) => {
|
|||||||
setDuration (videoMsToDurationValue (post.videoMs))
|
setDuration (videoMsToDurationValue (post.videoMs))
|
||||||
}, [post])
|
}, [post])
|
||||||
|
|
||||||
useEffect (() => {
|
|
||||||
if (!(videoFlg))
|
|
||||||
setDuration ('')
|
|
||||||
}, [videoFlg])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit} className="max-w-xl pt-2 space-y-4">
|
<form onSubmit={handleSubmit} className="max-w-xl pt-2 space-y-4">
|
||||||
<FieldError messages={baseErrors}/>
|
<FieldError messages={baseErrors}/>
|
||||||
|
|||||||
@@ -62,6 +62,24 @@ describe ('PostNewPage', () => {
|
|||||||
expect (toastApi.toast).toHaveBeenCalledWith ({ title: '投稿成功!' })
|
expect (toastApi.toast).toHaveBeenCalledWith ({ title: '投稿成功!' })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it ('preserves duration while the video tag is temporarily removed', () => {
|
||||||
|
api.apiGet.mockResolvedValue ([])
|
||||||
|
|
||||||
|
renderWithProviders (<PostNewPage user={buildUser ({ role: 'member' })}/>)
|
||||||
|
|
||||||
|
const tags = screen.getAllByRole ('textbox')[3]
|
||||||
|
fireEvent.change (tags, { target: { value: '動画' } })
|
||||||
|
fireEvent.change (screen.getByRole ('spinbutton'), { target: { value: '180.5' } })
|
||||||
|
|
||||||
|
fireEvent.change (tags, { target: { value: 'general-tag' } })
|
||||||
|
expect (screen.queryByRole ('spinbutton')).not.toBeInTheDocument ()
|
||||||
|
|
||||||
|
fireEvent.change (tags, {
|
||||||
|
target: { value: '動画 general-tag' },
|
||||||
|
})
|
||||||
|
expect (screen.getByRole ('spinbutton')).toHaveValue (180.5)
|
||||||
|
})
|
||||||
|
|
||||||
it ('shows 422 validation errors for post fields', async () => {
|
it ('shows 422 validation errors for post fields', async () => {
|
||||||
api.apiGet.mockResolvedValue ([])
|
api.apiGet.mockResolvedValue ([])
|
||||||
api.isApiError.mockReturnValue (true)
|
api.isApiError.mockReturnValue (true)
|
||||||
|
|||||||
@@ -135,11 +135,6 @@ const PostNewPage: FC<Props> = ({ user }) => {
|
|||||||
fetchThumbnail ()
|
fetchThumbnail ()
|
||||||
}, [fetchThumbnail, thumbnailAutoFlg, url])
|
}, [fetchThumbnail, thumbnailAutoFlg, url])
|
||||||
|
|
||||||
useEffect (() => {
|
|
||||||
if (!(videoFlg))
|
|
||||||
setDuration ('')
|
|
||||||
}, [videoFlg])
|
|
||||||
|
|
||||||
if (!(editable))
|
if (!(editable))
|
||||||
return <Forbidden/>
|
return <Forbidden/>
|
||||||
|
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする