コミットを比較
23 コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
| c9b22d346b | |||
| 283c20b9da | |||
| ec98c6b756 | |||
| d721a64e33 | |||
| 0eb45372c3 | |||
| 27aa5321a1 | |||
| 4c0a4f5d9b | |||
| 41a98ff725 | |||
| c836369dfc | |||
| 363146c219 | |||
| ce28661271 | |||
| d7b136c198 | |||
| 4da3f0afba | |||
| daf9e7e6fa | |||
| 8304909c8c | |||
| 377a09ed70 | |||
| c10ba7a698 | |||
| fa6c547cc9 | |||
| dbc654f346 | |||
| c2102c8f96 | |||
| 510cbb0d78 | |||
| a820ce4c3e | |||
| 507ce1680e |
@@ -1,10 +1,9 @@
|
|||||||
import { act, fireEvent, screen, waitFor, within } from '@testing-library/react'
|
import { act, fireEvent, screen, waitFor } from '@testing-library/react'
|
||||||
import { Route, Routes } from 'react-router-dom'
|
import { Route, Routes } from 'react-router-dom'
|
||||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
|
||||||
import TheatreDetailPage from '@/pages/theatres/TheatreDetailPage'
|
import TheatreDetailPage from '@/pages/theatres/TheatreDetailPage'
|
||||||
import { buildPost,
|
import { buildPost,
|
||||||
buildTag,
|
|
||||||
buildTheatre,
|
buildTheatre,
|
||||||
buildTheatreComment,
|
buildTheatreComment,
|
||||||
buildTheatreInfo,
|
buildTheatreInfo,
|
||||||
@@ -97,9 +96,6 @@ const renderPage = (user = buildUser ({ id: 1, role: 'member' })) =>
|
|||||||
{ route: '/theatres/7' },
|
{ route: '/theatres/7' },
|
||||||
)
|
)
|
||||||
|
|
||||||
const tagSection = (): HTMLElement =>
|
|
||||||
screen.getAllByRole ('heading', { name: 'タグ' })[0].closest ('section')!
|
|
||||||
|
|
||||||
const mockDefaultApi = () => {
|
const mockDefaultApi = () => {
|
||||||
api.apiGet.mockImplementation ((path: string) => {
|
api.apiGet.mockImplementation ((path: string) => {
|
||||||
switch (path)
|
switch (path)
|
||||||
@@ -249,54 +245,6 @@ describe ('TheatreDetailPage', () => {
|
|||||||
expect (postEmbed.seek).not.toHaveBeenCalledWith (0)
|
expect (postEmbed.seek).not.toHaveBeenCalledWith (0)
|
||||||
})
|
})
|
||||||
|
|
||||||
it ('shows child tags from the post tag tree in both vertical and horizontal layouts', async () => {
|
|
||||||
const childTag = buildTag ({ id: 12, name: '子タグ', category: 'general' })
|
|
||||||
const parentTag = buildTag ({
|
|
||||||
id: 11,
|
|
||||||
name: '親タグ',
|
|
||||||
category: 'general',
|
|
||||||
children: [childTag],
|
|
||||||
})
|
|
||||||
const duplicateParentTag = buildTag ({
|
|
||||||
id: 13,
|
|
||||||
name: '別親タグ',
|
|
||||||
category: 'general',
|
|
||||||
children: [childTag],
|
|
||||||
})
|
|
||||||
|
|
||||||
postsApi.fetchPost.mockResolvedValueOnce (buildPost ({
|
|
||||||
...currentPost,
|
|
||||||
tags: [parentTag, duplicateParentTag],
|
|
||||||
}))
|
|
||||||
|
|
||||||
renderPage ()
|
|
||||||
|
|
||||||
await screen.findByText ('Embed:上映中の投稿')
|
|
||||||
|
|
||||||
expect (within (tagSection ()).getByRole ('link', { name: '親タグ' }))
|
|
||||||
.toBeInTheDocument ()
|
|
||||||
expect (within (tagSection ()).getByRole ('link', { name: '別親タグ' }))
|
|
||||||
.toBeInTheDocument ()
|
|
||||||
expect (within (tagSection ()).getByRole ('link', { name: '子タグ' }))
|
|
||||||
.toBeInTheDocument ()
|
|
||||||
expect (within (tagSection ()).getAllByRole ('link', { name: '子タグ' }))
|
|
||||||
.toHaveLength (1)
|
|
||||||
|
|
||||||
fireEvent.click (screen.getByRole ('button', { name: '2 列 A 型' }))
|
|
||||||
fireEvent.click (screen.getAllByRole ('button', { name: '横並び' })[0])
|
|
||||||
|
|
||||||
await waitFor (() => {
|
|
||||||
expect (within (tagSection ()).getByRole ('link', { name: '親タグ' }))
|
|
||||||
.toBeInTheDocument ()
|
|
||||||
expect (within (tagSection ()).getByRole ('link', { name: '別親タグ' }))
|
|
||||||
.toBeInTheDocument ()
|
|
||||||
expect (within (tagSection ()).getByRole ('link', { name: '子タグ' }))
|
|
||||||
.toBeInTheDocument ()
|
|
||||||
expect (within (tagSection ()).getAllByRole ('link', { name: '子タグ' }))
|
|
||||||
.toHaveLength (1)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it ('does not advance host post while video length is unknown', async () => {
|
it ('does not advance host post while video length is unknown', async () => {
|
||||||
api.apiPut.mockImplementation ((path: string) => {
|
api.apiPut.mockImplementation ((path: string) => {
|
||||||
switch (path)
|
switch (path)
|
||||||
|
|||||||
@@ -102,33 +102,10 @@ const compareTagName = (a: Tag, b: Tag): number =>
|
|||||||
a.name === b.name ? 0 : (a.name < b.name ? -1 : 1)
|
a.name === b.name ? 0 : (a.name < b.name ? -1 : 1)
|
||||||
|
|
||||||
|
|
||||||
const flattenTags = (tags: Tag[]): Tag[] => {
|
|
||||||
const flattened: Tag[] = []
|
|
||||||
const seen = new Set<number> ()
|
|
||||||
|
|
||||||
const visit = (tag: Tag) => {
|
|
||||||
if (seen.has (tag.id))
|
|
||||||
return
|
|
||||||
|
|
||||||
seen.add (tag.id)
|
|
||||||
flattened.push (tag)
|
|
||||||
|
|
||||||
for (const child of tag.children ?? [])
|
|
||||||
visit (child)
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const tag of tags)
|
|
||||||
visit (tag)
|
|
||||||
|
|
||||||
return flattened
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const tagsByCategory = (tags: Tag[]): Partial<Record<Category, Tag[]>> => {
|
const tagsByCategory = (tags: Tag[]): Partial<Record<Category, Tag[]>> => {
|
||||||
const flattenedTags = flattenTags (tags)
|
|
||||||
const grouped: Partial<Record<Category, Tag[]>> = { }
|
const grouped: Partial<Record<Category, Tag[]>> = { }
|
||||||
|
|
||||||
for (const tag of flattenedTags)
|
for (const tag of tags)
|
||||||
{
|
{
|
||||||
grouped[tag.category] ??= []
|
grouped[tag.category] ??= []
|
||||||
grouped[tag.category]!.push (tag)
|
grouped[tag.category]!.push (tag)
|
||||||
|
|||||||
新しい課題から参照
ユーザをブロックする