Files
TREK/server/tests/helpers/journey-share-repos.ts
T
Maurice 48d573c60d refactor(trips): leaving a trip tidies its journal link in the roster's own repository
The departure port needed a global binding that every suite building TripMembersModule without AppModule lacked. The roster's repository now deletes the leaver's row on the trip's journal link itself (leaveJournalLink), inside the transaction that removes the member: no edge into journey, no DI, no test stub, and the eight suites the stub touched are back as they were.

The schema inventory tests count the two new tables and their NOT NULL columns, the legacy step map lists the migration as post-legacy, and the TJL scenes give their users numbered names so cases sharing one database do not collide.
2026-10-18 20:02:09 +02:00

28 lines
1.4 KiB
TypeScript

import { JourneyBooks } from '../../src/db/entities/JourneyBooks.entity';
import { JourneyShareTokens } from '../../src/db/entities/JourneyShareTokens.entity';
import type { JourneyBooksRepository } from '../../src/db/repositories/JourneyBooks.repository';
import type { JourneyShareTokensRepository } from '../../src/db/repositories/JourneyShareTokens.repository';
import { sharedTestOrm } from './test-uow';
import type Database from 'better-sqlite3';
/**
* Plan 3g Task 3 (`JourneyShareService`/`JourneyBookService`) test-only
* repository factories, bound to a suite's own better-sqlite3 handle via the
* SAME memoised `sharedTestOrm` (`test-uow.ts`) — same precedent
* `journey-repos.ts` (Task 1) documents for itself.
*
* A NEW file rather than an addition to `journey-repos.ts`: that file is
* Task 1/2's own (`JourneysRepository`/`JourneyContributorsRepository`/
* `JourneyTripsRepository`/`JourneyEntriesRepository`/`JourneyPhotosRepository`/
* `JourneyEntryPhotosRepository`), concurrently in flight when this task ran
* — this file only adds the two share/book-owned tables' factories.
*/
export function createTestJourneyShareTokensRepo(db: Database.Database): Promise<JourneyShareTokensRepository> {
return sharedTestOrm(db).then((t) => t.repo(JourneyShareTokens));
}
export function createTestJourneyBooksRepo(db: Database.Database): Promise<JourneyBooksRepository> {
return sharedTestOrm(db).then((t) => t.repo(JourneyBooks));
}