21 integration tests (14 broker behavior + 7 path encoding), all passing in ~1s against a real Postgres (claudemesh_test database on the dev container). Test infrastructure: - apps/broker/vitest.config.ts extends @turbostarter/vitest-config/base - tests/helpers.ts: setupTestMesh() creates a fresh mesh + 2 members per test with a unique slug, returns cleanup function that cascades the delete. cleanupAllTestMeshes() as an afterAll safety net. - Mesh isolation in broker logic means tests don't interfere even when they share a database — no per-test TRUNCATE needed. Ported behavior tests (broker.test.ts, 14 tests): - hook flips status + queued "next" messages unblock - "now"-priority bypasses the working gate - DND is sacred (hooks cannot unset it) - hook source stays fresh through jsonl refresh - source decays to jsonl when hook signal goes stale - isHookFresh freshness window + source-type rules - TTL sweep flips stuck "working" → idle - TTL sweep leaves DND alone - first-turn race: hook fired pre-connect stashed in pending_status - applyPendingHookStatus picks newest matching entry - expired pending entries are ignored on connect - broadcast targetSpec (*) reaches all members - pubkey mismatch → message not drained - mesh isolation: peer in mesh X doesn't drain from mesh Y Ported encoding tests (encoding.test.ts, 7 tests): - macOS, Linux, Windows path encoding first-candidate correctness - Roberto's H:\Claude → H--Claude regression test (2026-04-04) - Candidate dedup, drive-stripped fallback, leading-dash fallback How to run: from apps/broker, DATABASE_URL="postgresql://.../claudemesh_test" pnpm test Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
29 lines
809 B
TypeScript
29 lines
809 B
TypeScript
import baseConfig from "@turbostarter/vitest-config/base";
|
|
import { defineConfig, mergeConfig } from "vitest/config";
|
|
|
|
/**
|
|
* Broker test suite.
|
|
*
|
|
* Integration tests run against a real Postgres database (default:
|
|
* claudemesh_test on the dev Postgres container). Set DATABASE_URL
|
|
* in the environment to point elsewhere.
|
|
*
|
|
* Tests rely on mesh isolation: each test creates its own mesh via
|
|
* the setupTestMesh helper, so tests can run in parallel without
|
|
* colliding. No per-test TRUNCATE needed.
|
|
*/
|
|
export default mergeConfig(
|
|
baseConfig,
|
|
defineConfig({
|
|
test: {
|
|
testTimeout: 10_000,
|
|
hookTimeout: 10_000,
|
|
// Keep sequential initially — can flip to parallel once
|
|
// per-test isolation is proven.
|
|
sequence: {
|
|
concurrent: false,
|
|
},
|
|
},
|
|
}),
|
|
);
|