feat(help): in-app help center with per-screen guides and pictures

A help icon on every screen opens a panel with the screen's overview, its
sub-screens, task guides with a framed picture per step, search across guides
and the wiki, and a switch to any other screen's help. Guides exist for the
dashboard, Vacay, Atlas, Collections, Journey (list, journal, studio), Settings
(all tabs), Admin (all tabs) and the trip frame; the trip's own screens are
in progress. Pictures are produced by Playwright (client/e2e/help), texts in
all 23 languages.
This commit is contained in:
Maurice
2026-09-21 23:20:27 +02:00
parent 151e32107f
commit 4346d7f2c1
483 changed files with 47654 additions and 33 deletions
@@ -1,6 +1,6 @@
/**
* Unit tests for the MCP help and addons tools:
* list_help_topics, get_help_page, list_addons.
* list_help_topics, get_help_page, search_help, list_addons.
*/
import { describe, it, expect, vi, beforeAll, beforeEach, afterAll } from 'vitest';
@@ -49,6 +49,7 @@ const { wiki } = vi.hoisted(() => {
getWikiIndex: vi.fn(),
getWikiPage: vi.fn(),
getWikiAsset: vi.fn(),
searchWiki: vi.fn(),
},
};
});
@@ -124,7 +125,19 @@ beforeEach(() => {
delete process.env.DEMO_MODE;
wiki.getWikiIndex.mockReset();
wiki.getWikiPage.mockReset();
wiki.searchWiki.mockReset();
wiki.getWikiIndex.mockResolvedValue({ sections: SECTIONS });
wiki.searchWiki.mockResolvedValue([
{
slug: 'Quick-Start',
title: 'Quick Start',
section: 'Getting Started',
anchor: null,
heading: null,
snippet: 'Create a trip, then add days to it.',
score: 9,
},
]);
wiki.getWikiPage.mockImplementation(async (slug: string) => {
const page = PAGES[slug];
if (!page) throw new wiki.WikiNotFound(slug);
@@ -297,6 +310,51 @@ describe('Tool: get_help_page', () => {
});
});
// ---------------------------------------------------------------------------
// search_help
// ---------------------------------------------------------------------------
describe('Tool: search_help', () => {
it('hands the query and limit to the wiki search and returns its hits', async () => {
const { user } = createUser(testDb);
await withHarness(user.id, async (h) => {
const result = await h.client.callTool({ name: 'search_help', arguments: { query: 'create trip', limit: 3 } });
expect(result.isError).toBeFalsy();
const data = parseToolResult(result) as { hits: { slug: string; snippet: string }[] };
expect(data.hits).toHaveLength(1);
expect(data.hits[0].slug).toBe('Quick-Start');
expect(wiki.searchWiki).toHaveBeenCalledWith('create trip', 3);
});
});
it('rejects an empty query before the search runs', async () => {
const { user } = createUser(testDb);
await withHarness(user.id, async (h) => {
const result = await h.client.callTool({ name: 'search_help', arguments: { query: '' } });
expect(result.isError).toBe(true);
expect(wiki.searchWiki).not.toHaveBeenCalled();
});
});
it('reports an unavailable search instead of throwing', async () => {
wiki.searchWiki.mockRejectedValue(new Error('ENOENT'));
const { user } = createUser(testDb);
await withHarness(user.id, async (h) => {
const result = await h.client.callTool({ name: 'search_help', arguments: { query: 'trip' } });
expect(result.isError).toBe(true);
expect(toolText(result)).toBe('Help search unavailable.');
});
});
it('stays registered for a token holding an unrelated scope', async () => {
const { user } = createUser(testDb);
await withHarness(user.id, async (h) => {
const names = (await h.client.listTools()).tools.map((t) => t.name);
expect(names).toContain('search_help');
}, ['weather:read']);
});
});
// ---------------------------------------------------------------------------
// list_addons
// ---------------------------------------------------------------------------
+82
View File
@@ -216,3 +216,85 @@ describe('wiki — default path resolution', () => {
expect(fetchSpy).not.toHaveBeenCalled();
});
});
describe('wiki — full-text search', () => {
const ok = (body: string): Response =>
({ ok: true, status: 200, text: async () => body, arrayBuffer: async () => new ArrayBuffer(4) }) as unknown as Response;
it('ranks a title match first and points at the heading the text sits under', async () => {
const wiki = await loadWiki(FIXTURE_WIKI);
const hits = await wiki.searchWiki('cover image');
expect(hits[0]).toMatchObject({
slug: 'Sample',
title: 'Sample Page',
section: 'Planning',
heading: 'Cover images',
anchor: 'cover-images',
});
expect(hits[0].snippet).toContain('cover image');
// Only pages that carry the words come back; the fixture home page does not.
expect(hits.map((h) => h.slug)).not.toContain('Home');
expect(fetchSpy).not.toHaveBeenCalled();
});
it('finds a page by a word in its body and hands back a snippet around it', async () => {
const wiki = await loadWiki(FIXTURE_WIKI);
const hits = await wiki.searchWiki('restored');
expect(hits).toHaveLength(1);
expect(hits[0].slug).toBe('Sample');
expect(hits[0].heading).toBe('Archiving');
expect(hits[0].snippet).toMatch(/restored/);
expect(hits[0].snippet).not.toContain('```');
});
it('matches the page title without the words appearing in the body', async () => {
const wiki = await loadWiki(FIXTURE_WIKI);
const hits = await wiki.searchWiki('fixture');
expect(hits[0].slug).toBe('Home');
expect(hits[0].anchor).toBeNull();
});
it('returns nothing for an empty or single-letter query', async () => {
const wiki = await loadWiki(FIXTURE_WIKI);
expect(await wiki.searchWiki(' ')).toEqual([]);
expect(await wiki.searchWiki('a')).toEqual([]);
expect(await wiki.searchWiki('zzzz-no-such-word')).toEqual([]);
});
it('honours the limit and clamps it to a sane range', async () => {
const wiki = await loadWiki(FIXTURE_WIKI);
// Both fixture pages mention "page"; ask for one.
const one = await wiki.searchWiki('page', 1);
expect(one).toHaveLength(1);
const all = await wiki.searchWiki('page', 500);
expect(all.length).toBeGreaterThan(1);
expect(all.length).toBeLessThanOrEqual(20);
});
it('builds the index once for the bundled wiki and reuses it', async () => {
const wiki = await loadWiki(FIXTURE_WIKI);
const first = await wiki.searchWiki('archive');
const second = await wiki.searchWiki('archive');
expect(second).toEqual(first);
expect(fetchSpy).not.toHaveBeenCalled();
});
it('searches the GitHub fallback and skips a page that fails to load', async () => {
const wiki = await loadWiki(MISSING_WIKI);
expect(wiki.isLocalWiki()).toBe(false);
fetchSpy.mockImplementation(async (url: string) => {
if (url.endsWith('_Sidebar.md')) return ok('## Docs\n- [[Home]]\n- [[Broken]]\n');
if (url.endsWith('Home.md')) return ok('# Remote Home\n\nInvite links expire after a week.\n');
return { ok: false, status: 500, text: async () => '' } as unknown as Response;
});
const hits = await wiki.searchWiki('invite');
expect(hits).toHaveLength(1);
expect(hits[0]).toMatchObject({ slug: 'Home', title: 'Remote Home' });
});
});