Files
carmanagement/apps/api/src/tests/integration/public-validation-boundaries.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

41 lines
1.4 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { parseBody, parseQuery } from '../../http/validate'
import { carplaceReservationSchema, paginationSchema } from '../../modules/carplace/carplace.schemas'
import { paySchema } from '../../modules/site/site.schemas'
function reqWith(body: unknown, query: unknown = {}) {
return { body, query, params: {} } as any
}
describe('public validation boundaries', () => {
it('keeps carplace pagination coercion consistent with route parsing', () => {
expect(parseQuery(paginationSchema, reqWith({}, { page: '4', pageSize: '25' }))).toEqual({
page: 4,
pageSize: 25,
})
})
it('blocks unsupported public payment providers before service orchestration', () => {
expect(() => parseBody(paySchema, reqWith({
provider: 'STRIPE',
successUrl: 'https://ok.example.test',
failureUrl: 'https://fail.example.test',
accessToken: 'booking-access-token-123',
}))).toThrow('Invalid enum value')
})
it('requires enough anonymous carplace reservation identity to create a booking request', () => {
const parsed = parseBody(carplaceReservationSchema, reqWith({
vehicleId: 'ckvvehicle000000000000001',
companySlug: 'atlas-cars',
firstName: 'Aya',
lastName: 'Benali',
email: 'aya@example.com',
startDate: '2026-07-01T10:00:00.000Z',
endDate: '2026-07-03T10:00:00.000Z',
}))
expect(parsed.language).toBe('fr')
})
})