mirror of
https://github.com/garrytan/gbrain.git
synced 2026-07-28 14:59:47 +00:00
* test(e2e): drop flaky wall-clock bounds in minions-resilience
The runaway-dead-letter and cascade-kill tests asserted tight real-clock
upper bounds (<2000ms, <3000ms) on top of already-complete terminal-state
checks. Those bounds carry no correctness signal — the dead/cancelled status
and abortedChildren==10 assertions fully prove behavior — and flake on loaded
CI runners where the stall/timeout sweep cadence varies. Removed both bounds,
kept the diagnostic values, de-promised the test titles.
* test(e2e): kill order-dependence + no-op assertions in mechanical
- traverse_graph: self-contained (re-adds its own idempotent link) and asserts
the linked company is reachable, instead of depending on a prior it() and
only checking array shape.
- file_list-without-slug: seeds its own >100 rows instead of relying on the
previous test's 150 surviving in the DB; asserts the cap is exercised.
- precision@5: add a loose floor (every known-item query surfaces >=1 truth doc
in top-5) so a 0% retrieval regression no longer passes silently.
- get_health: assert value bounds (page_count==16, embed_coverage 0..1) not just
typeof; get_chunks: assert non-empty text, numeric non-decreasing chunk_index,
and that the page name appears, instead of toBeTruthy on chunks[0].
* test(e2e): strengthen graph/search quality assertions + close coverage gaps
graph-quality: truncate+reseed 'config' in truncateAll (kills config leak where a
setConfig test throwing before its finally bleeds into later tests); replace
toBeGreaterThan(0) link/timeline floors with fixture-derived minimums; assert exact
attendee slugs are 'attended' instead of a vacuous .every; pin autoLinks.created to
the provable 2 (Alice+Acme); add direction out/both + depth:2 multi-hop and a
cycle-safety (A->B->A terminates) test.
search-quality: fix the vacuous detail=low vector test; assert pedro returns >=2
chunks; assert detail=high includes the timeline chunk; add empty-query and
zero-vector no-throw edge tests.
* test(e2e): self-contain multi-source sync test + assert ledger cascade
Break the sequential dependency where 'performSync no sourceId' relied on a prior
test writing sync.repo_path — it now sets its own config. Add the missing
file_migration_ledger COUNT(*)==0 cascade assertion. Tighten the source_id default
check from toContain('default') to exact "'default'::text".
* test(e2e): make migration-flow HOME/PATH swap throw-safe
The suite repoints process.env.HOME/PATH to a temp dir and only restored them in
afterAll, so a mid-test throw left HOME dead for the rest of the bun process and
silently broke sibling suites. Wrap each test body in try/finally restore + a
defensive restore at the top of beforeEach.
* test(e2e): loud-skip jsonb-roundtrip + doctor-progress
Both skipped silently with no DATABASE_URL, giving zero signal the regression guard
never ran. Add the console.log skip line matching the sibling e2e files.
* test(e2e): robust check-update contract + find_orphans tool coverage
upgrade: the 'no-releases' test hard-asserted update_available===false, which flips
to failing the moment the repo has a real release. Assert the JSON contract shape
(boolean update_available, current_version===VERSION, typed optional fields) instead.
mcp: add find_orphans to the asserted generated tool names.
69 lines
2.5 KiB
TypeScript
69 lines
2.5 KiB
TypeScript
/**
|
|
* E2E MCP Protocol Test — Tier 1
|
|
*
|
|
* Verifies the MCP server can start and that the tools/list
|
|
* from operations.ts generates correct tool definitions.
|
|
*
|
|
* Note: The full stdio MCP protocol test (spawn server, send JSON-RPC)
|
|
* is complex because the MCP SDK uses its own transport layer. This test
|
|
* verifies the tool generation logic directly, which is what matters for
|
|
* agent compatibility.
|
|
*/
|
|
|
|
import { describe, test, expect } from 'bun:test';
|
|
import { operations } from '../../src/core/operations.ts';
|
|
|
|
describe('E2E: MCP Tool Generation', () => {
|
|
test('operations generate valid MCP tool definitions', () => {
|
|
// This replicates exactly what server.ts does in the tools/list handler
|
|
const tools = operations.map(op => ({
|
|
name: op.name,
|
|
description: op.description,
|
|
inputSchema: {
|
|
type: 'object' as const,
|
|
properties: Object.fromEntries(
|
|
Object.entries(op.params).map(([k, v]) => [k, {
|
|
type: v.type === 'array' ? 'array' : v.type,
|
|
...(v.description ? { description: v.description } : {}),
|
|
...(v.enum ? { enum: v.enum } : {}),
|
|
...(v.items ? { items: { type: v.items.type } } : {}),
|
|
}]),
|
|
),
|
|
required: Object.entries(op.params)
|
|
.filter(([, v]) => v.required)
|
|
.map(([k]) => k),
|
|
},
|
|
}));
|
|
|
|
expect(tools.length).toBe(operations.length);
|
|
expect(tools.length).toBeGreaterThanOrEqual(30);
|
|
|
|
for (const tool of tools) {
|
|
expect(tool.name).toBeTruthy();
|
|
expect(tool.description).toBeTruthy();
|
|
expect(tool.inputSchema.type).toBe('object');
|
|
expect(typeof tool.inputSchema.properties).toBe('object');
|
|
expect(Array.isArray(tool.inputSchema.required)).toBe(true);
|
|
}
|
|
|
|
// Verify specific tools exist
|
|
const names = tools.map(t => t.name);
|
|
expect(names).toContain('get_page');
|
|
expect(names).toContain('put_page');
|
|
expect(names).toContain('search');
|
|
expect(names).toContain('query');
|
|
expect(names).toContain('add_link');
|
|
expect(names).toContain('get_health');
|
|
expect(names).toContain('sync_brain');
|
|
expect(names).toContain('file_upload');
|
|
expect(names).toContain('find_orphans');
|
|
});
|
|
|
|
test('MCP server module can be imported', async () => {
|
|
// Verify the server module loads without errors
|
|
const mod = await import('../../src/mcp/server.ts');
|
|
expect(typeof mod.startMcpServer).toBe('function');
|
|
expect(typeof mod.handleToolCall).toBe('function');
|
|
});
|
|
});
|