Files
carmanagement/apps/api/src/modules/reservations/reservation.presenter.test.ts
T
root 7ff2dbb139
Build & Deploy / Build & Push Docker Image (push) Successful in 2m55s
Test / Type Check (all packages) (push) Successful in 54s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Failing after 48s
Test / Homepage Unit Tests (push) Successful in 43s
Test / Storefront Unit Tests (push) Failing after 40s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Failing after 42s
Test / API Integration Tests (push) Successful in 1m0s
chore: wire Carplace into dev and production stacks
2026-07-02 18:15:42 -04:00

40 lines
1.4 KiB
TypeScript

import { afterAll, beforeEach, describe, expect, it } from 'vitest'
import { serializeReservationForDashboard } from './reservation.presenter'
describe('serializeReservationForDashboard', () => {
const originalDashboardUrl = process.env.DASHBOARD_URL
const originalPublicDashboardUrl = process.env.NEXT_PUBLIC_DASHBOARD_URL
beforeEach(() => {
process.env.DASHBOARD_URL = 'http://localhost:3000/dashboard'
process.env.NEXT_PUBLIC_DASHBOARD_URL = ''
})
afterAll(() => {
process.env.DASHBOARD_URL = originalDashboardUrl
process.env.NEXT_PUBLIC_DASHBOARD_URL = originalPublicDashboardUrl
})
it('rewrites customer license image URLs to the protected route', () => {
const result = serializeReservationForDashboard({
id: 'reservation-1',
status: 'CONFIRMED',
source: 'CARPLACE',
contractNumber: null,
invoiceNumber: null,
paymentStatus: 'UNPAID',
extras: {},
customer: {
id: 'customer-1',
driverLicense: 'DL-1',
dateOfBirth: new Date('1990-01-01T00:00:00.000Z'),
address: { identityDocumentNumber: 'CIN-1', fullAddress: 'Casablanca' },
licenseImageUrl: 'http://localhost:4000/storage/companies/company-1/customers/customer-1/license.jpg',
licenseValidationStatus: 'APPROVED',
},
})
expect(result.customer?.licenseImageUrl).toBe('http://localhost:3000/dashboard/api/v1/customers/customer-1/license-image')
})
})