mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 17:03:15 +00:00
Delete four bridges with no consumer, and gate what runs outside the container
Both were left open by the audit and are closed here. days, packing, photos and reservations each built a service outside the container at module load for nobody: only their own delegation tests imported them, and three domain docblocks were still telling readers to go through them. photos.bridge's own comment pointed at src/services/, a directory deleted two PRs ago. The cases that exercised them kept their assertions and call the service the bridge delegated to, so nothing that was proved stopped being proved. Twelve bridges remain, each with a live out-of-container caller. Coverage measured src/** but gated only src/nest/**, so the boot path, the scheduler, the MCP handler and the migrations sat under no floor at all. That is the same 9,602 lines where this audit found its worst defect, and a swallowed EADDRINUSE is exactly the kind of thing an untested boot path hides. Seven globs now pin what is measured today. They are floors to raise, not targets that have been met: src/*.ts is at 39% statements and src/db at 38% branches, and writing those numbers down is the point. src/demo/** is deliberately left out. It measures 0%, and a floor of zero asserts nothing; it needs tests before it needs a threshold.
This commit is contained in:
@@ -56,7 +56,10 @@ import { createUser, createTrip, createDay, createPlace, createDayAssignment, cr
|
||||
import { DatabaseService } from '../../../src/nest/database/database.service';
|
||||
import { PermissionsService } from '../../../src/nest/permissions/permissions.service';
|
||||
import { DaysService, DayReorderError, addDays } from '../../../src/nest/days/days.service';
|
||||
import { getDay as bridgeGetDay, listDays as bridgeListDays } from '../../../src/nest/days/days.bridge';
|
||||
// Was days.bridge, deleted with the other three that had no consumer outside the
|
||||
// container. The assertions stayed; they point at the service now.
|
||||
const bridgeGetDay = (id: string | number, tripId: string | number) => svc.getDay(id, tripId);
|
||||
const bridgeListDays = (tripId: string | number) => svc.list(tripId);
|
||||
import { RealtimeService } from '../../../src/nest/realtime/realtime.service';
|
||||
import { QueryHelpersService } from '../../../src/nest/query-helpers/query-helpers.service';
|
||||
import { AccommodationsService } from '../../../src/nest/accommodations/accommodations.service';
|
||||
@@ -252,7 +255,7 @@ describe('remove', () => {
|
||||
// consumer (legacy tripService) folded into the DI-native TripsService —
|
||||
// 029/031/032 pin the same behavior on the service.
|
||||
|
||||
describe('days.bridge', () => {
|
||||
describe('DaysService — the surface the deleted bridge exposed', () => {
|
||||
it('DAY-SVC-027 — getDay delegates to DaysService.getDay', () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id);
|
||||
|
||||
@@ -63,7 +63,9 @@ import { createUser, createAdmin, createTrip, addTripMember } from '../../helper
|
||||
import { DatabaseService } from '../../../src/nest/database/database.service';
|
||||
import type { PermissionsService } from '../../../src/nest/permissions/permissions.service';
|
||||
import { PackingService } from '../../../src/nest/packing/packing.service';
|
||||
import { listItems as bridgeListItems } from '../../../src/nest/packing/packing.bridge';
|
||||
// Was packing.bridge, deleted with the other three that had no consumer outside the
|
||||
// container. The assertions stayed; they point at the service now.
|
||||
const bridgeListItems = (tripId: string | number, viewerId?: number) => svc.listItems(tripId, viewerId);
|
||||
import { RealtimeService } from '../../../src/nest/realtime/realtime.service';
|
||||
import { notificationsStub } from '../../helpers/notifications';
|
||||
|
||||
@@ -773,7 +775,7 @@ describe('notifyTagged', () => {
|
||||
|
||||
// ── Bridge delegation ─────────────────────────────────────────────────────────
|
||||
|
||||
describe('packing.bridge', () => {
|
||||
describe('PackingService — the surface the deleted bridge exposed', () => {
|
||||
it('PACK-SVC-050: listItems delegates to PackingService over the shared db Proxy', () => {
|
||||
const { user: owner } = createUser(testDb);
|
||||
const { user: other } = createUser(testDb);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Unit tests for the DI-native ReservationsService — RESV-SVC-001+ (real-SQL
|
||||
* cases over the folded legacy services/reservationService.ts statements),
|
||||
* RES-TRAV-001..005 (moved 1:1 from tests/unit/services/reservationTravelers.test.ts)
|
||||
* and RESV-BRIDGE-001..009 (one delegation case per reservations.bridge export).
|
||||
* and RESV-BRIDGE-001..009, which kept their assertions when the bridge went.
|
||||
* Uses a real in-memory SQLite DB so the SQL logic — falsy-coercion defaults,
|
||||
* COALESCE update semantics, day derivation, the accommodation/budget cascades
|
||||
* and the TEXT accommodation_id normalization — is exercised faithfully.
|
||||
@@ -57,7 +57,26 @@ import { DatabaseService } from '../../../src/nest/database/database.service';
|
||||
import type { PermissionsService } from '../../../src/nest/permissions/permissions.service';
|
||||
import { ReservationsService } from '../../../src/nest/reservations/reservations.service';
|
||||
import type { BudgetService } from '../../../src/nest/budget/budget.service';
|
||||
import * as bridge from '../../../src/nest/reservations/reservations.bridge';
|
||||
// Was reservations.bridge, deleted along with the other three that had no
|
||||
// consumer outside the container. The cases below kept their assertions and
|
||||
// point at the service the bridge delegated to; only the delegation itself is
|
||||
// gone, and there was nothing left to delegate for.
|
||||
const bridge = {
|
||||
listReservations: (tripId: string | number) => svc.list(tripId),
|
||||
loadEndpointsByTrip: (tripId: string | number) => svc.loadEndpointsByTrip(tripId),
|
||||
resyncReservationDays: (tripId: string | number) => svc.resyncReservationDays(tripId),
|
||||
createReservation: (tripId: string | number, data: Parameters<ReservationsService['create']>[1]) => svc.create(tripId, data),
|
||||
getReservation: (id: string | number, tripId: string | number) => svc.getReservation(id, tripId),
|
||||
getReservationWithJoins: (id: string | number) => svc.getReservationWithJoins(id),
|
||||
updateReservation: (
|
||||
id: string | number,
|
||||
tripId: string | number,
|
||||
data: Parameters<ReservationsService['update']>[2],
|
||||
current: Parameters<ReservationsService['update']>[3],
|
||||
) => svc.update(id, tripId, data, current),
|
||||
deleteReservation: (id: string | number, tripId: string | number) => svc.remove(id, tripId),
|
||||
notifyBookingChange: (...a: Parameters<ReservationsService['notifyBookingChange']>) => svc.notifyBookingChange(...a),
|
||||
};
|
||||
import { RealtimeService } from '../../../src/nest/realtime/realtime.service';
|
||||
import { notificationsStub } from '../../helpers/notifications';
|
||||
|
||||
@@ -513,7 +532,7 @@ describe('setReservationTravelers / loadTravelers (#1517)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('reservations.bridge (legacy-named delegation for outside-container consumers)', () => {
|
||||
describe('ReservationsService — the surface the deleted bridge exposed', () => {
|
||||
it('RESV-BRIDGE-001: listReservations delegates to ReservationsService.list', () => {
|
||||
const { trip } = ownerTrip();
|
||||
createReservation(testDb, trip.id, { title: 'A' });
|
||||
|
||||
@@ -23,7 +23,16 @@ vi.mock('../../../src/config', () => ({
|
||||
import { createTables } from '../../../src/db/schema';
|
||||
import { runMigrations } from '../../../src/db/migrations';
|
||||
import { createUser } from '../../helpers/factories';
|
||||
import { getOrCreateLocalTrekPhoto, getOrCreateTrekPhoto, resolveTrekPhoto } from '../../../src/nest/photos/photos.bridge';
|
||||
import { TrekPhotosRepository } from '../../../src/nest/photos/trek-photos.repository';
|
||||
import { DatabaseService } from '../../../src/nest/database/database.service';
|
||||
import { db as trekDb } from '../../../src/db/database';
|
||||
|
||||
// Was photos.bridge, deleted with the other three that had no consumer outside
|
||||
// the container. These call the repository directly now.
|
||||
const trekPhotos = new TrekPhotosRepository(new DatabaseService(trekDb));
|
||||
const getOrCreateTrekPhoto = (...a: Parameters<TrekPhotosRepository['getOrCreate']>) => trekPhotos.getOrCreate(...a);
|
||||
const getOrCreateLocalTrekPhoto = (...a: Parameters<TrekPhotosRepository['getOrCreateLocal']>) => trekPhotos.getOrCreateLocal(...a);
|
||||
const resolveTrekPhoto = (id: number) => trekPhotos.resolve(id);
|
||||
|
||||
beforeAll(() => {
|
||||
createTables(testDb);
|
||||
|
||||
Reference in New Issue
Block a user