Skip to content

Commit 312424e

Browse files
committed
test(mcp): cover the router tools in the MCP e2e harness
Give diff-navigations, follow-navigations and preview-navigation valid-arguments cases. Without one, preview-navigation was called with no `url`, so its unknown-page case got the missing-url refusal instead of the unknown-page answer. A unit test checks that answer.
1 parent 049b226 commit 312424e

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎packages/devtools/src/__tests__/router-preview.test.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
type RoutePreview,
1010
} from '../rpc/router-preview.ts';
1111
import type { RouterPage } from '../rpc/router-tools.ts';
12-
import { answerText } from './tool-answer.ts';
12+
import { answerText, toolAnswer } from './tool-answer.ts';
1313

1414
const config: RouteNode[] = [
1515
{ id: '0', path: '', fullPath: '/', kind: 'redirect', redirectTo: 'home', pathMatch: 'full' },
@@ -187,4 +187,24 @@ describe('pangular:preview-navigation', () => {
187187
})) as RoutePreview;
188188
expect(rpc.chain.map((r) => r.component)).toEqual(['Home']);
189189
});
190+
191+
it('says a page it does not know is unknown, with no preview from another page', async () => {
192+
const host = {
193+
mountStatic: () => {},
194+
resolveOrigin: () => 'http://localhost',
195+
getStorageDir: () => '',
196+
};
197+
const ctx = await createHostContext({ cwd: process.cwd(), mode: 'dev', host: host as never });
198+
await pangular.setup(ctx as never);
199+
await ctx.rpc.invokeLocal(
200+
'pangular:push-router' as never,
201+
...([{ pageId: 'page-w', snapshot: null, navigations: [], generation: 1, config }] as never),
202+
);
203+
const answer = await toolAnswer(
204+
ctx.agent.invoke('pangular:preview-navigation', { page: 'zz-no-such-page', url: '/home' }),
205+
);
206+
expect(answer.isError).toBe(true);
207+
expect(answer.markdown).toContain('No page `zz-no-such-page` is reporting router state');
208+
expect(answer.markdown).not.toContain('Going to');
209+
});
190210
});

‎scripts/e2e-mcp.mjs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,11 @@ const READ_PLAN = [
771771
['lint-routes', '/examples/routes/details', () => ({})],
772772
['router-config', '/examples/routes/details', () => ({})],
773773
['explain-navigation', '/examples/routes/details', () => ({ format: 'repro' })],
774+
['diff-navigations', '/examples/routes/details', () => ({})],
775+
['follow-navigations', '/examples/routes/details', () => ({})],
776+
['follow-navigations', '/examples/routes/details', () => ({ since: 0, waitMs: 0 })],
777+
['preview-navigation', '/examples/routes/details', () => ({ url: '/destinations/kyoto' })],
778+
['preview-navigation', '/examples/routes/details', () => ({ url: '/trips' })],
774779

775780
['inspect-forms', '/examples/forms', () => ({})],
776781
['inspect-forms', '/examples/forms', (ctx) => ({ form: ctx.formIds[0] })],

0 commit comments

Comments
 (0)