The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
test(realtime): read each parity case after its notification sends have settled
Maurice900f2bfc30ec
diff --git a/server/tests/integration/broadcast-parity/harness.ts b/server/tests/integration/broadcast-parity/harness.tsindex 445efdc09..6eae6d9d3 100644--- a/server/tests/integration/broadcast-parity/harness.ts+++ b/server/tests/integration/broadcast-parity/harness.ts@@ -13,6 +13,7 @@ import { RoadtripVias } from '../../../src/db/entities/RoadtripVias.entity';import { createLocalMcpServer, McpRegistryService } from '../../../src/nest-mcp';import { AccommodationsService } from '../../../src/nest/accommodations/accommodations.service';import { withRequestContext } from '../../../src/nest/database/request-context';+import { NotificationsService } from '../../../src/nest/notifications/notifications.service';import { RealtimeService } from '../../../src/nest/realtime/realtime.service';import { SchoolHolidaysService } from '../../../src/nest/school-holidays/school-holidays.service';import { authCookie } from '../../helpers/auth';@@ -209,6 +210,12 @@ export interface ParityHarness {listTools(userId: number): Promise<ListedTool[]>;/** The REST twin, as `userId`, with the session cookie and X-Socket-Id 'sock-rest'. */rest(userId: number, call: RestCall, s: Scene): Promise<{ status: number; text: string }>;+ /**+ * Resolves once every notification send started so far has finished. A+ * write starts most of them without waiting, and on Postgres one still runs+ * after the answer, so the case reads its recording only after this.+ */+ notificationsSettled(): Promise<void>;close(): Promise<void>;}@@ -296,6 +303,7 @@ export async function openHarness(): Promise<ParityHarness> {const res = call.body ? await req.send(call.body(s)) : await req;return { status: res.status, text: res.text };},+ notificationsSettled: () => app.get(NotificationsService).settled(),close: async () => {vi.restoreAllMocks();await app.close();diff --git a/server/tests/integration/broadcast-parity/run-group.ts b/server/tests/integration/broadcast-parity/run-group.tsindex a2d1da5be..59d5dda1c 100644--- a/server/tests/integration/broadcast-parity/run-group.ts+++ b/server/tests/integration/broadcast-parity/run-group.ts@@ -169,6 +169,16 @@ function nothingSentYet(h: ParityHarness, before: string): void {const nextMacrotask = () => new Promise<void>((resolve) => setImmediate(resolve));+/**+ * What a write left running once it answered: a send one macrotask later when+ * the case says so, then every notification send it started, so each send is+ * read with the case that caused it.+ */+async function writeSettled(h: ParityHarness, settle: boolean | undefined): Promise<void> {+ if (settle) await nextMacrotask();+ await h.notificationsSettled();+}+async function runCase(h: ParityHarness, c: ParityCase): Promise<void> {const restore = c.stub?.(h.app);try {@@ -176,7 +186,7 @@ async function runCase(h: ParityHarness, c: ParityCase): Promise<void> {await c.setup?.(mcpScene, h.app);nothingSentYet(h, `${c.tool} ran over MCP`);const outcome = await h.callTool(actorOf(c, mcpScene).id, c.tool, c.args(mcpScene));- if (c.settle) await nextMacrotask();+ await writeSettled(h, c.settle);const mcp = h.recorder.take();expect(outcome.isError, `${c.tool} failed over MCP: ${outcome.text}`).toBe(false);checkSurface('MCP', c, mcp, mcpScene);@@ -186,7 +196,7 @@ async function runCase(h: ParityHarness, c: ParityCase): Promise<void> {await c.setup?.(restScene, h.app);nothingSentYet(h, `the REST twin of ${c.tool} ran`);const res = await h.rest(actorOf(c, restScene).id, c.rest, restScene);- if (c.settle) await nextMacrotask();+ await writeSettled(h, c.settle);const rest = h.recorder.take();expect(res.status, `the REST twin of ${c.tool} answered ${res.status}: ${res.text}`).toBeGreaterThanOrEqual(200);expect(res.status, `the REST twin of ${c.tool} answered ${res.status}: ${res.text}`).toBeLessThan(300);@@ -208,7 +218,7 @@ async function runExempt(h: ParityHarness, e: ExemptTool): Promise<void> {expect(before.isError, `${e.first.tool}, run before ${e.tool}, failed: ${before.text}`).toBe(false);}const outcome = await h.callTool(actor.id, e.tool, e.args(s));- await nextMacrotask();+ await writeSettled(h, true);const sent = h.recorder.take();expect(outcome.isError, `${e.tool} failed over MCP: ${outcome.text}`).toBe(false);expect(sent, `${e.tool} is exempt as silent, yet sent:\n${trace(sent)}`).toEqual([]);