Clean up dead code, dedupe helpers, fix the reset-password contract

- Remove server exports orphaned by the Express removal: the immich
  album-link helpers, seven route-only service exports, getFileByIdFull;
  de-export internal-only helpers (utcSuffix).
- De-duplicate verifyTripAccess (9 identical copies -> services/tripAccess.ts)
  and avatarUrl (3 -> services/avatarUrl.ts); name the bcrypt cost
  (BCRYPT_COST) and the email regex (EMAIL_REGEX). Public API unchanged.
- resetPasswordRequestSchema declared `password`, but the client sends and
  the service reads `new_password` — rename it so the contract matches and
  the client types resolve.
- Make ATLAS-013 deterministic: stub the admin-1 GeoJSON download instead of
  fetching ~4600 features from GitHub during the test (it hung the suite).
This commit is contained in:
Maurice
2026-05-31 14:13:04 +02:00
parent 4c9631998f
commit 4cb4454d9f
24 changed files with 94 additions and 145 deletions
+22
View File
@@ -51,6 +51,27 @@ let nestApp: INestApplication;
let app: Application;
beforeAll(async () => {
// Stub the admin-1 GeoJSON download so /regions/geo is deterministic and never
// hits the real network (the un-stubbed fetch of a ~4600-feature file from
// raw.githubusercontent.com is what made ATLAS-013 hang/time out under load).
// Any other outbound fetch (e.g. background reverse-geocoding) returns empty so
// no test depends on live network.
vi.stubGlobal('fetch', async (url: unknown) => {
if (String(url).includes('natural-earth-vector')) {
return new Response(
JSON.stringify({
type: 'FeatureCollection',
features: [
{ type: 'Feature', properties: { iso_a2: 'DE' }, geometry: { type: 'Point', coordinates: [10, 51] } },
{ type: 'Feature', properties: { iso_a2: 'FR' }, geometry: { type: 'Point', coordinates: [2, 47] } },
],
}),
{ status: 200, headers: { 'Content-Type': 'application/json' } },
);
}
return new Response('{}', { status: 200, headers: { 'Content-Type': 'application/json' } });
});
createTables(testDb);
runMigrations(testDb);
nestApp = await buildApp();
@@ -63,6 +84,7 @@ beforeEach(() => {
});
afterAll(async () => {
vi.unstubAllGlobals();
await nestApp.close();
testDb.close();
});