From a636472ec36fa0c7527ab61a329b0a17b1b0e9f2 Mon Sep 17 00:00:00 2001 From: codex-bot Date: Sat, 14 Nov 2026 22:12:56 +0900 Subject: [PATCH] WIP: address PR #475 review feedback --- frontend/scripts/help-assets.test.ts | 21 +++++++++++++++++- frontend/scripts/help-assets.ts | 11 +++++----- frontend/src/components/common/Pagination.tsx | 2 +- frontend/src/config.test.ts | 9 ++++++++ frontend/src/index.css | 22 +++++++++++++------ frontend/vitest.config.ts | 5 ++++- 6 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 frontend/src/config.test.ts diff --git a/frontend/scripts/help-assets.test.ts b/frontend/scripts/help-assets.test.ts index 1e49d2f..4a19f7c 100644 --- a/frontend/scripts/help-assets.test.ts +++ b/frontend/scripts/help-assets.test.ts @@ -1,9 +1,10 @@ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import path from 'node:path' +import { createServer } from 'vite' import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { generateHelpAssets } from './help-assets' +import { generateHelpAssets, helpAssets } from './help-assets' import type { ArticleMeta, HelpChange, HelpSearchEntry, HelpTitleIndex } from '@/lib/help' @@ -109,4 +110,22 @@ describe ('Build-time Help assets', () => { it ('rejects an empty Help checkout', async () => { await expect (generateHelpAssets (root)).rejects.toThrow ('No Help articles found') }) + + it ('defers missing Help errors until a Help module is requested', async () => { + const server = await createServer ({ + configFile: false, + root, + plugins: [helpAssets ()], + server: { middlewareMode: true, watch: null } }) + try + { + await server.pluginContainer.buildStart ({}) + await expect (server.pluginContainer.load ('\0virtual:help/articles')) + .rejects.toThrow ('ENOENT') + } + finally + { + await server.close () + } + }) }) diff --git a/frontend/scripts/help-assets.ts b/frontend/scripts/help-assets.ts index 157d0aa..867a193 100644 --- a/frontend/scripts/help-assets.ts +++ b/frontend/scripts/help-assets.ts @@ -159,10 +159,9 @@ export const helpAssets = (): Plugin => { configResolved (config) { state.root = path.resolve (config.root, 'help') }, - async buildStart () { - state.data = generateHelpAssets (state.root) - const generated = await data () - generated.files.forEach (file => this.addWatchFile (file)) + buildStart () { + state.data = undefined + this.addWatchFile (state.root) }, resolveId (id) { return id.startsWith (prefix) ? `\0${ id }` : null @@ -170,7 +169,9 @@ export const helpAssets = (): Plugin => { async load (id) { if (!(id.startsWith (`\0${ prefix }`))) return null - const source = (await data ()).modules.get (id.slice (1)) + const generated = await data () + generated.files.forEach (file => this.addWatchFile (file)) + const source = generated.modules.get (id.slice (1)) if (source == null) throw new Error (`Unknown Help asset: ${ id.slice (1) }`) return source diff --git a/frontend/src/components/common/Pagination.tsx b/frontend/src/components/common/Pagination.tsx index 47c54e1..98ac911 100644 --- a/frontend/src/components/common/Pagination.tsx +++ b/frontend/src/components/common/Pagination.tsx @@ -61,7 +61,7 @@ const Pagination: FC = ({ page, totalPages, siblingCount = 3 }) => { const pages = getPages (page, totalPages, siblingCount) return ( -