このコミットが含まれているのは:
@@ -1,3 +1,5 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
@@ -39,8 +41,8 @@ describe ('PostNewPage', () => {
|
||||
const textboxes = screen.getAllByRole ('textbox')
|
||||
fireEvent.change (textboxes[0], { target: { value: 'https://example.com/post' } })
|
||||
fireEvent.change (textboxes[1], { target: { value: '投稿タイトル' } })
|
||||
fireEvent.change (textboxes[2], { target: { value: '1 2' } })
|
||||
fireEvent.change (textboxes[3], { target: { value: 'tag1 tag2' } })
|
||||
fireEvent.change (textboxes[3], { target: { value: '1 2' } })
|
||||
fireEvent.change (textboxes[4], { target: { value: 'tag1 tag2' } })
|
||||
fireEvent.click (screen.getByRole ('button', { name: '追加' }))
|
||||
|
||||
await waitFor (() => {
|
||||
@@ -63,17 +65,19 @@ describe ('PostNewPage', () => {
|
||||
|
||||
renderWithProviders (<PostNewPage user={buildUser ({ role: 'member' })}/>)
|
||||
|
||||
const tags = screen.getAllByRole ('textbox')[3]
|
||||
const tags = screen.getAllByRole ('textbox')[4]
|
||||
fireEvent.change (tags, { target: { value: '動画' } })
|
||||
fireEvent.change (screen.getByRole ('spinbutton'), { target: { value: '180.5' } })
|
||||
fireEvent.change (
|
||||
screen.getByPlaceholderText ('例: 2 / 2.5 / 1:23'),
|
||||
{ target: { value: '180.5' } })
|
||||
|
||||
fireEvent.change (tags, { target: { value: 'general-tag' } })
|
||||
expect (screen.queryByRole ('spinbutton')).not.toBeInTheDocument ()
|
||||
expect (screen.queryByPlaceholderText ('例: 2 / 2.5 / 1:23')).not.toBeInTheDocument ()
|
||||
|
||||
fireEvent.change (tags, {
|
||||
target: { value: '動画 general-tag' },
|
||||
})
|
||||
expect (screen.getByRole ('spinbutton')).toHaveValue (180.5)
|
||||
expect (screen.getByPlaceholderText ('例: 2 / 2.5 / 1:23')).toHaveValue ('180.5')
|
||||
})
|
||||
|
||||
it ('shows 422 validation errors for post fields', async () => {
|
||||
@@ -96,11 +100,23 @@ describe ('PostNewPage', () => {
|
||||
const textboxes = screen.getAllByRole ('textbox')
|
||||
fireEvent.change (textboxes[0], { target: { value: 'https://example.com/post' } })
|
||||
fireEvent.change (textboxes[1], { target: { value: '投稿タイトル' } })
|
||||
fireEvent.change (textboxes[3], { target: { value: 'nico:nico_tag' } })
|
||||
fireEvent.change (textboxes[4], { target: { value: 'nico:nico_tag' } })
|
||||
fireEvent.click (screen.getByRole ('button', { name: '追加' }))
|
||||
|
||||
expect (await screen.findByText ('投稿内容を確認してください.')).toBeInTheDocument ()
|
||||
expect (screen.getByText ('ニコニコ・タグは直接指定できません.')).toBeInTheDocument ()
|
||||
expect (screen.getAllByRole ('textbox')[3]).toHaveAttribute ('aria-invalid', 'true')
|
||||
expect (screen.getAllByRole ('textbox')[4]).toHaveAttribute ('aria-invalid', 'true')
|
||||
})
|
||||
|
||||
it ('shares the common post field components with the import form', () => {
|
||||
const newPage = readFileSync ('src/pages/posts/PostNewPage.tsx', 'utf8')
|
||||
const importForm = readFileSync ('src/components/posts/import/PostImportRowForm.tsx', 'utf8')
|
||||
|
||||
expect (newPage).toContain ("@/components/posts/PostTextField")
|
||||
expect (newPage).toContain ("@/components/posts/PostDurationField")
|
||||
expect (newPage).toContain ("@/components/posts/PostTagsField")
|
||||
expect (importForm).toContain ("@/components/posts/PostTextField")
|
||||
expect (importForm).toContain ("@/components/posts/PostDurationField")
|
||||
expect (importForm).toContain ("@/components/posts/PostTagsField")
|
||||
})
|
||||
})
|
||||
|
||||
新しい課題から参照
ユーザをブロックする