|
|
|
@@ -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 { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
|
|
|
|
|
|
import TheatreDetailPage from '@/pages/theatres/TheatreDetailPage'
|
|
|
|
|
import { buildPost,
|
|
|
|
|
buildTag,
|
|
|
|
|
buildTheatre,
|
|
|
|
|
buildTheatreComment,
|
|
|
|
|
buildTheatreInfo,
|
|
|
|
@@ -97,9 +96,6 @@ const renderPage = (user = buildUser ({ id: 1, role: 'member' })) =>
|
|
|
|
|
{ route: '/theatres/7' },
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const tagSection = (): HTMLElement =>
|
|
|
|
|
screen.getAllByRole ('heading', { name: 'タグ' })[0].closest ('section')!
|
|
|
|
|
|
|
|
|
|
const mockDefaultApi = () => {
|
|
|
|
|
api.apiGet.mockImplementation ((path: string) => {
|
|
|
|
|
switch (path)
|
|
|
|
@@ -249,54 +245,6 @@ describe ('TheatreDetailPage', () => {
|
|
|
|
|
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 () => {
|
|
|
|
|
api.apiPut.mockImplementation ((path: string) => {
|
|
|
|
|
switch (path)
|
|
|
|
|