このコミットが含まれているのは:
@@ -0,0 +1,9 @@
|
||||
import { describe, it } from 'vitest'
|
||||
|
||||
describe ('pending high-level browser coverage', () => {
|
||||
it.todo ('covers TheatreDetailPage with timer polling, comment posting, and next-post updates')
|
||||
it.todo ('covers NicoTagListPage linking and pagination against realistic API payloads')
|
||||
it.todo ('covers TagDetailSidebar drag/drop parent-child editing with pointer-event fidelity')
|
||||
it.todo ('covers TopNav desktop and mobile menu flows as browser-level integration tests')
|
||||
it.todo ('covers full App bootstrap for user creation, user verification, and 503 handling')
|
||||
})
|
||||
@@ -0,0 +1,74 @@
|
||||
import type { Material, Post, Tag, User, WikiPage } from '@/types'
|
||||
|
||||
export const buildTag = (overrides: Partial<Tag> = {}): Tag => ({
|
||||
id: 1,
|
||||
name: 'テストタグ',
|
||||
category: 'general',
|
||||
aliases: [],
|
||||
parents: [],
|
||||
postCount: 12,
|
||||
createdAt: '2026-01-02T03:04:05.000Z',
|
||||
updatedAt: '2026-01-03T03:04:05.000Z',
|
||||
hasWiki: false,
|
||||
materialId: null,
|
||||
hasDeerjikists: false,
|
||||
matchedAlias: null,
|
||||
...overrides,
|
||||
})
|
||||
|
||||
export const buildPost = (overrides: Partial<Post> = {}): Post => ({
|
||||
id: 1,
|
||||
versionNo: 1,
|
||||
url: 'https://example.com/post/1',
|
||||
title: 'テスト投稿',
|
||||
thumbnail: 'https://example.com/thumb.jpg',
|
||||
thumbnailBase: null,
|
||||
tags: [buildTag ()],
|
||||
parentPosts: [],
|
||||
childPosts: [],
|
||||
siblingPosts: {},
|
||||
viewed: false,
|
||||
related: [],
|
||||
originalCreatedFrom: null,
|
||||
originalCreatedBefore: null,
|
||||
createdAt: '2026-01-02T03:04:05.000Z',
|
||||
updatedAt: '2026-01-03T03:04:05.000Z',
|
||||
uploadedUser: { id: 1, name: 'tester' },
|
||||
...overrides,
|
||||
})
|
||||
|
||||
export const buildUser = (overrides: Partial<User> = {}): User => ({
|
||||
id: 1,
|
||||
name: 'tester',
|
||||
inheritanceCode: 'inherit-code',
|
||||
role: 'member',
|
||||
...overrides,
|
||||
})
|
||||
|
||||
export const buildWikiPage = (overrides: Partial<WikiPage> = {}): WikiPage => ({
|
||||
id: 1,
|
||||
title: 'テストWiki',
|
||||
createdUserId: 1,
|
||||
updatedUserId: 1,
|
||||
createdAt: '2026-01-02T03:04:05.000Z',
|
||||
updatedAt: '2026-01-03T03:04:05.000Z',
|
||||
body: '# 本文',
|
||||
revisionId: 10,
|
||||
pred: null,
|
||||
succ: null,
|
||||
...overrides,
|
||||
})
|
||||
|
||||
export const buildMaterial = (overrides: Partial<Material> = {}): Material => ({
|
||||
id: 1,
|
||||
tag: buildTag (),
|
||||
file: null,
|
||||
url: null,
|
||||
wikiPageBody: null,
|
||||
contentType: null,
|
||||
createdAt: '2026-01-02T03:04:05.000Z',
|
||||
createdByUser: { id: 1, name: 'creator' },
|
||||
updatedAt: '2026-01-03T03:04:05.000Z',
|
||||
updatedByUser: { id: 2, name: 'updater' },
|
||||
...overrides,
|
||||
})
|
||||
@@ -0,0 +1,35 @@
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { render } from '@testing-library/react'
|
||||
import { HelmetProvider } from 'react-helmet-async'
|
||||
import { MemoryRouter } from 'react-router-dom'
|
||||
|
||||
import type { ReactElement, ReactNode } from 'react'
|
||||
|
||||
type Options = {
|
||||
route?: string
|
||||
}
|
||||
|
||||
export const renderWithProviders = (
|
||||
ui: ReactElement,
|
||||
options: Options = {},
|
||||
) => {
|
||||
const queryClient = new QueryClient ({
|
||||
defaultOptions: {
|
||||
queries: { retry: false },
|
||||
},
|
||||
})
|
||||
|
||||
const Wrapper = ({ children }: { children: ReactNode }) => (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<HelmetProvider>
|
||||
<MemoryRouter initialEntries={[options.route ?? '/']}>
|
||||
{children}
|
||||
</MemoryRouter>
|
||||
</HelmetProvider>
|
||||
</QueryClientProvider>)
|
||||
|
||||
return {
|
||||
queryClient,
|
||||
...render (ui, { wrapper: Wrapper }),
|
||||
}
|
||||
}
|
||||
@@ -1 +1,20 @@
|
||||
import '@testing-library/jest-dom/vitest'
|
||||
import { cleanup } from '@testing-library/react'
|
||||
import { afterEach } from 'vitest'
|
||||
|
||||
afterEach (() => {
|
||||
cleanup ()
|
||||
})
|
||||
|
||||
Element.prototype.scrollIntoView = function () {
|
||||
;
|
||||
}
|
||||
|
||||
window.scroll = function () {
|
||||
;
|
||||
}
|
||||
|
||||
window.requestAnimationFrame = callback => {
|
||||
callback (0)
|
||||
return 0
|
||||
}
|
||||
|
||||
新しい課題から参照
ユーザをブロックする