fix(ci): presence through the sessions domain, warm bags taken once, a slimmer planner page

Server lint: the realtime gateway injected the user_sessions repository, a table the sessions domain owns; it now asks SessionsService. The presence tests reuse the handshake's gateway instead of building one more by hand (test-new-service ratchet).

Client tests: the packing bags kept per trip leaked from one test (and one list) into the next; bags read ahead are now taken once as the list's first state, and only while bag tracking is on. The planner hook hands the page planMapKept, tourMapKept and the tour stage's class, so page tests that mock the hook keep working and TripPlannerPage is back at its size baseline (1127); the B4A wiring test reads the new condition.

Client lint: max-depth in src is down to 19, the baseline follows; the new websocket tests call onopen with ?. instead of a non-null assertion.
This commit is contained in:
Maurice
2026-11-29 10:13:53 +01:00
parent 5401728c41
commit 10ad92574d
9 changed files with 45 additions and 42 deletions
@@ -1,10 +1,10 @@
import { AppSettings } from '../../db/entities/AppSettings.entity';
import { Trips } from '../../db/entities/Trips.entity';
import { UserSessions } from '../../db/entities/UserSessions.entity';
import { Users } from '../../db/entities/Users.entity';
import { EphemeralTokenModule } from '../auth-core/ephemeral-token.module';
import { DatabaseLifecycleModule } from '../database/database-lifecycle.module';
import { DatabaseLifecycle } from '../database/database-lifecycle.service';
import { SessionsModule } from '../sessions/sessions.module';
import { TripMembershipModule } from '../trip-membership/trip-membership.module';
import { RealtimeGateway } from './realtime.gateway';
import { closeSockets, processRooms, RoomRegistry, roomsSlot } from './ws-state';
@@ -36,7 +36,8 @@ import { Module, type OnModuleDestroy } from '@nestjs/common';
TripMembershipModule,
EphemeralTokenModule,
DatabaseLifecycleModule,
MikroOrmModule.forFeature([Users, AppSettings, Trips, UserSessions]),
SessionsModule,
MikroOrmModule.forFeature([Users, AppSettings, Trips]),
],
// The room registry is the process-wide in-memory one; the constructor
// below hands whichever one the container resolved to the broadcast
+4 -4
View File
@@ -1,9 +1,7 @@
import { runningVersion } from '../../app-config';
import { AppSettings } from '../../db/entities/AppSettings.entity';
import { UserSessions } from '../../db/entities/UserSessions.entity';
import { Users } from '../../db/entities/Users.entity';
import type { AppSettingsRepository } from '../../db/repositories/AppSettings.repository';
import type { UserSessionsRepository } from '../../db/repositories/UserSessions.repository';
import type { UsersRepository } from '../../db/repositories/Users.repository';
import { dbNow } from '../../db/types/db-timestamp.type';
import { User } from '../../types';
@@ -12,6 +10,7 @@ import { EphemeralTokenService } from '../auth-core/ephemeral-token.service';
import { SESSION_TOUCH_INTERVAL_MS } from '../auth-core/jwt-verify';
import { readAppSetting } from '../common/app-settings.registry';
import { toRowId } from '../common/row-id';
import { SessionsService } from '../sessions/sessions.service';
import { TripAccessService } from '../trip-membership/trip-access.service';
import { JOURNEY_ACCESS, type JourneyAccess } from './journey-access.types';
import {
@@ -87,8 +86,9 @@ export class RealtimeGateway implements OnGatewayInit, OnGatewayConnection, OnGa
@Inject(JOURNEY_ACCESS) private readonly journeys: JourneyAccess,
@InjectRepository(Users) private readonly users: UsersRepository,
@InjectRepository(AppSettings) private readonly appSettings: AppSettingsRepository,
// A tab in front keeps its session's last activity current (presence below).
@InjectRepository(UserSessions) private readonly sessions: UserSessionsRepository,
// A tab in front keeps its session's last activity current (presence below),
// written through the sessions domain that owns the table.
private readonly sessions: SessionsService,
// Room membership, behind its port. The container's provider, which
// RealtimeGatewayModule also installs for the broadcast functions in
// ws-state.ts; a hand-built gateway takes the installed one.