fix(appointments): include destination timezone in batch preview

This commit is contained in:
2026-10-10 18:37:38 +08:00
parent c6471d06ff
commit 15ab355dc2
3 changed files with 16 additions and 3 deletions
@@ -15,12 +15,14 @@ class AppointmentBatchPreviewServiceTest {
var refs=List.of(new AppointmentCoverageService.SourceRef("A","ORDER:1","FBA:ONT8"),new AppointmentCoverageService.SourceRef("B","BOOKING:B-1","FBA:ONT8"));
when(sources.resolveBatch(refs)).thenReturn(List.of(source("ORDER:1","A",1L,"100","FBA:ONT8"),source("BOOKING:B-1","B",null,"100","FBA:ONT8")));
when(mapper.flags(List.of(1L))).thenReturn(List.of(new AppointmentBatchPreviewMapper.Flags(1L,false,false,false)));
when(sources.destinationTimezone("ONT8")).thenReturn("America/Los_Angeles");
var preview=new AppointmentBatchPreviewService(sources,mapper).preview(refs);
assertEquals("America/Los_Angeles",preview.destinationTimezone());
assertEquals(2,preview.group().customerCount());assertEquals(20,preview.group().packages());
assertTrue(preview.group().readinessIncomplete());assertNull(preview.group().readyFrom());
assertEquals(List.of("READY_WINDOW_UNVERIFIED"),preview.missingFields());
assertNull(preview.sources().get(1).orderId());
verify(sources).resolveBatch(refs);verify(mapper).flags(List.of(1L));verifyNoMoreInteractions(sources,mapper);
verify(sources).resolveBatch(refs);verify(mapper).flags(List.of(1L));verify(sources).destinationTimezone("ONT8");verifyNoMoreInteractions(sources,mapper);
}
@Test void missingRowsDetentionMixedDestinationsAndPriorAppointmentsBlockGrouping() {
var sources=mock(AppointmentSourceService.class);var mapper=mock(AppointmentBatchPreviewMapper.class);
@@ -40,4 +42,13 @@ class AppointmentBatchPreviewServiceTest {
assertThrows(ResponseStatusException.class,()->new AppointmentBatchPreviewService(sources,mapper).preview(refs));
verifyNoInteractions(mapper);
}
@Test void absentTimezoneStaysUnknownAndLookupFailureIsNotMasked() {
var sources=mock(AppointmentSourceService.class);var mapper=mock(AppointmentBatchPreviewMapper.class);
var refs=List.of(new AppointmentCoverageService.SourceRef("A","BOOKING:A","FBA:ONT8"));
when(sources.resolveBatch(refs)).thenReturn(List.of(source("BOOKING:A","A",null,"100","FBA:ONT8")));
var service=new AppointmentBatchPreviewService(sources,mapper);
assertNull(service.preview(refs).destinationTimezone());
when(sources.destinationTimezone("ONT8")).thenThrow(new ResponseStatusException(org.springframework.http.HttpStatus.SERVICE_UNAVAILABLE,"lookup failed"));
assertEquals(503,assertThrows(ResponseStatusException.class,()->service.preview(refs)).getStatusCode().value());
}
}