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(db): run the trips and vacay MCP suites and the route inventory on the real database module
Maurice377f22972b8c
diff --git a/server/scripts/test-mocks-baseline.json b/server/scripts/test-mocks-baseline.jsonindex a2c722ced..6989f8fc7 100644--- a/server/scripts/test-mocks-baseline.json+++ b/server/scripts/test-mocks-baseline.json@@ -66,8 +66,6 @@"tests/unit/mcp/tools-notifications.test.ts": 1,"tests/unit/mcp/tools-packing-advanced.test.ts": 1,"tests/unit/mcp/tools-prompts.test.ts": 1,- "tests/unit/mcp/tools-trips.test.ts": 1,- "tests/unit/mcp/tools-vacay.test.ts": 1,"tests/unit/nest/accommodations.service.test.ts": 1,"tests/unit/nest/admin.service.test.ts": 1,"tests/unit/nest/admin.version-notification.test.ts": 1,@@ -135,7 +133,6 @@"tests/unit/nest/registration-invites.service.test.ts": 1,"tests/unit/nest/reminder-jobs.service.test.ts": 1,"tests/unit/nest/reservations.service.test.ts": 1,- "tests/unit/nest/route-inventory.test.ts": 1,"tests/unit/nest/settings.service.test.ts": 1,"tests/unit/nest/share.service.test.ts": 1,"tests/unit/nest/storage/storage-admin.service.test.ts": 1,diff --git a/server/tests/postgres/snapshot-suites-baseline.json b/server/tests/postgres/snapshot-suites-baseline.jsonindex d7d6f8b39..d1c49236f 100644--- a/server/tests/postgres/snapshot-suites-baseline.json+++ b/server/tests/postgres/snapshot-suites-baseline.json@@ -1,8 +1,5 @@["tests/unit/mcp/tools-notifications.test.ts","tests/unit/mcp/tools-packing-advanced.test.ts",- "tests/unit/mcp/tools-trips.test.ts",- "tests/unit/mcp/tools-vacay.test.ts",- "tests/unit/nest/route-inventory.test.ts","tests/websocket/wire-envelope.test.ts"]diff --git a/server/tests/unit/mcp/tools-trips.test.ts b/server/tests/unit/mcp/tools-trips.test.tsindex 942efb440..0be1e0a01 100644--- a/server/tests/unit/mcp/tools-trips.test.ts+++ b/server/tests/unit/mcp/tools-trips.test.ts@@ -7,55 +7,43 @@* notice riding the attach ctx, and the scope gating (declarative* trips:write markers + the canReadTrips/canDeleteTrips predicates).*/-import { db as testDb } from '../../../src/db/database';import { Days } from '../../../src/db/entities/Days.entity';import { Trips } from '../../../src/db/entities/Trips.entity';import { VacayEntries } from '../../../src/db/entities/VacayEntries.entity';import { VacayUserYears } from '../../../src/db/entities/VacayUserYears.entity';import { VacayYears } from '../../../src/db/entities/VacayYears.entity';import { invalidatePermissionsCache } from '../../../src/nest/permissions/permissions-cache';-import {- createUser,- createTrip,- createDay,- createPlace,- addTripMember,- createBudgetItem,- createPackingItem,- createReservation,- createDayNote,- createCollabNote,- createDayAssignment,- createDayAccommodation,-} from '../../helpers/factories';+import { makeBudgetItem } from '../../helpers/factories/budget';+import { makeCollabNote } from '../../helpers/factories/collab';+import { makeDayAccommodation, makeDayAssignment, makeDayNote } from '../../helpers/factories/itinerary';import { makePackingItem } from '../../helpers/factories/packing';+import { makePlace } from '../../helpers/factories/places';+import { makeReservation } from '../../helpers/factories/reservations';import { countRows, findRow, findRows, insertRow, insertRows, updateRows } from '../../helpers/factories/rows';import { setAppSetting, setUserSetting } from '../../helpers/factories/settings';+import { addTripMember, makeDay, makeTrip } from '../../helpers/factories/trips';+import { makeUser } from '../../helpers/factories/users';import { makeVacayEntry, makeVacayPlan, addVacayPlanMember } from '../../helpers/factories/vacay';import { FakeRealtimeService } from '../../helpers/fake-realtime';import { createMcpHarness, parseToolResult, parseResourceResult, type McpHarness } from '../../helpers/mcp-harness';-import { resetTestDb } from '../../helpers/test-db';-import { createTestOrm, type TestOrm } from '../../helpers/test-orm';+import { resetDatabase } from '../../helpers/reset-database';+import { bootTestApp } from '../../helpers/test-app';+import { MikroORM } from '@mikro-orm/core';import { MAX_TRIP_DAYS } from '@trek/shared';import { describe, it, expect, vi, beforeAll, beforeEach, afterEach, afterAll } from 'vitest';-vi.mock('../../../src/db/database', async () => {- const { createSnapshotTestDb, buildDbMock } = await import('../../helpers/db-mock');- return buildDbMock(createSnapshotTestDb());-});-const realtime = new FakeRealtimeService();const broadcastMock = realtime.broadcastMock;-let orm: TestOrm;+let orm: MikroORM;beforeAll(async () => {- orm = await createTestOrm(testDb);+ orm = (await bootTestApp(realtime)).get(MikroORM);});-beforeEach(() => {- resetTestDb(testDb);+beforeEach(async () => {+ await resetDatabase(orm);broadcastMock.mockClear();delete process.env.DEMO_MODE;});@@ -66,8 +54,7 @@ afterEach(() => {});afterAll(async () => {- await orm.close();- testDb.close();+ await (await bootTestApp(realtime)).close();});async function tripRow(id: number) {@@ -108,7 +95,7 @@ async function withHarness(userId: number, fn: (h: McpHarness) => Promise<void>)describe('Tool: create_trip', () => {it('creates a trip with title only and generates 7 default days', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'create_trip', arguments: { title: 'Summer Escape' } });const data = parseToolResult(result) as any;@@ -120,7 +107,7 @@ describe('Tool: create_trip', () => {});it('creates a trip with dates and auto-generates correct number of days', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'create_trip',@@ -133,7 +120,7 @@ describe('Tool: create_trip', () => {});it('generates every day of a trip longer than a year (#2403)', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'create_trip',@@ -146,7 +133,7 @@ describe('Tool: create_trip', () => {});it('refuses a date range longer than MAX_TRIP_DAYS instead of cutting the days short', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'create_trip',@@ -159,7 +146,7 @@ describe('Tool: create_trip', () => {});it('returns error for invalid start_date format', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'create_trip',@@ -170,7 +157,7 @@ describe('Tool: create_trip', () => {});it('returns error when end_date is before start_date', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'create_trip',@@ -182,7 +169,7 @@ describe('Tool: create_trip', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'create_trip', arguments: { title: 'Demo Trip' } });expect(result.isError).toBe(true);@@ -190,7 +177,7 @@ describe('Tool: create_trip', () => {});it('gives a dateless trip the requested day_count instead of the default 7', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'create_trip',@@ -206,7 +193,7 @@ describe('Tool: create_trip', () => {});it('refuses a day_count outside 1..MAX_TRIP_DAYS', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {expect((await h.client.callTool({ name: 'create_trip', arguments: { title: 'Zero', day_count: 0 } })).isError,@@ -220,7 +207,7 @@ describe('Tool: create_trip', () => {});it('stores the requested reminder_days', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'create_trip',@@ -233,7 +220,7 @@ describe('Tool: create_trip', () => {});it('turns the reminder off with reminder_days 0 rather than falling back to 3', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'create_trip', arguments: { title: 'Quiet', reminder_days: 0 } });const data = parseToolResult(result) as any;@@ -243,7 +230,7 @@ describe('Tool: create_trip', () => {});it('refuses a reminder_days outside 0..30', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {expect((await h.client.callTool({ name: 'create_trip', arguments: { title: 'Early', reminder_days: 31 } })).isError,@@ -256,7 +243,7 @@ describe('Tool: create_trip', () => {});it('gives a trip without a currency the display currency from the settings, not EUR', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await setUserSetting(orm, user.id, 'default_currency', JSON.stringify('USD'));await withHarness(user.id, async (h) => {const fromSettings = parseToolResult(@@ -271,7 +258,7 @@ describe('Tool: create_trip', () => {});it('falls back to EUR when neither the user nor the admin set a display currency', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const data = parseToolResult(await h.client.callTool({ name: 'create_trip', arguments: { title: 'Plain' } }),@@ -287,8 +274,8 @@ describe('Tool: create_trip', () => {describe('Tool: update_trip', () => {it('updates trip title', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { title: 'Old Title' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { title: 'Old Title' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'update_trip',@@ -300,8 +287,8 @@ describe('Tool: update_trip', () => {});it('partial update preserves unspecified fields', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { title: 'My Trip', description: 'A great trip' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { title: 'My Trip', description: 'A great trip' });await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, title: 'Renamed' } });const updated = await tripRow(trip.id);@@ -311,8 +298,8 @@ describe('Tool: update_trip', () => {});it('broadcasts trip:updated event', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, title: 'Updated' } });expect(broadcastMock).toHaveBeenCalledWith(trip.id, 'trip:updated', expect.any(Object));@@ -320,9 +307,9 @@ describe('Tool: update_trip', () => {});it('returns access denied for non-member', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);- const trip = createTrip(testDb, other.id);+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);+ const trip = await makeTrip(orm, other.id);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, title: 'Hack' } });expect(result.isError).toBe(true);@@ -331,8 +318,8 @@ describe('Tool: update_trip', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm, { email: '[email protected]' });+ const trip = await makeTrip(orm, user.id);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, title: 'New' } });expect(result.isError).toBe(true);@@ -340,8 +327,8 @@ describe('Tool: update_trip', () => {});it('shifts owner vacay entries when update_trip moves trip window by fixed offset', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { start_date: '2026-08-01', end_date: '2026-08-09' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { start_date: '2026-08-01', end_date: '2026-08-09' });// Materialize active vacay plan for owner and entries in old trip window.const planId = await vacayPlanWithYear(user.id);@@ -367,9 +354,9 @@ describe('Tool: update_trip', () => {});it('shifts the owner entries in the plan they are active in, a shared plan they joined included (#2604)', async () => {- const { user } = createUser(testDb);- const { user: otherOwner } = createUser(testDb);- const trip = createTrip(testDb, user.id, { start_date: '2026-09-01', end_date: '2026-09-07' });+ const { user } = await makeUser(orm);+ const { user: otherOwner } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { start_date: '2026-09-01', end_date: '2026-09-07' });// Joining a plan moves the owner's days into it, so that is where they live.const { id: sharedPlanId } = await makeVacayPlan(orm, otherOwner.id);@@ -394,8 +381,8 @@ describe('Tool: update_trip', () => {});it('clear_dates turns a dated trip back into a dateless one and un-dates its days', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { start_date: '2026-07-01', end_date: '2026-07-05' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { start_date: '2026-07-01', end_date: '2026-07-05' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'update_trip',@@ -411,8 +398,8 @@ describe('Tool: update_trip', () => {});it('clear_dates with a day_count resizes the now dateless trip', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { start_date: '2026-07-01', end_date: '2026-07-05' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { start_date: '2026-07-01', end_date: '2026-07-05' });await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, clear_dates: true, day_count: 3 } });const days = await countRows(orm, Days, { trip: trip.id });@@ -421,8 +408,8 @@ describe('Tool: update_trip', () => {});it('refuses clear_dates alongside a start_date and leaves the trip untouched', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { start_date: '2026-07-01', end_date: '2026-07-05' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { start_date: '2026-07-01', end_date: '2026-07-05' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'update_trip',@@ -435,8 +422,8 @@ describe('Tool: update_trip', () => {});it('resizes a dateless trip with day_count', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);await insertRows(orm, Days, [{ trip: trip.id, day_number: 1, date: null },{ trip: trip.id, day_number: 2, date: null },@@ -449,8 +436,8 @@ describe('Tool: update_trip', () => {});it('refuses a day_count outside 1..MAX_TRIP_DAYS', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { title: 'Untouched' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { title: 'Untouched' });await withHarness(user.id, async (h) => {expect((await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, day_count: 0 } })).isError,@@ -464,7 +451,7 @@ describe('Tool: update_trip', () => {});it('says in its description what shortening a dated trip takes, and where the result lists it', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const tool = (await h.client.listTools()).tools.find((t) => t.name === 'update_trip');expect(tool?.description).toContain('Shortening a dated trip deletes its last days by position');@@ -473,8 +460,8 @@ describe('Tool: update_trip', () => {});it('lists the days an earlier end removed, as they stood before, and none for a rename', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { start_date: '2026-07-01', end_date: '2026-07-05' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { start_date: '2026-07-01', end_date: '2026-07-05' });const days = await findRows(orm, Days, { trip: trip.id }, { day_number: 'asc' });await withHarness(user.id, async (h) => {type Answer = { trip: { end_date: string; title: string }; removed_days?: unknown[] };@@ -495,8 +482,8 @@ describe('Tool: update_trip', () => {});it('refuses a date range longer than MAX_TRIP_DAYS and leaves the trip untouched', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { title: 'Untouched', start_date: '2026-07-01', end_date: '2026-07-07' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { title: 'Untouched', start_date: '2026-07-01', end_date: '2026-07-07' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'update_trip',@@ -510,8 +497,8 @@ describe('Tool: update_trip', () => {});it('changes reminder_days and can turn the reminder off', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, reminder_days: 10 } });expect((await tripRow(trip.id)).reminder_days).toBe(10);@@ -521,8 +508,8 @@ describe('Tool: update_trip', () => {});it('refuses a reminder_days outside 0..30 and keeps the stored value', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'update_trip',@@ -534,8 +521,8 @@ describe('Tool: update_trip', () => {});it('clears the description with an explicit null', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { description: 'A great trip' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { description: 'A great trip' });await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, description: null } });const row = await tripRow(trip.id);@@ -544,8 +531,8 @@ describe('Tool: update_trip', () => {});it('clears the cover image with an explicit null', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);await updateRows(orm, Trips, { id: trip.id }, { cover_image: '/uploads/covers/old.jpg' });await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'update_trip', arguments: { tripId: trip.id, cover_image: null } });@@ -572,7 +559,7 @@ describe('Tool: search_cover_images', () => {}it('returns the photo candidates for a query', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);stubUnsplash({results: [{@@ -597,7 +584,7 @@ describe('Tool: search_cover_images', () => {});it('reports an upstream failure as a tool error', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);stubUnsplash({ errors: ['Rate Limit Exceeded'] }, { ok: false, status: 429 });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'search_cover_images', arguments: { query: 'Lisbon' } });@@ -607,7 +594,7 @@ describe('Tool: search_cover_images', () => {});it('refuses an empty query without reaching Unsplash', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);const fetchMock = vi.fn();vi.stubGlobal('fetch', fetchMock);await withHarness(user.id, async (h) => {@@ -618,8 +605,8 @@ describe('Tool: search_cover_images', () => {});it('saves nothing on the trip', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);stubUnsplash({ results: [] });await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'search_cover_images', arguments: { query: 'Lisbon' } });@@ -635,8 +622,8 @@ describe('Tool: search_cover_images', () => {describe('Tool: delete_trip', () => {it('owner can delete trip', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'delete_trip', arguments: { tripId: trip.id } });const data = parseToolResult(result) as any;@@ -647,10 +634,10 @@ describe('Tool: delete_trip', () => {});it('non-owner member cannot delete trip', async () => {- const { user } = createUser(testDb);- const { user: owner } = createUser(testDb);- const trip = createTrip(testDb, owner.id);- addTripMember(testDb, trip.id, user.id);+ const { user } = await makeUser(orm);+ const { user: owner } = await makeUser(orm);+ const trip = await makeTrip(orm, owner.id);+ await addTripMember(orm, trip.id, user.id);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'delete_trip', arguments: { tripId: trip.id } });expect(result.isError).toBe(true);@@ -661,8 +648,8 @@ describe('Tool: delete_trip', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm, { email: '[email protected]' });+ const trip = await makeTrip(orm, user.id);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'delete_trip', arguments: { tripId: trip.id } });expect(result.isError).toBe(true);@@ -676,12 +663,12 @@ describe('Tool: delete_trip', () => {describe('Tool: list_trips', () => {it('returns owned and member trips', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);- createTrip(testDb, user.id, { title: 'My Trip' });- const shared = createTrip(testDb, other.id, { title: 'Shared' });- addTripMember(testDb, shared.id, user.id);- createTrip(testDb, other.id, { title: 'Inaccessible' });+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);+ await makeTrip(orm, user.id, { title: 'My Trip' });+ const shared = await makeTrip(orm, other.id, { title: 'Shared' });+ await addTripMember(orm, shared.id, user.id);+ await makeTrip(orm, other.id, { title: 'Inaccessible' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'list_trips', arguments: {} });@@ -694,9 +681,9 @@ describe('Tool: list_trips', () => {});it('excludes archived trips by default', async () => {- const { user } = createUser(testDb);- createTrip(testDb, user.id, { title: 'Active' });- const archived = createTrip(testDb, user.id, { title: 'Archived' });+ const { user } = await makeUser(orm);+ await makeTrip(orm, user.id, { title: 'Active' });+ const archived = await makeTrip(orm, user.id, { title: 'Archived' });await updateRows(orm, Trips, { id: archived.id }, { is_archived: 1 });await withHarness(user.id, async (h) => {@@ -708,9 +695,9 @@ describe('Tool: list_trips', () => {});it('includes archived trips when include_archived is true', async () => {- const { user } = createUser(testDb);- createTrip(testDb, user.id, { title: 'Active' });- const archived = createTrip(testDb, user.id, { title: 'Archived' });+ const { user } = await makeUser(orm);+ await makeTrip(orm, user.id, { title: 'Active' });+ const archived = await makeTrip(orm, user.id, { title: 'Archived' });await updateRows(orm, Trips, { id: archived.id }, { is_archived: 1 });await withHarness(user.id, async (h) => {@@ -727,18 +714,18 @@ describe('Tool: list_trips', () => {describe('Tool: get_trip_summary', () => {it('returns full denormalized trip snapshot', async () => {- const { user } = createUser(testDb);- const { user: member } = createUser(testDb);- const trip = createTrip(testDb, user.id, { title: 'Full Trip' });- addTripMember(testDb, trip.id, member.id);- const day = createDay(testDb, trip.id);- const place = createPlace(testDb, trip.id, { name: 'Colosseum' });- const assignment = createDayAssignment(testDb, day.id, place.id);- createDayNote(testDb, day.id, trip.id, { text: 'Check in' });- createBudgetItem(testDb, trip.id, { name: 'Hotel', total_price: 300 });- createPackingItem(testDb, trip.id, { name: 'Passport' });- createReservation(testDb, trip.id, { title: 'Flight', type: 'flight' });- createCollabNote(testDb, trip.id, user.id, { title: 'Plan' });+ const { user } = await makeUser(orm);+ const { user: member } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { title: 'Full Trip' });+ await addTripMember(orm, trip.id, member.id);+ const day = await makeDay(orm, trip.id);+ const place = await makePlace(orm, trip.id, { name: 'Colosseum' });+ const assignment = await makeDayAssignment(orm, day.id, place.id);+ await makeDayNote(orm, day.id, trip.id, { text: 'Check in' });+ await makeBudgetItem(orm, trip.id, { name: 'Hotel', total_price: 300 });+ await makePackingItem(orm, trip.id, { name: 'Passport' });+ await makeReservation(orm, trip.id, { title: 'Flight', type: 'flight' });+ await makeCollabNote(orm, trip.id, user.id, { title: 'Plan' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'get_trip_summary', arguments: { tripId: trip.id } });@@ -758,9 +745,9 @@ describe('Tool: get_trip_summary', () => {});it('returns access denied for non-member', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);- const trip = createTrip(testDb, other.id);+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);+ const trip = await makeTrip(orm, other.id);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'get_trip_summary', arguments: { tripId: trip.id } });@@ -770,8 +757,8 @@ describe('Tool: get_trip_summary', () => {it('is not blocked for demo user (read-only tool)', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });- const trip = createTrip(testDb, user.id, { title: 'Demo Trip' });+ const { user } = await makeUser(orm, { email: '[email protected]' });+ const trip = await makeTrip(orm, user.id, { title: 'Demo Trip' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'get_trip_summary', arguments: { tripId: trip.id } });@@ -782,8 +769,8 @@ describe('Tool: get_trip_summary', () => {});it('includes todos, files, pollCount, messageCount in response', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { title: 'Summary Test' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { title: 'Summary Test' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'get_trip_summary', arguments: { tripId: trip.id } });@@ -798,14 +785,14 @@ describe('Tool: get_trip_summary', () => {// member emails, the itinerary, or accommodations. The tool stays registered for// navigation but only surfaces the trip id + title.it('withholds members, days and accommodations from a token without trips:read', async () => {- const { user } = createUser(testDb, { email: '[email protected]' });- const { user: member } = createUser(testDb, { email: '[email protected]' });- const trip = createTrip(testDb, user.id, { title: 'Confidential Trip' });- addTripMember(testDb, trip.id, member.id);- const day = createDay(testDb, trip.id);- const place = createPlace(testDb, trip.id, { name: 'Colosseum', lat: 41.89, lng: 12.49 });- createDayAssignment(testDb, day.id, place.id);- createDayAccommodation(testDb, trip.id, place.id, day.id, day.id);+ const { user } = await makeUser(orm, { email: '[email protected]' });+ const { user: member } = await makeUser(orm, { email: '[email protected]' });+ const trip = await makeTrip(orm, user.id, { title: 'Confidential Trip' });+ await addTripMember(orm, trip.id, member.id);+ const day = await makeDay(orm, trip.id);+ const place = await makePlace(orm, trip.id, { name: 'Colosseum', lat: 41.89, lng: 12.49 });+ await makeDayAssignment(orm, day.id, place.id);+ await makeDayAccommodation(orm, trip.id, place.id, day.id, day.id);const h = await createMcpHarness({ realtime, userId: user.id, withResources: false, scopes: ['weather:read'] });try {@@ -827,11 +814,11 @@ describe('Tool: get_trip_summary', () => {});it('returns the full core bucket for a token that has trips:read', async () => {- const { user } = createUser(testDb);- const { user: member } = createUser(testDb);- const trip = createTrip(testDb, user.id, { title: 'Scoped Trip' });- addTripMember(testDb, trip.id, member.id);- createDay(testDb, trip.id);+ const { user } = await makeUser(orm);+ const { user: member } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { title: 'Scoped Trip' });+ await addTripMember(orm, trip.id, member.id);+ await makeDay(orm, trip.id);const h = await createMcpHarness({ realtime, userId: user.id, withResources: false, scopes: ['trips:read'] });try {@@ -848,10 +835,10 @@ describe('Tool: get_trip_summary', () => {// Regression: get_trip_summary must hide another member's private packing items (#858).it("hides another member's private packing item from the summary", async () => {- const { user: owner } = createUser(testDb);- const { user: member } = createUser(testDb);- const trip = createTrip(testDb, owner.id, { title: 'Shared Trip' });- addTripMember(testDb, trip.id, member.id);+ const { user: owner } = await makeUser(orm);+ const { user: member } = await makeUser(orm);+ const trip = await makeTrip(orm, owner.id, { title: 'Shared Trip' });+ await addTripMember(orm, trip.id, member.id);await makePackingItem(orm, trip.id, {name: 'Secret gift',category: 'Misc',@@ -884,13 +871,13 @@ describe('Tool: get_trip_summary', () => {describe('Resource: trek://trips', () => {it('returns all trips the user owns or is a member of', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);- createTrip(testDb, user.id, { title: 'My Trip' });- const sharedTrip = createTrip(testDb, other.id, { title: 'Shared Trip' });- addTripMember(testDb, sharedTrip.id, user.id);+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);+ await makeTrip(orm, user.id, { title: 'My Trip' });+ const sharedTrip = await makeTrip(orm, other.id, { title: 'Shared Trip' });+ await addTripMember(orm, sharedTrip.id, user.id);// Trip from another user (not accessible)- createTrip(testDb, other.id, { title: 'Other Trip' });+ await makeTrip(orm, other.id, { title: 'Other Trip' });await withHarness(user.id, async (harness) => {const result = await harness.client.readResource({ uri: 'trek://trips' });@@ -904,9 +891,9 @@ describe('Resource: trek://trips', () => {});it('excludes archived trips', async () => {- const { user } = createUser(testDb);- createTrip(testDb, user.id, { title: 'Active Trip' });- const archived = createTrip(testDb, user.id, { title: 'Archived Trip' });+ const { user } = await makeUser(orm);+ await makeTrip(orm, user.id, { title: 'Active Trip' });+ const archived = await makeTrip(orm, user.id, { title: 'Archived Trip' });await updateRows(orm, Trips, { id: archived.id }, { is_archived: 1 });await withHarness(user.id, async (harness) => {@@ -918,7 +905,7 @@ describe('Resource: trek://trips', () => {});it('returns empty array when user has no trips', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (harness) => {const result = await harness.client.readResource({ uri: 'trek://trips' });const trips = parseResourceResult(result) as any[];@@ -929,8 +916,8 @@ describe('Resource: trek://trips', () => {describe('Resource: trek://trips/{tripId}', () => {it('returns trip data for an accessible trip', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id, { title: 'Paris Trip' });+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id, { title: 'Paris Trip' });await withHarness(user.id, async (harness) => {const result = await harness.client.readResource({ uri: `trek://trips/${trip.id}` });@@ -941,9 +928,9 @@ describe('Resource: trek://trips/{tripId}', () => {});it('returns access denied for inaccessible trip', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);- const otherTrip = createTrip(testDb, other.id, { title: 'Private' });+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);+ const otherTrip = await makeTrip(orm, other.id, { title: 'Private' });await withHarness(user.id, async (harness) => {const result = await harness.client.readResource({ uri: `trek://trips/${otherTrip.id}` });@@ -953,7 +940,7 @@ describe('Resource: trek://trips/{tripId}', () => {});it('returns access denied for non-existent ID', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (harness) => {const result = await harness.client.readResource({ uri: 'trek://trips/99999' });const data = parseResourceResult(result) as any;@@ -964,10 +951,10 @@ describe('Resource: trek://trips/{tripId}', () => {describe('Resource: trek://trips/{tripId}/members', () => {it('returns owner and collaborators', async () => {- const { user } = createUser(testDb);- const { user: member } = createUser(testDb);- const trip = createTrip(testDb, user.id);- addTripMember(testDb, trip.id, member.id);+ const { user } = await makeUser(orm);+ const { user: member } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);+ await addTripMember(orm, trip.id, member.id);await withHarness(user.id, async (harness) => {const result = await harness.client.readResource({ uri: `trek://trips/${trip.id}/members` });@@ -980,9 +967,9 @@ describe('Resource: trek://trips/{tripId}/members', () => {});it('returns access denied for unauthorized trip', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);- const trip = createTrip(testDb, other.id);+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);+ const trip = await makeTrip(orm, other.id);await withHarness(user.id, async (harness) => {const result = await harness.client.readResource({ uri: `trek://trips/${trip.id}/members` });@@ -998,8 +985,8 @@ describe('Resource: trek://trips/{tripId}/members', () => {describe('static-token deprecation notice', () => {it('list_trips surfaces the notice exactly once and still carries the payload', async () => {- const { user } = createUser(testDb);- createTrip(testDb, user.id, { title: 'Noticed' });+ const { user } = await makeUser(orm);+ await makeTrip(orm, user.id, { title: 'Noticed' });// Mirror the fire-once closure built per session in src/mcp/index.ts.let emitted = false;const getDeprecationNotice = () => {@@ -1113,7 +1100,7 @@ describe('Trip writes, as REST makes them', () => {});it('MCP-TRIPS-001: create_trip and copy_trip tell every tab of the owner that the trip list changed', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const created = parseToolResult(await h.client.callTool({ name: 'create_trip', arguments: { title: 'Lisbon' } }),@@ -1127,8 +1114,8 @@ describe('Trip writes, as REST makes them', () => {});it('MCP-TRIPS-002: create_trip and copy_trip are refused without trip_create, as the routes refuse them', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);await setPermission('trip_create', 'admin');await withHarness(user.id, async (h) => {const created = await h.client.callTool({ name: 'create_trip', arguments: { title: 'Lisbon' } });@@ -1143,8 +1130,8 @@ describe('Trip writes, as REST makes them', () => {});it('MCP-TRIPS-003: delete_trip tells the room the trip is gone, as the route does', async () => {- const { user } = createUser(testDb);- const trip = createTrip(testDb, user.id);+ const { user } = await makeUser(orm);+ const trip = await makeTrip(orm, user.id);await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'delete_trip', arguments: { tripId: trip.id } });});@@ -1152,10 +1139,10 @@ describe('Trip writes, as REST makes them', () => {});it('MCP-TRIPS-004: update_trip asks trip_archive and trip_cover_upload for those fields, not trip_edit alone', async () => {- const { user: owner } = createUser(testDb);- const { user: member } = createUser(testDb);- const trip = createTrip(testDb, owner.id, { title: 'Before' });- addTripMember(testDb, trip.id, member.id);+ const { user: owner } = await makeUser(orm);+ const { user: member } = await makeUser(orm);+ const trip = await makeTrip(orm, owner.id, { title: 'Before' });+ await addTripMember(orm, trip.id, member.id);await setPermission('trip_edit', 'trip_member');await withHarness(member.id, async (h) => {const archive = await h.client.callTool({@@ -1181,10 +1168,10 @@ describe('Trip writes, as REST makes them', () => {});it('MCP-TRIPS-005: update_trip sets the costs mode on budget_edit, as the route does (#1714)', async () => {- const { user: owner } = createUser(testDb);- const { user: member } = createUser(testDb);- const trip = createTrip(testDb, owner.id);- addTripMember(testDb, trip.id, member.id);+ const { user: owner } = await makeUser(orm);+ const { user: member } = await makeUser(orm);+ const trip = await makeTrip(orm, owner.id);+ await addTripMember(orm, trip.id, member.id);expect((await tripRow(trip.id)).costs_mode).toBe('split');// A member may edit the costs by default, though not the trip's own details.await withHarness(member.id, async (h) => {diff --git a/server/tests/unit/mcp/tools-vacay.test.ts b/server/tests/unit/mcp/tools-vacay.test.tsindex 439d2648f..4de27b8ab 100644--- a/server/tests/unit/mcp/tools-vacay.test.ts+++ b/server/tests/unit/mcp/tools-vacay.test.ts@@ -14,7 +14,6 @@* registerTools), so `withTools` must stay on even for resource reads.*/import { ADDON_IDS } from '../../../src/addons';-import { db as testDb } from '../../../src/db/database';import { VacayEntries } from '../../../src/db/entities/VacayEntries.entity';import { VacayHolidayCalendars } from '../../../src/db/entities/VacayHolidayCalendars.entity';import { VacayPlanMembers } from '../../../src/db/entities/VacayPlanMembers.entity';@@ -23,30 +22,26 @@ import { VacayShares } from '../../../src/db/entities/VacayShares.entity';import { VacayUserSettings } from '../../../src/db/entities/VacayUserSettings.entity';import { DomainError } from '../../../src/nest/common/domain-error';import { VacayService } from '../../../src/nest/vacay/vacay.service';-import { createUser } from '../../helpers/factories';import { findRow, insertRow } from '../../helpers/factories/rows';+import { setAddonEnabled } from '../../helpers/factories/settings';+import { makeUser } from '../../helpers/factories/users';import { FakeRealtimeService } from '../../helpers/fake-realtime';import { createMcpHarness, parseToolResult, parseResourceResult, type McpHarness } from '../../helpers/mcp-harness';-// share_vacay_calendar fires a user notification after inserting; stub it out+import { resetDatabase } from '../../helpers/reset-database';+import { bootTestApp } from '../../helpers/test-app';+import { MikroORM } from '@mikro-orm/core';-import { resetTestDb } from '../../helpers/test-db';-import { setAddonEnabled } from '../../helpers/test-db';-import { createTestOrm, type TestOrm } from '../../helpers/test-orm';+// share_vacay_calendar fires a user notification after inserting; stub it outimport { describe, it, expect, vi, beforeAll, beforeEach, afterEach, afterAll } from 'vitest';-vi.mock('../../../src/db/database', async () => {- const { createSnapshotTestDb, buildDbMock } = await import('../../helpers/db-mock');- return buildDbMock(createSnapshotTestDb());-});-const realtime = new FakeRealtimeService();const broadcastMock = realtime.broadcastMock;-let orm: TestOrm;+let orm: MikroORM;beforeAll(async () => {- orm = await createTestOrm(testDb);+ orm = (await bootTestApp(realtime)).get(MikroORM);});/** The plan the user was invited into. */@@ -80,11 +75,11 @@ const schoolHolidaysSpy = vi.spyOn(VacayService.prototype, 'getSchoolHolidays').data: [{ name: 'Sommerferien', startDate: '2025-07-28', endDate: '2025-09-08' }],});-beforeEach(() => {- resetTestDb(testDb);+beforeEach(async () => {+ await resetDatabase(orm);// The `when:` gate reads the injected AddonsService, so the toggle is the row// the admin panel writes — and this addon ships disabled by default.- setAddonEnabled(testDb, ADDON_IDS.VACAY, true);+ await setAddonEnabled(orm, ADDON_IDS.VACAY, true);broadcastMock.mockClear();updatePlanSpy.mockClear();schoolRegionsSpy.mockClear();@@ -93,8 +88,7 @@ beforeEach(() => {});afterAll(async () => {- await orm.close();- testDb.close();+ await (await bootTestApp(realtime)).close();});async function withHarness(userId: number, fn: (h: McpHarness) => Promise<void>) {@@ -138,7 +132,7 @@ async function fusePlan(ownerId: number, memberId: number): Promise<number> {describe('Tool: get_vacay_plan', () => {it('returns plan data object', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'get_vacay_plan', arguments: {} });const data = parseToolResult(result) as any;@@ -153,7 +147,7 @@ describe('Tool: get_vacay_plan', () => {describe('Tool: update_vacay_plan', () => {it('calls updatePlan and returns the hydrated plan', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'update_vacay_plan',@@ -169,7 +163,7 @@ describe('Tool: update_vacay_plan', () => {});it('persists school holidays, the weekend weekdays and the week start', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);updatePlanSpy.mockImplementationOnce(realUpdatePlan);await withHarness(user.id, async (h) => {const result = await h.client.callTool({@@ -187,7 +181,7 @@ describe('Tool: update_vacay_plan', () => {});it('leaves the untouched settings alone', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);updatePlanSpy.mockImplementationOnce(realUpdatePlan);await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'update_vacay_plan', arguments: { weekend_days: '1,2' } });@@ -200,7 +194,7 @@ describe('Tool: update_vacay_plan', () => {});it('refuses a non-numeric week_start', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'update_vacay_plan', arguments: { week_start: 'monday' } });expect(result.isError).toBe(true);@@ -210,7 +204,7 @@ describe('Tool: update_vacay_plan', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'update_vacay_plan', arguments: { block_weekends: true } });expect(result.isError).toBe(true);@@ -224,7 +218,7 @@ describe('Tool: update_vacay_plan', () => {describe('Tool: get_vacay_year_settings', () => {it('falls back to the calendar year when nothing is stored', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'get_vacay_year_settings', arguments: {} });const data = parseToolResult(result) as any;@@ -235,7 +229,7 @@ describe('Tool: get_vacay_year_settings', () => {});it('returns a stored fiscal window', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await insertRow(orm, VacayUserSettings, {user: user.id,year_type: 'fiscal',@@ -259,7 +253,7 @@ describe('Tool: get_vacay_year_settings', () => {describe('Tool: set_vacay_color', () => {it('updates color and returns success', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'set_vacay_color', arguments: { color: '#ff0000' } });const data = parseToolResult(result) as any;@@ -270,7 +264,7 @@ describe('Tool: set_vacay_color', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'set_vacay_color', arguments: { color: '#ff0000' } });expect(result.isError).toBe(true);@@ -284,7 +278,7 @@ describe('Tool: set_vacay_color', () => {describe('Tool: list_vacay_years', () => {it('returns years array', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'list_vacay_years', arguments: {} });const data = parseToolResult(result) as any;@@ -299,7 +293,7 @@ describe('Tool: list_vacay_years', () => {describe('Tool: add_vacay_year', () => {it('adds year to list', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'add_vacay_year', arguments: { year: 2025 } });const data = parseToolResult(result) as any;@@ -310,7 +304,7 @@ describe('Tool: add_vacay_year', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'add_vacay_year', arguments: { year: 2025 } });expect(result.isError).toBe(true);@@ -324,7 +318,7 @@ describe('Tool: add_vacay_year', () => {describe('Tool: delete_vacay_year', () => {it('removes year from list', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {// Add year firstawait h.client.callTool({ name: 'add_vacay_year', arguments: { year: 2025 } });@@ -337,7 +331,7 @@ describe('Tool: delete_vacay_year', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'delete_vacay_year', arguments: { year: 2025 } });expect(result.isError).toBe(true);@@ -351,7 +345,7 @@ describe('Tool: delete_vacay_year', () => {describe('Tool: get_vacay_entries', () => {it('returns entries array (empty initially)', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'get_vacay_entries', arguments: { year: 2025 } });const data = parseToolResult(result) as any;@@ -367,7 +361,7 @@ describe('Tool: get_vacay_entries', () => {describe('Tool: toggle_vacay_entry', () => {it('toggles entry and returns action', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'toggle_vacay_entry', arguments: { date: '2025-06-16' } });const data = parseToolResult(result) as any;@@ -376,7 +370,7 @@ describe('Tool: toggle_vacay_entry', () => {});it('logs a half day', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'toggle_vacay_entry',@@ -392,7 +386,7 @@ describe('Tool: toggle_vacay_entry', () => {});it('logs a comp day', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'toggle_vacay_entry', arguments: { date: '2025-06-17', kind: 'comp' } });const row = (await findRow(orm, VacayEntries, { user: user.id, date: '2025-06-17' }))!;@@ -402,7 +396,7 @@ describe('Tool: toggle_vacay_entry', () => {});it('converts the day in place on a different fraction and clears it on a repeat', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);const row = () => findRow(orm, VacayEntries, { user: user.id, date: '2025-06-18' });await withHarness(user.id, async (h) => {await h.client.callTool({@@ -429,8 +423,8 @@ describe('Tool: toggle_vacay_entry', () => {});it('logs the day for another member of the plan', async () => {- const { user: owner } = createUser(testDb);- const { user: member } = createUser(testDb);+ const { user: owner } = await makeUser(orm);+ const { user: member } = await makeUser(orm);await fusePlan(owner.id, member.id);await withHarness(owner.id, async (h) => {@@ -447,8 +441,8 @@ describe('Tool: toggle_vacay_entry', () => {});it('refuses a target user outside the plan, the way POST /entries/toggle does', async () => {- const { user } = createUser(testDb);- const { user: stranger } = createUser(testDb);+ const { user } = await makeUser(orm);+ const { user: stranger } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'toggle_vacay_entry',@@ -461,7 +455,7 @@ describe('Tool: toggle_vacay_entry', () => {});it('refuses a fraction the contract does not allow', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'toggle_vacay_entry',@@ -473,7 +467,7 @@ describe('Tool: toggle_vacay_entry', () => {});it('refuses a leave kind the contract does not allow', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'toggle_vacay_entry',@@ -486,7 +480,7 @@ describe('Tool: toggle_vacay_entry', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'toggle_vacay_entry', arguments: { date: '2025-06-16' } });expect(result.isError).toBe(true);@@ -500,7 +494,7 @@ describe('Tool: toggle_vacay_entry', () => {describe('Tool: toggle_company_holiday', () => {it('toggles company holiday and returns action', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'toggle_company_holiday',@@ -512,7 +506,7 @@ describe('Tool: toggle_company_holiday', () => {});it('makes a half company holiday like the REST route (#2439)', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const data = parseToolResult(await h.client.callTool({@@ -526,7 +520,7 @@ describe('Tool: toggle_company_holiday', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'toggle_company_holiday', arguments: { date: '2025-12-25' } });expect(result.isError).toBe(true);@@ -540,7 +534,7 @@ describe('Tool: toggle_company_holiday', () => {describe('Tool: get_vacay_stats', () => {it('returns stats object', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'get_vacay_stats', arguments: { year: 2025 } });const data = parseToolResult(result) as any;@@ -555,7 +549,7 @@ describe('Tool: get_vacay_stats', () => {describe('Tool: update_vacay_stats', () => {it('updates vacation days allowance and returns success', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'update_vacay_stats',@@ -568,7 +562,7 @@ describe('Tool: update_vacay_stats', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'update_vacay_stats',@@ -585,7 +579,7 @@ describe('Tool: update_vacay_stats', () => {describe('Tool: add_holiday_calendar', () => {it('inserts calendar row and returns calendar', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'add_holiday_calendar',@@ -598,7 +592,7 @@ describe('Tool: add_holiday_calendar', () => {});it('stores a school-holiday calendar with the colour that goes with the type', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'add_holiday_calendar',@@ -613,7 +607,7 @@ describe('Tool: add_holiday_calendar', () => {});it('still writes a public-holiday calendar when the type is omitted', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'add_holiday_calendar', arguments: { region: 'GB' } });const data = parseToolResult(result) as any;@@ -624,7 +618,7 @@ describe('Tool: add_holiday_calendar', () => {});it('refuses a calendar type outside the contract', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'add_holiday_calendar',@@ -637,7 +631,7 @@ describe('Tool: add_holiday_calendar', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'add_holiday_calendar', arguments: { region: 'US' } });expect(result.isError).toBe(true);@@ -651,7 +645,7 @@ describe('Tool: add_holiday_calendar', () => {describe('Tool: update_holiday_calendar', () => {it('updates label and color', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {// First add a calendarconst addResult = await h.client.callTool({@@ -673,7 +667,7 @@ describe('Tool: update_holiday_calendar', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'update_holiday_calendar',@@ -690,7 +684,7 @@ describe('Tool: update_holiday_calendar', () => {describe('Tool: delete_holiday_calendar', () => {it('removes calendar and returns success', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const addResult = await h.client.callTool({name: 'add_holiday_calendar',@@ -707,7 +701,7 @@ describe('Tool: delete_holiday_calendar', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'delete_holiday_calendar', arguments: { calendarId: 1 } });expect(result.isError).toBe(true);@@ -721,7 +715,7 @@ describe('Tool: delete_holiday_calendar', () => {describe('Tool: list_holiday_countries', () => {it('returns countries from mocked service', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'list_holiday_countries', arguments: {} });const data = parseToolResult(result) as any;@@ -736,7 +730,7 @@ describe('Tool: list_holiday_countries', () => {describe('Tool: list_holidays', () => {it('returns holidays from mocked service', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'list_holidays', arguments: { country: 'US', year: 2025 } });const data = parseToolResult(result) as any;@@ -751,7 +745,7 @@ describe('Tool: list_holidays', () => {describe('Tool: list_school_holiday_regions', () => {it('returns the group and subdivision codes, asking in the country language like the route does', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'list_school_holiday_regions', arguments: { country: 'de' } });const data = parseToolResult(result) as any;@@ -761,7 +755,7 @@ describe('Tool: list_school_holiday_regions', () => {});it('asks in English for every other country', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'list_school_holiday_regions', arguments: { country: 'NL' } });expect(schoolRegionsSpy).toHaveBeenCalledWith('NL', 'EN');@@ -769,7 +763,7 @@ describe('Tool: list_school_holiday_regions', () => {});it('surfaces the upstream failure', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);schoolRegionsSpy.mockRejectedValueOnce(new DomainError(502, 'Failed to fetch school holiday regions'));await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'list_school_holiday_regions', arguments: { country: 'DE' } });@@ -785,7 +779,7 @@ describe('Tool: list_school_holiday_regions', () => {describe('Tool: list_school_holidays', () => {it('forwards the subdivision and group filters', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'list_school_holidays',@@ -798,7 +792,7 @@ describe('Tool: list_school_holidays', () => {});it('leaves both filters unset when they are omitted', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'list_school_holidays', arguments: { country: 'AT', year: 2026 } });expect(schoolHolidaysSpy).toHaveBeenCalledWith('2026', 'AT', undefined, 'EN', undefined);@@ -806,7 +800,7 @@ describe('Tool: list_school_holidays', () => {});it('surfaces the upstream failure', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);schoolHolidaysSpy.mockRejectedValueOnce(new DomainError(502, 'Failed to fetch school holidays'));await withHarness(user.id, async (h) => {const result = await h.client.callTool({@@ -819,7 +813,7 @@ describe('Tool: list_school_holidays', () => {});it('refuses a non-numeric year', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({name: 'list_school_holidays',@@ -837,8 +831,8 @@ describe('Tool: list_school_holidays', () => {describe('Tool: list_vacay_shares', () => {it('returns outgoing and incoming shares', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'share_vacay_calendar', arguments: { targetUserId: other.id } });const result = await h.client.callTool({ name: 'list_vacay_shares', arguments: {} });@@ -857,9 +851,9 @@ describe('Tool: list_vacay_shares', () => {describe('Tool: get_shareable_vacay_users', () => {it('offers users the fusion picker leaves out because they already sit in a plan', async () => {- const { user } = createUser(testDb);- const { user: fusedOwner } = createUser(testDb);- const { user: fusedMember } = createUser(testDb);+ const { user } = await makeUser(orm);+ const { user: fusedOwner } = await makeUser(orm);+ const { user: fusedMember } = await makeUser(orm);await fusePlan(fusedOwner.id, fusedMember.id);await withHarness(user.id, async (h) => {@@ -882,8 +876,8 @@ describe('Tool: get_shareable_vacay_users', () => {});it('drops a user the caller already shares with, and never the caller', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);await withHarness(user.id, async (h) => {const before = parseToolResult(await h.client.callTool({ name: 'get_shareable_vacay_users', arguments: {} }),@@ -906,8 +900,8 @@ describe('Tool: get_shareable_vacay_users', () => {describe('Tool: share_vacay_calendar', () => {it('creates a share and returns success', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'share_vacay_calendar', arguments: { targetUserId: other.id } });const data = parseToolResult(result) as any;@@ -918,7 +912,7 @@ describe('Tool: share_vacay_calendar', () => {});it('errors when sharing with yourself', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'share_vacay_calendar', arguments: { targetUserId: user.id } });expect(result.isError).toBe(true);@@ -927,8 +921,8 @@ describe('Tool: share_vacay_calendar', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });- const { user: other } = createUser(testDb);+ const { user } = await makeUser(orm, { email: '[email protected]' });+ const { user: other } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'share_vacay_calendar', arguments: { targetUserId: other.id } });expect(result.isError).toBe(true);@@ -942,8 +936,8 @@ describe('Tool: share_vacay_calendar', () => {describe('Tool: unshare_vacay_calendar', () => {it('removes an existing share and returns success', async () => {- const { user } = createUser(testDb);- const { user: other } = createUser(testDb);+ const { user } = await makeUser(orm);+ const { user: other } = await makeUser(orm);await withHarness(user.id, async (h) => {await h.client.callTool({ name: 'share_vacay_calendar', arguments: { targetUserId: other.id } });const shareId = (await findRow(orm, VacayShares, { owner: user.id }))!.id;@@ -956,7 +950,7 @@ describe('Tool: unshare_vacay_calendar', () => {});it('errors when the share does not exist', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'unshare_vacay_calendar', arguments: { shareId: 99999 } });expect(result.isError).toBe(true);@@ -965,7 +959,7 @@ describe('Tool: unshare_vacay_calendar', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'unshare_vacay_calendar', arguments: { shareId: 1 } });expect(result.isError).toBe(true);@@ -979,8 +973,8 @@ describe('Tool: unshare_vacay_calendar', () => {describe('Tool: get_shared_vacay_calendars', () => {it('returns the sharer entries for the viewer', async () => {- const { user: owner } = createUser(testDb);- const { user: viewer } = createUser(testDb);+ const { user: owner } = await makeUser(orm);+ const { user: viewer } = await makeUser(orm);await withHarness(owner.id, async (h) => {await h.client.callTool({ name: 'toggle_vacay_entry', arguments: { date: '2025-06-16' } });await h.client.callTool({ name: 'share_vacay_calendar', arguments: { targetUserId: viewer.id } });@@ -1002,7 +996,7 @@ describe('Tool: get_shared_vacay_calendars', () => {describe('Resource: trek://vacay/plan', () => {it('returns plan data', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withResourceHarness(user.id, async (h) => {const result = await h.client.readResource({ uri: 'trek://vacay/plan' });const data = parseResourceResult(result) as any;@@ -1013,7 +1007,7 @@ describe('Resource: trek://vacay/plan', () => {describe('Resource: trek://vacay/entries/{year}', () => {it('returns entries for a year', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withResourceHarness(user.id, async (h) => {const result = await h.client.readResource({ uri: 'trek://vacay/entries/2025' });const data = parseResourceResult(result) as any;@@ -1025,7 +1019,7 @@ describe('Resource: trek://vacay/entries/{year}', () => {describe('Resource: trek://vacay/holidays/{year}', () => {it('returns [] while public holidays are disabled or no region is set', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);await withResourceHarness(user.id, async (h) => {const result = await h.client.readResource({ uri: 'trek://vacay/holidays/2025' });const data = parseResourceResult(result) as unknown[];@@ -1041,8 +1035,8 @@ describe('Resource: trek://vacay/holidays/{year}', () => {describe('Tool: decline_vacay_invite', () => {it('declines a pending invite', async () => {- const { user: owner } = createUser(testDb);- const { user: invitee } = createUser(testDb);+ const { user: owner } = await makeUser(orm);+ const { user: invitee } = await makeUser(orm);await withHarness(owner.id, async (h) => {await h.client.callTool({ name: 'send_vacay_invite', arguments: { targetUserId: invitee.id } });});@@ -1058,7 +1052,7 @@ describe('Tool: decline_vacay_invite', () => {it('blocks demo user', async () => {process.env.DEMO_MODE = 'true';- const { user } = createUser(testDb, { email: '[email protected]' });+ const { user } = await makeUser(orm, { email: '[email protected]' });await withHarness(user.id, async (h) => {const result = await h.client.callTool({ name: 'decline_vacay_invite', arguments: { planId: 1 } });expect(result.isError).toBe(true);@@ -1089,21 +1083,21 @@ describe('Tool: list_school_holiday_regions (the codes a calendar can be built f}it('prefixes a group code with the country, the way the calendar reader expects', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);schoolRegionsSpy.mockResolvedValueOnce({ data: { groups: [{ code: 'NO', name: 'Noord' }], subdivisions: [] } });const data = await regionsFor(user.id, 'NL');expect(data.calendar_regions).toEqual([{ region: 'NL|group:NO', kind: 'group' }]);});it('leaves a subdivision code alone', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);schoolRegionsSpy.mockResolvedValueOnce({ data: { groups: [], subdivisions: [{ code: 'DE-BY', name: 'Bayern' }] } });const data = await regionsFor(user.id, 'DE');expect(data.calendar_regions).toEqual([{ region: 'DE-BY', kind: 'subdivision' }]);});it('walks nested children, which the provider uses for sub-regions', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);schoolRegionsSpy.mockResolvedValueOnce({data: {groups: [],@@ -1115,7 +1109,7 @@ describe('Tool: list_school_holiday_regions (the codes a calendar can be built f});it('still returns the raw provider payload alongside it', async () => {- const { user } = createUser(testDb);+ const { user } = await makeUser(orm);schoolRegionsSpy.mockResolvedValueOnce({ data: { groups: [], subdivisions: [{ code: 'AT-9' }] } });const data = await regionsFor(user.id, 'AT');expect(data.regions.subdivisions).toEqual([{ code: 'AT-9' }]);diff --git a/server/tests/unit/nest/route-inventory.test.ts b/server/tests/unit/nest/route-inventory.test.tsindex 1822bd178..9f02b6877 100644--- a/server/tests/unit/nest/route-inventory.test.ts+++ b/server/tests/unit/nest/route-inventory.test.ts@@ -16,12 +16,7 @@ import {} from '../../../src/nest/common/validate-route-guards';import { Test } from '@nestjs/testing';-import { describe, it, expect, vi } from 'vitest';--vi.mock('../../../src/db/database', async () => {- const { createSnapshotTestDb, buildDbMock } = await import('../../helpers/db-mock');- return buildDbMock(createSnapshotTestDb());-});+import { describe, it, expect } from 'vitest';async function buildApp() {// Plan 4 Task 4: `DatabaseService` is gone — nothing left in the graph