feat(platform): add lightweight vehicle overview api

This commit is contained in:
lingniu
2026-07-04 02:52:56 +08:00
parent 38e1bf422a
commit 6c745bf48b
5 changed files with 111 additions and 0 deletions

View File

@@ -204,6 +204,31 @@ func TestHandlerVehicleServiceIncludesUnifiedOverview(t *testing.T) {
}
}
func TestHandlerVehicleServiceOverviewEndpoint(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
rec := httptest.NewRecorder()
req := httptest.NewRequest(http.MethodGet, "/api/vehicle-service/overview?keyword=粤AG18312", nil)
handler.ServeHTTP(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("status = %d body=%s", rec.Code, rec.Body.String())
}
var body struct {
Data VehicleServiceOverview `json:"data"`
}
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
t.Fatalf("response JSON should decode: %v body=%s", err, rec.Body.String())
}
if body.Data.VIN != "LB9A32A24R0LS1426" || body.Data.Plate != "粤AG18312" {
t.Fatalf("overview endpoint should resolve canonical vehicle identity, got %+v", body.Data)
}
if body.Data.SourceCount != 2 || body.Data.OnlineSourceCount != 1 || body.Data.CoverageStatus != "partial" {
t.Fatalf("overview endpoint should summarize vehicle service coverage, got %+v", body.Data)
}
if strings.Contains(rec.Body.String(), `"raw"`) || strings.Contains(rec.Body.String(), `"history"`) {
t.Fatalf("overview endpoint should not return heavy detail pages: %s", rec.Body.String())
}
}
func TestHandlerVehicleDetailResolvesPlateToVIN(t *testing.T) {
handler := NewHandler(NewService(NewMockStore()))
rec := httptest.NewRecorder()