diff --git a/server/scripts/format-baseline.json b/server/scripts/format-baseline.json index 5d102b44e..ce1c30423 100644 --- a/server/scripts/format-baseline.json +++ b/server/scripts/format-baseline.json @@ -1131,6 +1131,7 @@ "tests/unit/db/known-migrations.test.ts", "tests/unit/db/legacy-baseline.test.ts", "tests/unit/db/migrate-encryption-parity.test.ts", + "tests/unit/db/migration.test.ts", "tests/unit/db/nul-safe-sqlite-platform.test.ts", "tests/unit/db/repositories/Addons.repository.test.ts", "tests/unit/db/repositories/AppSettings.repository.test.ts", @@ -1224,6 +1225,7 @@ "tests/unit/db/tour-types-migration.test.ts", "tests/unit/db/tours-migration.test.ts", "tests/unit/db/transaction-yield.test.ts", + "tests/unit/db/trimUserWhitespace.test.ts", "tests/unit/db/trip-access.test.ts", "tests/unit/db/trip-days-backfill-migration.test.ts", "tests/unit/db/trip-files-prefix-migration.test.ts", @@ -1312,6 +1314,7 @@ "tests/unit/nest/atlas-visit-dates.test.ts", "tests/unit/nest/atlas.controller.test.ts", "tests/unit/nest/atlas.service.test.ts", + "tests/unit/nest/atlasBundle.test.ts", "tests/unit/nest/audit-log.logger.test.ts", "tests/unit/nest/audit.service.test.ts", "tests/unit/nest/auth.controller.test.ts", @@ -1325,6 +1328,7 @@ "tests/unit/nest/booking-import/booking-import.service.test.ts", "tests/unit/nest/booking-import/import-jobs.service.test.ts", "tests/unit/nest/booking-import/kitinerary-extractor.service.test.ts", + "tests/unit/nest/booking-import/kitineraryMapper.test.ts", "tests/unit/nest/booking-import/reservation-import.controller.test.ts", "tests/unit/nest/boot-restore.test.ts", "tests/unit/nest/budget.controller.test.ts", @@ -1343,6 +1347,12 @@ "tests/unit/nest/collab.service.test.ts", "tests/unit/nest/collections.controller.test.ts", "tests/unit/nest/collections.service.test.ts", + "tests/unit/nest/common/avatarUrl.test.ts", + "tests/unit/nest/common/conflictUpdate.test.ts", + "tests/unit/nest/common/cookie.test.ts", + "tests/unit/nest/common/crypto/apiKeyCrypto.test.ts", + "tests/unit/nest/common/crypto/mfaCrypto.test.ts", + "tests/unit/nest/common/passwordPolicy.test.ts", "tests/unit/nest/common/request-correlation.test.ts", "tests/unit/nest/common/row-id.test.ts", "tests/unit/nest/common/rowShape.test.ts", @@ -1398,6 +1408,12 @@ "tests/unit/nest/google-transit.provider.test.ts", "tests/unit/nest/idempotency.interceptor.test.ts", "tests/unit/nest/immich.service.test.ts", + "tests/unit/nest/integrations/airtrailImport.test.ts", + "tests/unit/nest/integrations/airtrailMapper.test.ts", + "tests/unit/nest/integrations/airtrailSync.test.ts", + "tests/unit/nest/integrations/airtrailTestConnection.test.ts", + "tests/unit/nest/integrations/airtrailWriteGate.test.ts", + "tests/unit/nest/integrations/airtrailWriteback.test.ts", "tests/unit/nest/journey-book.service.test.ts", "tests/unit/nest/journey-domain.service.test.ts", "tests/unit/nest/journey-photo-capture.service.test.ts", @@ -1485,6 +1501,7 @@ "tests/unit/nest/photo-capture-backfill.service.test.ts", "tests/unit/nest/photo-provider.test.ts", "tests/unit/nest/photo-resolver.service.test.ts", + "tests/unit/nest/photos/trekPhotoMedia.test.ts", "tests/unit/nest/place-enrichment.brand.test.ts", "tests/unit/nest/place-enrichment.controller.test.ts", "tests/unit/nest/place-enrichment.description.test.ts", @@ -1701,23 +1718,6 @@ "tests/unit/scripts/pg-probe/schema.test.ts", "tests/unit/scripts/test-sql-ratchet.test.ts", "tests/unit/scripts/tx-writes.test.ts", - "tests/unit/services/airtrailImport.test.ts", - "tests/unit/services/airtrailMapper.test.ts", - "tests/unit/services/airtrailSync.test.ts", - "tests/unit/services/airtrailTestConnection.test.ts", - "tests/unit/services/airtrailWriteGate.test.ts", - "tests/unit/services/airtrailWriteback.test.ts", - "tests/unit/services/apiKeyCrypto.test.ts", - "tests/unit/services/atlasBundle.test.ts", - "tests/unit/services/avatarUrl.test.ts", - "tests/unit/services/conflictUpdate.test.ts", - "tests/unit/services/cookie.test.ts", - "tests/unit/services/kitineraryMapper.test.ts", - "tests/unit/services/mfaCrypto.test.ts", - "tests/unit/services/migration.test.ts", - "tests/unit/services/passwordPolicy.test.ts", - "tests/unit/services/trekPhotoMedia.test.ts", - "tests/unit/services/trimUserWhitespace.test.ts", "tests/unit/shared-contract.test.ts", "tests/unit/shutdown.test.ts", "tests/unit/systemNotices/conditions.test.ts", diff --git a/server/tests/unit/services/migration.test.ts b/server/tests/unit/db/migration.test.ts similarity index 100% rename from server/tests/unit/services/migration.test.ts rename to server/tests/unit/db/migration.test.ts diff --git a/server/tests/unit/services/trimUserWhitespace.test.ts b/server/tests/unit/db/trimUserWhitespace.test.ts similarity index 100% rename from server/tests/unit/services/trimUserWhitespace.test.ts rename to server/tests/unit/db/trimUserWhitespace.test.ts diff --git a/server/tests/unit/services/atlasBundle.test.ts b/server/tests/unit/nest/atlasBundle.test.ts similarity index 100% rename from server/tests/unit/services/atlasBundle.test.ts rename to server/tests/unit/nest/atlasBundle.test.ts diff --git a/server/tests/unit/services/kitineraryMapper.test.ts b/server/tests/unit/nest/booking-import/kitineraryMapper.test.ts similarity index 98% rename from server/tests/unit/services/kitineraryMapper.test.ts rename to server/tests/unit/nest/booking-import/kitineraryMapper.test.ts index b90516abc..df44c6503 100644 --- a/server/tests/unit/services/kitineraryMapper.test.ts +++ b/server/tests/unit/nest/booking-import/kitineraryMapper.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { mapReservations } from '../../../src/nest/booking-import/kitinerary-mapper'; +import { mapReservations } from '../../../../src/nest/booking-import/kitinerary-mapper'; const airport = (iata: string, lat: number, lng: number) => ({ iataCode: iata, diff --git a/server/tests/unit/services/avatarUrl.test.ts b/server/tests/unit/nest/common/avatarUrl.test.ts similarity index 93% rename from server/tests/unit/services/avatarUrl.test.ts rename to server/tests/unit/nest/common/avatarUrl.test.ts index bdc9b46c6..b131af6d4 100644 --- a/server/tests/unit/services/avatarUrl.test.ts +++ b/server/tests/unit/nest/common/avatarUrl.test.ts @@ -4,7 +4,7 @@ * an OIDC `picture` claim (#1399); the helper resolves both to a renderable src. */ import { describe, it, expect } from 'vitest'; -import { avatarUrl } from '../../../src/nest/common/avatarUrl'; +import { avatarUrl } from '../../../../src/nest/common/avatarUrl'; describe('avatarUrl', () => { it('AVATAR-URL-001: prefixes an uploaded file name with the avatars path', () => { diff --git a/server/tests/unit/services/conflictUpdate.test.ts b/server/tests/unit/nest/common/conflictUpdate.test.ts similarity index 78% rename from server/tests/unit/services/conflictUpdate.test.ts rename to server/tests/unit/nest/common/conflictUpdate.test.ts index 25fa07d96..bd2950162 100644 --- a/server/tests/unit/services/conflictUpdate.test.ts +++ b/server/tests/unit/nest/common/conflictUpdate.test.ts @@ -5,8 +5,8 @@ */ import { describe, it, expect, vi, beforeAll, beforeEach, afterAll } from 'vitest'; -vi.mock('../../../src/db/database', async () => { - const { createSnapshotTestDb } = await import('../../helpers/db-mock'); +vi.mock('../../../../src/db/database', async () => { + const { createSnapshotTestDb } = await import('../../../helpers/db-mock'); const db = createSnapshotTestDb(); return { db, @@ -17,29 +17,29 @@ vi.mock('../../../src/db/database', async () => { }; }); -import { db as testDb } from '../../../src/db/database'; -import { resetTestDb } from '../../helpers/test-db'; -import { findRow } from '../../helpers/factories/rows'; -import { Places } from '../../../src/db/entities/Places.entity'; -import { createUser, createTrip } from '../../helpers/factories'; -import { accommodationsOver } from '../../helpers/accommodations-service'; -import { isUpdateConflict } from '../../../src/nest/common/conflictResult'; -import { PackingService } from '../../../src/nest/packing/packing.service'; -import { PlacesService } from '../../../src/nest/places/places.service'; -import { buildPlaceImportService } from '../../helpers/place-import'; -import { buildMapsService } from '../../helpers/maps-service'; -import { PermissionsService } from '../../../src/nest/permissions/permissions.service'; -import { RealtimeService } from '../../../src/nest/realtime/realtime.service'; -import { QueryHelpersService } from '../../../src/nest/query-helpers/query-helpers.service'; -import { UnsplashService } from '../../../src/nest/unsplash/unsplash.service'; -import { PlacePhotoCacheService } from '../../../src/nest/place-photos/place-photo-cache.service'; -import { JourneyDomainService } from '../../../src/nest/journey/journey-domain.service'; -import { TrekPhotoRegistrationService } from '../../../src/nest/photos/trek-photo-registration.service'; -import { TrekPhotos } from '../../../src/db/entities/TrekPhotos.entity'; -import { TripPhotos } from '../../../src/db/entities/TripPhotos.entity'; -import { RuntimeEnvService } from '../../../src/nest/app-config/runtime-env.service'; -import { notificationsStub } from '../../helpers/notifications'; -import { makeStorageFixture } from '../../helpers/storage-fixture'; +import { db as testDb } from '../../../../src/db/database'; +import { resetTestDb } from '../../../helpers/test-db'; +import { findRow } from '../../../helpers/factories/rows'; +import { Places } from '../../../../src/db/entities/Places.entity'; +import { createUser, createTrip } from '../../../helpers/factories'; +import { accommodationsOver } from '../../../helpers/accommodations-service'; +import { isUpdateConflict } from '../../../../src/nest/common/conflictResult'; +import { PackingService } from '../../../../src/nest/packing/packing.service'; +import { PlacesService } from '../../../../src/nest/places/places.service'; +import { buildPlaceImportService } from '../../../helpers/place-import'; +import { buildMapsService } from '../../../helpers/maps-service'; +import { PermissionsService } from '../../../../src/nest/permissions/permissions.service'; +import { RealtimeService } from '../../../../src/nest/realtime/realtime.service'; +import { QueryHelpersService } from '../../../../src/nest/query-helpers/query-helpers.service'; +import { UnsplashService } from '../../../../src/nest/unsplash/unsplash.service'; +import { PlacePhotoCacheService } from '../../../../src/nest/place-photos/place-photo-cache.service'; +import { JourneyDomainService } from '../../../../src/nest/journey/journey-domain.service'; +import { TrekPhotoRegistrationService } from '../../../../src/nest/photos/trek-photo-registration.service'; +import { TrekPhotos } from '../../../../src/db/entities/TrekPhotos.entity'; +import { TripPhotos } from '../../../../src/db/entities/TripPhotos.entity'; +import { RuntimeEnvService } from '../../../../src/nest/app-config/runtime-env.service'; +import { notificationsStub } from '../../../helpers/notifications'; +import { makeStorageFixture } from '../../../helpers/storage-fixture'; import { createTestUnitOfWork, createTestAppSettingsRepo, @@ -55,13 +55,13 @@ import { createTestCategoriesRepo, createTestTripsRepo, sharedTestOrm, -} from '../../helpers/test-uow'; -import { createTestBudgetItemsRepo } from '../../helpers/files-repos'; -import { createTestCollectionPlacesRepo } from '../../helpers/test-uow'; +} from '../../../helpers/test-uow'; +import { createTestBudgetItemsRepo } from '../../../helpers/files-repos'; +import { createTestCollectionPlacesRepo } from '../../../helpers/test-uow'; import { createTestJourneysRepo, createTestJourneyContributorsRepo, createTestJourneyTripsRepo, createTestJourneyEntriesRepo, createTestJourneyPhotosRepo, createTestJourneyEntryPhotosRepo, -} from '../../helpers/journey-repos'; +} from '../../../helpers/journey-repos'; import { createTestPackingItemsRepo, createTestPackingItemContributorsRepo, @@ -70,8 +70,8 @@ import { createTestPackingTemplatesRepo, createTestPackingTemplateCategoriesRepo, createTestPackingTemplateItemsRepo, -} from '../../helpers/packing-repos'; -import { noGoogleQuota } from '../../helpers/google-quota'; +} from '../../../helpers/packing-repos'; +import { noGoogleQuota } from '../../../helpers/google-quota'; const realtime = new RealtimeService(); const runtimeEnv = new RuntimeEnvService(); diff --git a/server/tests/unit/services/cookie.test.ts b/server/tests/unit/nest/common/cookie.test.ts similarity index 96% rename from server/tests/unit/services/cookie.test.ts rename to server/tests/unit/nest/common/cookie.test.ts index 494f111c7..68b6619df 100644 --- a/server/tests/unit/services/cookie.test.ts +++ b/server/tests/unit/nest/common/cookie.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import { cookieOptions } from '../../../src/nest/common/cookie'; -import { SESSION_DURATION_MS, SESSION_DURATION_REMEMBER_MS } from '../../../src/config'; +import { cookieOptions } from '../../../../src/nest/common/cookie'; +import { SESSION_DURATION_MS, SESSION_DURATION_REMEMBER_MS } from '../../../../src/config'; describe('cookieOptions', () => { afterEach(() => { diff --git a/server/tests/unit/services/apiKeyCrypto.test.ts b/server/tests/unit/nest/common/crypto/apiKeyCrypto.test.ts similarity index 97% rename from server/tests/unit/services/apiKeyCrypto.test.ts rename to server/tests/unit/nest/common/crypto/apiKeyCrypto.test.ts index b27732ca6..c2bfe8e66 100644 --- a/server/tests/unit/services/apiKeyCrypto.test.ts +++ b/server/tests/unit/nest/common/crypto/apiKeyCrypto.test.ts @@ -5,7 +5,7 @@ import { decrypt_api_key, maybe_encrypt_api_key, is_encrypted_api_key, -} from '../../../src/nest/common/crypto/apiKeyCrypto'; +} from '../../../../../src/nest/common/crypto/apiKeyCrypto'; describe('apiKeyCrypto', () => { const PLAINTEXT_KEY = 'my-secret-api-key-12345'; diff --git a/server/tests/unit/services/mfaCrypto.test.ts b/server/tests/unit/nest/common/crypto/mfaCrypto.test.ts similarity index 94% rename from server/tests/unit/services/mfaCrypto.test.ts rename to server/tests/unit/nest/common/crypto/mfaCrypto.test.ts index 74fadaf8e..299604428 100644 --- a/server/tests/unit/services/mfaCrypto.test.ts +++ b/server/tests/unit/nest/common/crypto/mfaCrypto.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect } from 'vitest'; -import { encryptMfaSecret, decryptMfaSecret } from '../../../src/nest/common/crypto/mfaCrypto'; +import { encryptMfaSecret, decryptMfaSecret } from '../../../../../src/nest/common/crypto/mfaCrypto'; describe('mfaCrypto', () => { const TOTP_SECRET = 'JBSWY3DPEHPK3PXP'; // typical base32 TOTP secret diff --git a/server/tests/unit/services/passwordPolicy.test.ts b/server/tests/unit/nest/common/passwordPolicy.test.ts similarity index 98% rename from server/tests/unit/services/passwordPolicy.test.ts rename to server/tests/unit/nest/common/passwordPolicy.test.ts index 6f5eff3f7..0bd84f16e 100644 --- a/server/tests/unit/services/passwordPolicy.test.ts +++ b/server/tests/unit/nest/common/passwordPolicy.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { validatePassword } from '../../../src/nest/common/passwordPolicy'; +import { validatePassword } from '../../../../src/nest/common/passwordPolicy'; describe('validatePassword', () => { // AUTH-006 — Registration with weak password diff --git a/server/tests/unit/services/timezoneService.test.ts b/server/tests/unit/nest/common/timezoneService.test.ts similarity index 88% rename from server/tests/unit/services/timezoneService.test.ts rename to server/tests/unit/nest/common/timezoneService.test.ts index 29a31ef19..ecf470e50 100644 --- a/server/tests/unit/services/timezoneService.test.ts +++ b/server/tests/unit/nest/common/timezoneService.test.ts @@ -1,4 +1,4 @@ -import { localParts, resolveTimeZone } from '../../../src/nest/common/timezoneService'; +import { localParts, resolveTimeZone } from '../../../../src/nest/common/timezoneService'; import { describe, expect, it } from 'vitest'; diff --git a/server/tests/unit/services/airtrailImport.test.ts b/server/tests/unit/nest/integrations/airtrailImport.test.ts similarity index 89% rename from server/tests/unit/services/airtrailImport.test.ts rename to server/tests/unit/nest/integrations/airtrailImport.test.ts index fa797eb42..e21a4a158 100644 --- a/server/tests/unit/services/airtrailImport.test.ts +++ b/server/tests/unit/nest/integrations/airtrailImport.test.ts @@ -8,27 +8,27 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; * doesn't actually chain. */ -import { db } from '../../../src/db/database'; -import { createUser, createTrip } from '../../helpers/factories'; -import type { AirtrailAirport, AirtrailFlightRaw } from '../../../src/nest/integrations/airtrail.client'; -import { AirtrailImportService } from '../../../src/nest/integrations/airtrail-import.service'; -import { PermissionsService } from '../../../src/nest/permissions/permissions.service'; -import { RealtimeService } from '../../../src/nest/realtime/realtime.service'; -import { BudgetService } from '../../../src/nest/budget/budget.service'; -import { ExchangeRatesService } from '../../../src/nest/budget/exchange-rates.service'; -import { ReservationsService } from '../../../src/nest/reservations/reservations.service'; -import { ReservationsReadService } from '../../../src/nest/reservations/reservations-read.service'; -import type { AirtrailClient } from '../../../src/nest/integrations/airtrail.client'; -import type { AirtrailService } from '../../../src/nest/integrations/airtrail.service'; -import { notificationsStub } from '../../helpers/notifications'; -import { accommodationsOver } from '../../helpers/accommodations-service'; -import { createTestUnitOfWork, createTestAppSettingsRepo, createTestReservationsRepo, createTestReservationEndpointsRepo, createTestReservationTravelersRepo, createTestReservationDayPositionsRepo, createTestDayAccommodationsRepo, createTestDaysRepo, createTestPlacesRepo, createTestDayAssignmentsRepo, createTestTripMembersRepo, createTestUsersRepo, createTestTripsRepo, sharedTestOrm } from '../../helpers/test-uow'; -import { createTestBudgetItemsRepo } from '../../helpers/files-repos'; -import { budgetRepoArgs } from '../../helpers/budget-repos'; -import { findRow, findRows } from '../../helpers/factories/rows'; -import { Days } from '../../../src/db/entities/Days.entity'; -import { Reservations } from '../../../src/db/entities/Reservations.entity'; -import { ReservationEndpoints } from '../../../src/db/entities/ReservationEndpoints.entity'; +import { db } from '../../../../src/db/database'; +import { createUser, createTrip } from '../../../helpers/factories'; +import type { AirtrailAirport, AirtrailFlightRaw } from '../../../../src/nest/integrations/airtrail.client'; +import { AirtrailImportService } from '../../../../src/nest/integrations/airtrail-import.service'; +import { PermissionsService } from '../../../../src/nest/permissions/permissions.service'; +import { RealtimeService } from '../../../../src/nest/realtime/realtime.service'; +import { BudgetService } from '../../../../src/nest/budget/budget.service'; +import { ExchangeRatesService } from '../../../../src/nest/budget/exchange-rates.service'; +import { ReservationsService } from '../../../../src/nest/reservations/reservations.service'; +import { ReservationsReadService } from '../../../../src/nest/reservations/reservations-read.service'; +import type { AirtrailClient } from '../../../../src/nest/integrations/airtrail.client'; +import type { AirtrailService } from '../../../../src/nest/integrations/airtrail.service'; +import { notificationsStub } from '../../../helpers/notifications'; +import { accommodationsOver } from '../../../helpers/accommodations-service'; +import { createTestUnitOfWork, createTestAppSettingsRepo, createTestReservationsRepo, createTestReservationEndpointsRepo, createTestReservationTravelersRepo, createTestReservationDayPositionsRepo, createTestDayAccommodationsRepo, createTestDaysRepo, createTestPlacesRepo, createTestDayAssignmentsRepo, createTestTripMembersRepo, createTestUsersRepo, createTestTripsRepo, sharedTestOrm } from '../../../helpers/test-uow'; +import { createTestBudgetItemsRepo } from '../../../helpers/files-repos'; +import { budgetRepoArgs } from '../../../helpers/budget-repos'; +import { findRow, findRows } from '../../../helpers/factories/rows'; +import { Days } from '../../../../src/db/entities/Days.entity'; +import { Reservations } from '../../../../src/db/entities/Reservations.entity'; +import { ReservationEndpoints } from '../../../../src/db/entities/ReservationEndpoints.entity'; // The client and the per-user credentials are the only stubs; the reservation // writes go through the real service against the real test DB, as before. They diff --git a/server/tests/unit/services/airtrailMapper.test.ts b/server/tests/unit/nest/integrations/airtrailMapper.test.ts similarity index 98% rename from server/tests/unit/services/airtrailMapper.test.ts rename to server/tests/unit/nest/integrations/airtrailMapper.test.ts index 689a20367..33ab55e61 100644 --- a/server/tests/unit/services/airtrailMapper.test.ts +++ b/server/tests/unit/nest/integrations/airtrailMapper.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect } from 'vitest'; -import { canonicalHash, mapFlightToReservation, mapFlightsToMultiLegReservation, normalizeFlight } from '../../../src/nest/integrations/airtrail.mapper'; -import type { AirtrailFlightRaw } from '../../../src/nest/integrations/airtrail.client'; +import { canonicalHash, mapFlightToReservation, mapFlightsToMultiLegReservation, normalizeFlight } from '../../../../src/nest/integrations/airtrail.mapper'; +import type { AirtrailFlightRaw } from '../../../../src/nest/integrations/airtrail.client'; function airport(over: Partial = {}): NonNullable { return { diff --git a/server/tests/unit/services/airtrailSync.test.ts b/server/tests/unit/nest/integrations/airtrailSync.test.ts similarity index 98% rename from server/tests/unit/services/airtrailSync.test.ts rename to server/tests/unit/nest/integrations/airtrailSync.test.ts index f1089a6d9..003cbebe3 100644 --- a/server/tests/unit/services/airtrailSync.test.ts +++ b/server/tests/unit/nest/integrations/airtrailSync.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect } from 'vitest'; -import { buildSavePayload } from '../../../src/nest/integrations/airtrail-sync.service'; -import type { AirtrailAirport, AirtrailFlightRaw, AirtrailSavePayload } from '../../../src/nest/integrations/airtrail.client'; +import { buildSavePayload } from '../../../../src/nest/integrations/airtrail-sync.service'; +import type { AirtrailAirport, AirtrailFlightRaw, AirtrailSavePayload } from '../../../../src/nest/integrations/airtrail.client'; /** * buildSavePayload spreads the raw flight, so the body also carries the diff --git a/server/tests/unit/services/airtrailTestConnection.test.ts b/server/tests/unit/nest/integrations/airtrailTestConnection.test.ts similarity index 82% rename from server/tests/unit/services/airtrailTestConnection.test.ts rename to server/tests/unit/nest/integrations/airtrailTestConnection.test.ts index f3f0096f7..b5af0ec9e 100644 --- a/server/tests/unit/services/airtrailTestConnection.test.ts +++ b/server/tests/unit/nest/integrations/airtrailTestConnection.test.ts @@ -1,20 +1,20 @@ import { describe, it, expect, vi, beforeAll, beforeEach, afterAll } from 'vitest'; // Avoid any real DNS/network from the SSRF guard during saveSettings and the probe. -vi.mock('../../../src/utils/ssrfGuard', () => ({ +vi.mock('../../../../src/utils/ssrfGuard', () => ({ checkSsrf: vi.fn(async () => ({ allowed: true, isPrivate: false })), safeFetch: vi.fn(), })); -import { db } from '../../../src/db/database'; -import { createUser } from '../../helpers/factories'; -import { AirtrailService } from '../../../src/nest/integrations/airtrail.service'; -import type { AirtrailClient } from '../../../src/nest/integrations/airtrail.client'; -import { AuditService } from '../../../src/nest/audit/audit.service'; -import { createTestOrm, type TestOrm } from '../../helpers/test-orm'; -import { AuditLog } from '../../../src/db/entities/AuditLog.entity'; -import { Users } from '../../../src/db/entities/Users.entity'; -import { UserAirtrailRepository } from '../../../src/db/repositories/UserAirtrail.repository'; +import { db } from '../../../../src/db/database'; +import { createUser } from '../../../helpers/factories'; +import { AirtrailService } from '../../../../src/nest/integrations/airtrail.service'; +import type { AirtrailClient } from '../../../../src/nest/integrations/airtrail.client'; +import { AuditService } from '../../../../src/nest/audit/audit.service'; +import { createTestOrm, type TestOrm } from '../../../helpers/test-orm'; +import { AuditLog } from '../../../../src/db/entities/AuditLog.entity'; +import { Users } from '../../../../src/db/entities/Users.entity'; +import { UserAirtrailRepository } from '../../../../src/db/repositories/UserAirtrail.repository'; // The probe is the only call that would leave the process, so the client is a // stub; the credential handling around it runs against the real row. diff --git a/server/tests/unit/services/airtrailWriteGate.test.ts b/server/tests/unit/nest/integrations/airtrailWriteGate.test.ts similarity index 88% rename from server/tests/unit/services/airtrailWriteGate.test.ts rename to server/tests/unit/nest/integrations/airtrailWriteGate.test.ts index 79d4ca14d..5ec7cf2de 100644 --- a/server/tests/unit/services/airtrailWriteGate.test.ts +++ b/server/tests/unit/nest/integrations/airtrailWriteGate.test.ts @@ -10,24 +10,24 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'; * the collaborators are visible in the signature instead of resolved by path. * Only the mapper stays a module mock, because it stayed free functions. */ -vi.mock('../../../src/nest/integrations/airtrail.mapper', () => ({ +vi.mock('../../../../src/nest/integrations/airtrail.mapper', () => ({ canonicalHash: vi.fn(() => 'hash'), mapFlightToReservation: vi.fn(() => ({})), entityCode: (e: any) => e?.icao || e?.iata || null, })); -import { AirtrailLinkService } from '../../../src/nest/integrations/airtrail-link.service'; -import { AirtrailAuthError } from '../../../src/nest/integrations/airtrail.client'; -import type { ReservationsRepository } from '../../../src/db/repositories/Reservations.repository'; -import type { ReservationEndpointsRepository } from '../../../src/db/repositories/ReservationEndpoints.repository'; -import type { AppSettingsRepository } from '../../../src/db/repositories/AppSettings.repository'; -import type { RealtimeService } from '../../../src/nest/realtime/realtime.service'; -import type { AddonsService } from '../../../src/nest/addons/addons.service'; -import { AirtrailSyncService } from '../../../src/nest/integrations/airtrail-sync.service'; -import type { ReservationsService } from '../../../src/nest/reservations/reservations.service'; -import type { ReservationsReadService } from '../../../src/nest/reservations/reservations-read.service'; -import type { AirtrailClient } from '../../../src/nest/integrations/airtrail.client'; -import type { AirtrailService } from '../../../src/nest/integrations/airtrail.service'; +import { AirtrailLinkService } from '../../../../src/nest/integrations/airtrail-link.service'; +import { AirtrailAuthError } from '../../../../src/nest/integrations/airtrail.client'; +import type { ReservationsRepository } from '../../../../src/db/repositories/Reservations.repository'; +import type { ReservationEndpointsRepository } from '../../../../src/db/repositories/ReservationEndpoints.repository'; +import type { AppSettingsRepository } from '../../../../src/db/repositories/AppSettings.repository'; +import type { RealtimeService } from '../../../../src/nest/realtime/realtime.service'; +import type { AddonsService } from '../../../../src/nest/addons/addons.service'; +import { AirtrailSyncService } from '../../../../src/nest/integrations/airtrail-sync.service'; +import type { ReservationsService } from '../../../../src/nest/reservations/reservations.service'; +import type { ReservationsReadService } from '../../../../src/nest/reservations/reservations-read.service'; +import type { AirtrailClient } from '../../../../src/nest/integrations/airtrail.client'; +import type { AirtrailService } from '../../../../src/nest/integrations/airtrail.service'; const linkedRow = { id: 5, trip_id: 9, external_id: '42', external_owner_user_id: 7, sync_enabled: 1 }; diff --git a/server/tests/unit/services/airtrailWriteback.test.ts b/server/tests/unit/nest/integrations/airtrailWriteback.test.ts similarity index 87% rename from server/tests/unit/services/airtrailWriteback.test.ts rename to server/tests/unit/nest/integrations/airtrailWriteback.test.ts index cfe8af2aa..062fbf19d 100644 --- a/server/tests/unit/services/airtrailWriteback.test.ts +++ b/server/tests/unit/nest/integrations/airtrailWriteback.test.ts @@ -5,20 +5,20 @@ import { describe, it, expect, vi, beforeAll, afterAll } from 'vitest'; import 'reflect-metadata'; // Avoid any real DNS/network from the SSRF guard during saveSettings. -vi.mock('../../../src/utils/ssrfGuard', () => ({ +vi.mock('../../../../src/utils/ssrfGuard', () => ({ checkSsrf: vi.fn(async () => ({ allowed: true, isPrivate: false })), safeFetch: vi.fn(), })); -import { db } from '../../../src/db/database'; -import { createUser } from '../../helpers/factories'; -import { AirtrailService } from '../../../src/nest/integrations/airtrail.service'; -import { AirtrailClient } from '../../../src/nest/integrations/airtrail.client'; -import { AuditService } from '../../../src/nest/database/../audit/audit.service'; -import { createTestOrm, type TestOrm } from '../../helpers/test-orm'; -import { AuditLog } from '../../../src/db/entities/AuditLog.entity'; -import { Users } from '../../../src/db/entities/Users.entity'; -import { UserAirtrailRepository } from '../../../src/db/repositories/UserAirtrail.repository'; +import { db } from '../../../../src/db/database'; +import { createUser } from '../../../helpers/factories'; +import { AirtrailService } from '../../../../src/nest/integrations/airtrail.service'; +import { AirtrailClient } from '../../../../src/nest/integrations/airtrail.client'; +import { AuditService } from '../../../../src/nest/audit/audit.service'; +import { createTestOrm, type TestOrm } from '../../../helpers/test-orm'; +import { AuditLog } from '../../../../src/db/entities/AuditLog.entity'; +import { Users } from '../../../../src/db/entities/Users.entity'; +import { UserAirtrailRepository } from '../../../../src/db/repositories/UserAirtrail.repository'; // The free functions became methods with the airtrail fold; same SQL, same // behaviour, one instance over the same db handle. diff --git a/server/tests/unit/services/trekPhotoMedia.test.ts b/server/tests/unit/nest/photos/trekPhotoMedia.test.ts similarity index 78% rename from server/tests/unit/services/trekPhotoMedia.test.ts rename to server/tests/unit/nest/photos/trekPhotoMedia.test.ts index 651f20856..3de1c19d5 100644 --- a/server/tests/unit/services/trekPhotoMedia.test.ts +++ b/server/tests/unit/nest/photos/trekPhotoMedia.test.ts @@ -4,22 +4,22 @@ */ import { describe, it, expect, vi, beforeAll, beforeEach, afterAll } from 'vitest'; -vi.mock('../../../src/db/database', async () => { - const { createSnapshotTestDb } = await import('../../helpers/db-mock'); +vi.mock('../../../../src/db/database', async () => { + const { createSnapshotTestDb } = await import('../../../helpers/db-mock'); const db = createSnapshotTestDb(); // FKs off: this suite only checks media_type persistence, not owner/user integrity. db.exec('PRAGMA foreign_keys = OFF'); return { db, closeDb: () => {}, reinitialize: () => {}, getPlaceWithTags: async () => null, canAccessTrip: async () => null, isOwner: async () => false }; }); -import { db as testDb } from '../../../src/db/database'; -import { createUser } from '../../helpers/factories'; -import { TrekPhotoRegistrationService } from '../../../src/nest/photos/trek-photo-registration.service'; -import { TrekPhotos } from '../../../src/db/entities/TrekPhotos.entity'; -import { TripPhotos } from '../../../src/db/entities/TripPhotos.entity'; -import { JourneyPhotos } from '../../../src/db/entities/JourneyPhotos.entity'; -import { createTestOrm, type TestOrm } from '../../helpers/test-orm'; -import { deleteRows } from '../../helpers/factories/rows'; +import { db as testDb } from '../../../../src/db/database'; +import { createUser } from '../../../helpers/factories'; +import { TrekPhotoRegistrationService } from '../../../../src/nest/photos/trek-photo-registration.service'; +import { TrekPhotos } from '../../../../src/db/entities/TrekPhotos.entity'; +import { TripPhotos } from '../../../../src/db/entities/TripPhotos.entity'; +import { JourneyPhotos } from '../../../../src/db/entities/JourneyPhotos.entity'; +import { createTestOrm, type TestOrm } from '../../../helpers/test-orm'; +import { deleteRows } from '../../../helpers/factories/rows'; // Was photos.bridge, deleted with the other three that had no consumer outside // the container. These call the repository directly now.