diff --git a/services/driver-service/src/services/admin-drivers.service.spec.ts b/services/driver-service/src/services/admin-drivers.service.spec.ts index dda883f..0c4c047 100644 --- a/services/driver-service/src/services/admin-drivers.service.spec.ts +++ b/services/driver-service/src/services/admin-drivers.service.spec.ts @@ -38,6 +38,30 @@ describe('AdminDriversService (#214)', () => { expect(result.items[0]).not.toHaveProperty('nationalIdHash'); }); + it('passes the status and verificationStatus filters straight through to the repository', async () => { + const { service, drivers, lookups } = setup(); + drivers.findForAdmin.mockResolvedValue([[], 0]); + lookups.names.mockResolvedValue(new Map()); + + await service.list(listQuery({ status: 'OFFLINE' as never, verificationStatus: 'PENDING' as never })); + + expect(drivers.findForAdmin).toHaveBeenCalledWith(expect.objectContaining({ status: 'OFFLINE', verificationStatus: 'PENDING' }), 1, 20); + }); + + it('never exposes secret fields: the staff driver row has a fixed shape', async () => { + const { service, drivers, lookups } = setup(); + drivers.findForAdmin.mockResolvedValue([[driver('d1', 'u1')], 1]); + lookups.names.mockResolvedValue(new Map()); + + const row = (await service.list(listQuery())).items[0]; + + expect(Object.keys(row).sort()).toEqual( + ['createdAt', 'drivingLicenceExpiresOn', 'fullName', 'id', 'licensePlate', 'status', 'submittedAt', 'userId', 'vehicleLicenceExpiresOn', 'vehicleType', 'verificationStatus', 'verifiedAt'].sort(), + ); + expect(row).not.toHaveProperty('nationalIdHash'); + expect(JSON.stringify(row)).not.toContain('secret-hash'); + }); + it('shows names as null, never made up, when user-service does not answer', async () => { const { service, drivers, lookups } = setup(); drivers.findForAdmin.mockResolvedValue([[driver('d1', 'u1')], 1]); diff --git a/services/restaurant-service/src/services/admin-restaurants.service.spec.ts b/services/restaurant-service/src/services/admin-restaurants.service.spec.ts index a923b6f..8763884 100644 --- a/services/restaurant-service/src/services/admin-restaurants.service.spec.ts +++ b/services/restaurant-service/src/services/admin-restaurants.service.spec.ts @@ -50,6 +50,35 @@ describe('AdminRestaurantsService (#214)', () => { expect(result.items[0]).not.toHaveProperty('taxCardNumber'); }); + it('passes the approvalStatus and status filters straight through, and no area when it is partial', async () => { + const { service, restaurants, lookups } = setup(); + restaurants.findForAdmin.mockResolvedValue([[], 0]); + lookups.names.mockResolvedValue(new Map()); + + await service.list(Object.assign(new AdminListRestaurantsQueryDto(), { approvalStatus: 'SUBMITTED' as never, status: 'OPEN' as never, nearLat: 30 })); + + expect(restaurants.findForAdmin).toHaveBeenCalledWith( + expect.objectContaining({ approvalStatus: 'SUBMITTED', status: 'OPEN', near: undefined }), + 1, + 20, + ); + }); + + it('never exposes secret fields: the staff restaurant row has a fixed shape', async () => { + const { service, restaurants, lookups } = setup(); + restaurants.findForAdmin.mockResolvedValue([[restaurant('r1', 'o1')], 1]); + lookups.names.mockResolvedValue(new Map()); + + const row = (await service.list(Object.assign(new AdminListRestaurantsQueryDto()))).items[0]; + + expect(Object.keys(row).sort()).toEqual( + ['address', 'approvalStatus', 'approvedAt', 'contactPhone', 'createdAt', 'deliveryRadiusKm', 'id', 'latitude', 'longitude', 'name', 'ownerId', 'ownerName', 'status', 'submittedAt'].sort(), + ); + expect(row).not.toHaveProperty('taxCardNumber'); + expect(row).not.toHaveProperty('commercialRegistrationNumber'); + expect(JSON.stringify(row)).not.toContain('123'); + }); + it('searches by the exact phone', async () => { const { service, restaurants, lookups } = setup(); restaurants.findByContactPhone.mockResolvedValue([restaurant('r1', 'o1')]);