このコミットが含まれているのは:
2026-10-12 20:10:04 +09:00
コミット 2e98ed02e3
41個のファイルの変更、624行の追加、244行の削除
+25 -18
ファイルの表示
@@ -6,51 +6,58 @@ import { createHelpFixture } from '@/test/helpFixtures'
describe ('Help file catalogue', () => {
it ('uses current_edition rather than the newest file, without YAML titles', async () => {
const { api } = createHelpFixture ()
expect (api.getHelpArticle ('guide')?.languages.ja.currentEdition).toBe ('2026-10-02')
expect ((await api.getHelpArticle ('guide'))?.languages.ja.currentEdition)
.toBe ('2026-10-02.10')
expect (await api.getHelpSearchEntries ('ja')).toEqual ([
{ identifier: 'guide', edition: '2026-10-02',
title: 'ホーム', body: '\nタグを検索する' },
{ identifier: 'guide', edition: '2026-10-02.10',
title: 'ホーム第十版', body: '\nタグを検索する 第十版本文' },
{ identifier: '設定 手順', edition: '2026-10-03',
title: '設定', body: '\nタグを設定する' }])
})
it ('orders same-day editions numerically and separates languages', () => {
it ('orders published editions numerically and separates languages', async () => {
const { api } = createHelpFixture ()
expect (api.getHelpEditions ('guide', 'ja')).toEqual ([
expect (await api.getHelpEditions ('guide', 'ja')).toEqual ([
'2026-10-01', '2026-10-02', '2026-10-02.2', '2026-10-02.3', '2026-10-02.10'])
expect (api.getHelpEditions ('guide', 'en')).toEqual (['2026-10-02'])
expect (await api.getHelpEditions ('guide', 'en')).toEqual (['2026-10-02'])
expect (await api.getHelpPublishedEditions ('guide', 'ja'))
.not.toContain ('2026-10-02.11')
})
it ('derives each edition title from its first H1', async () => {
it ('uses generated edition titles without reparsing raw sources', async () => {
const { api, raw } = createHelpFixture ()
expect (await api.getHelpEditionText ('guide', 'ja', '2026-10-01'))
.toEqual ({ title: '旧ホーム', body: '\n過去限定本文' })
raw['../../help/guide/editions/ja/2026-10-02.mdx']
.mockResolvedValue ('\uFEFF# 改題\r\n\r\n本文\r\n# 別見出し')
expect (await api.getHelpEditionText ('guide', 'ja', '2026-10-02'))
.toEqual ({ title: '改題', body: '\r\n本文\r\n# 別見出し' })
.toEqual ({ title: 'ホーム', body: '\nタグを検索する' })
expect (raw['../../help/guide/editions/ja/2026-10-02.mdx']).not.toHaveBeenCalled ()
expect ((await api.getHelpEditionSource ('guide', 'ja', '2026-10-02'))?.source)
.toBe ('\uFEFF# 改題\r\n\r\n本文\r\n# 別見出し')
})
it ('returns missing resources without substituting another edition', async () => {
const { api } = createHelpFixture ()
expect (api.getHelpArticle ('absent')).toBeNull ()
expect (api.getHelpEditions ('absent', 'ja')).toEqual ([])
expect (await api.getHelpArticle ('absent')).toBeNull ()
expect (await api.getHelpEditions ('absent', 'ja')).toEqual ([])
expect (await api.getHelpEdition ('guide', 'ja', 'missing')).toBeNull ()
expect (await api.getHelpEditionText ('guide', 'fr', '2026-10-02')).toBeNull ()
})
it ('rejects a missing current file instead of silently hiding an article', async () => {
const { api, raw } = createHelpFixture ()
delete raw['../../help/guide/editions/ja/2026-10-02.mdx']
await expect (api.getHelpSearchEntries ('ja')).rejects.toThrow ()
it ('reports generated search asset failures instead of hiding articles', async () => {
const { api, loads } = createHelpFixture ()
loads.search.mockImplementationOnce (() => { throw new Error ('asset failure') })
await expect (api.getHelpSearchEntries ('ja')).rejects.toThrow ('asset failure')
})
it ('reports raw loading failures and missing leading H1', async () => {
it ('reports raw loading failures and excludes unpublished editions', async () => {
const { api, raw } = createHelpFixture ()
const loader = raw['../../help/guide/editions/ja/2026-10-02.mdx']
loader.mockRejectedValueOnce (new Error ('fixture failure'))
await expect (api.getHelpSearchEntries ('ja')).rejects.toThrow ('fixture failure')
loader.mockResolvedValueOnce ('本文\n# 遅い見出し')
await expect (api.getHelpEditionText ('guide', 'ja', '2026-10-02')).rejects.toThrow ()
await expect (api.getHelpEditionSource ('guide', 'ja', '2026-10-02'))
.rejects.toThrow ('fixture failure')
expect (await api.getHelpEdition ('guide', 'ja', '2026-10-02.11')).toBeNull ()
expect (await api.getHelpEditionSource ('guide', 'ja', '2026-10-02.11')).toBeNull ()
})
})
+9 -6
ファイルの表示
@@ -23,11 +23,13 @@ const Location = () => {
describe ('Help prefetch integration', () => {
beforeEach (() => {
helpFixture.reset ()
settings.linkPreload = 'intent'
vi.clearAllMocks ()
})
it.each (['/help', '/help/guide', '/help/changes',
it.each (['/help', '/help?title=ホーム&text=検索&page=2', '/help/guide', '/help/changes',
'/help/guide/diff?from=2026-10-01&to=2026-10-02.10',
'/help/%E8%A8%AD%E5%AE%9A%20%E6%89%8B%E9%A0%86?edition=2026-10-03']) (
'registers a unique prefetcher for %s', path => {
const url = new URL (path, window.location.origin)
@@ -43,13 +45,13 @@ describe ('Help prefetch integration', () => {
<Route path="/help/:identifier" element={<HelpDetailPage/>}/>
</Routes>
</>)
const loader = helpFixture.moduleLoads['../../help/guide/editions/ja/2026-10-02.mdx']
const loader = helpFixture.moduleLoads['../../help/guide/editions/ja/2026-10-02.10.mdx']
await Promise.all ([
prefetchers.prefetchForURL (queryClient, '/help/guide'),
prefetchers.prefetchForURL (queryClient, '/help/guide')])
expect (loader).toHaveBeenCalledTimes (1)
fireEvent.click (screen.getByRole ('link', { name: 'Help' }))
await screen.findByRole ('heading', { name: 'ホーム' })
await screen.findByRole ('heading', { name: 'ホーム第十版' })
expect (loader).toHaveBeenCalledTimes (1)
})
@@ -69,11 +71,12 @@ describe ('Help prefetch integration', () => {
const article = vi.spyOn (helpFixture.api, 'getHelpArticle')
await prefetchers.prefetchForURL (new QueryClient (), '/help/changes')
expect (article).not.toHaveBeenCalledWith ('changes')
expect (helpFixture.raw['../../help/guide/editions/ja/2026-10-01.mdx'])
.toHaveBeenCalled ()
expect (helpFixture.loads.changes).toHaveBeenCalledTimes (1)
Object.values (helpFixture.raw).forEach (load => expect (load).not.toHaveBeenCalled ())
Object.values (helpFixture.modules).forEach (load => expect (load).not.toHaveBeenCalled ())
})
it.each (['intent', 'off', 'click']) ('respects %s intent settings and still prefetches clicks',
it.each (['intent', 'off']) ('respects %s intent settings and still prefetches clicks',
async mode => {
settings.linkPreload = mode
const run = vi.spyOn (prefetchers, 'prefetchForURL').mockResolvedValue ()