fix search feature
Build & Push / Pipeline Tests (push) Failing after 1m14s
Build & Push / Build & Push Docker Image (push) Has been skipped
Test / Type Check (all packages) (push) Successful in 53s
Test / API Unit Tests (push) Failing after 50s
Test / Homepage Unit Tests (push) Successful in 45s
Test / Carplace Unit Tests (push) Successful in 44s
Test / Admin Unit Tests (push) Successful in 42s
Test / Dashboard Unit Tests (push) Successful in 43s
Test / API Integration Tests (push) Successful in 1m4s
Build & Push / Pipeline Tests (push) Failing after 1m14s
Build & Push / Build & Push Docker Image (push) Has been skipped
Test / Type Check (all packages) (push) Successful in 53s
Test / API Unit Tests (push) Failing after 50s
Test / Homepage Unit Tests (push) Successful in 45s
Test / Carplace Unit Tests (push) Successful in 44s
Test / Admin Unit Tests (push) Successful in 42s
Test / Dashboard Unit Tests (push) Successful in 43s
Test / API Integration Tests (push) Successful in 1m4s
This commit is contained in:
@@ -74,7 +74,7 @@ import * as additionalDriverService from './reservation.additional-driver.servic
|
||||
import { validateLicense } from '../../services/licenseValidationService'
|
||||
import { sendNotification } from '../../services/notificationService'
|
||||
import { buildReservationWorkflow } from './reservation.presenter'
|
||||
import { createReservation } from './reservation.service'
|
||||
import { createReservation, listReservations } from './reservation.service'
|
||||
import { confirmReservation, checkinReservation, checkoutReservation, closeReservation } from './reservation.lifecycle.service'
|
||||
import { approveAdditionalDriver } from './reservation.additional-driver.service'
|
||||
|
||||
@@ -112,6 +112,47 @@ beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────
|
||||
describe('listReservations', () => {
|
||||
it('passes search across vehicle, customer, contract, status and source fields', async () => {
|
||||
vi.mocked(repo.findMany).mockResolvedValue([[makeReservation({ vehicle: { make: 'Citroen', model: 'C4' } })], 1] as any)
|
||||
|
||||
await expect(listReservations(COMPANY, { search: 'c4', pageSize: 100 })).resolves.toMatchObject({
|
||||
total: 1,
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
})
|
||||
|
||||
expect(repo.findMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
companyId: COMPANY,
|
||||
OR: expect.arrayContaining([
|
||||
{ vehicle: { is: { model: { contains: 'c4', mode: 'insensitive' } } } },
|
||||
{ vehicle: { is: { make: { contains: 'c4', mode: 'insensitive' } } } },
|
||||
{ customer: { is: { email: { contains: 'c4', mode: 'insensitive' } } } },
|
||||
{ contractNumber: { contains: 'c4', mode: 'insensitive' } },
|
||||
]),
|
||||
}),
|
||||
0,
|
||||
100,
|
||||
)
|
||||
})
|
||||
|
||||
it('adds exact enum filters for status and source search terms', async () => {
|
||||
vi.mocked(repo.findMany).mockResolvedValue([[], 0] as any)
|
||||
|
||||
await listReservations(COMPANY, { search: 'public site' })
|
||||
|
||||
expect(repo.findMany).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
OR: expect.arrayContaining([{ source: 'PUBLIC_SITE' }]),
|
||||
}),
|
||||
0,
|
||||
20,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────
|
||||
describe('createReservation', () => {
|
||||
it('creates a reservation and returns it', async () => {
|
||||
|
||||
Reference in New Issue
Block a user