package plan3test import ( "amadan.net/oficina/equipo/internal/equipo/personapi" "amadan.net/oficina/equipo/internal/wire/wireschema" "encoding/json" "os" "reflect" "strings" "testing" ) func TestNotificationLegacyCardAndContract(t *testing.T) { f := newFixture(t) proposed(t, f) list := apiRequest(t, f, owner, "GET", "/api/v1/conversation/cards", "", "", "") expectHTTP(t, list, 200) page := apiValue[personapi.Page[personapi.Card]](t, list) if len(page.Items) == 0 { t.Fatal("missing legacy fixture") } c := page.Items[0] if strings.HasPrefix(c.ID, "c_") { t.Fatal("legacy id collides with reserved thin prefix", c.ID) } response := apiRequest(t, f, owner, "GET", "/api/v1/cards/"+c.ID, "", "", "") expectHTTP(t, response, 200) got := apiValue[personapi.Card](t, response) if !reflect.DeepEqual(c, got) { t.Fatal("legacy projection changed", c, got) } raw, err := os.ReadFile("../../docs/api/equipo-v1.openapi.json") must(t, err) var doc map[string]any must(t, json.Unmarshal(raw, &doc)) schema := doc["paths"].(map[string]any)["/cards/{id}"].(map[string]any)["get"].(map[string]any)["responses"].(map[string]any)["200"].(map[string]any)["content"].(map[string]any)["application/json"].(map[string]any)["schema"].(map[string]any) schemas := doc["components"].(map[string]any)["schemas"].(map[string]any) must(t, wireschema.Validate(schemas, deviceJSON(t, got), schema, "legacy")) raw, err = os.ReadFile("../../native/apple/Tests/EquipoKitTests/Fixtures/thin/snapshot.json") must(t, err) var snapshot map[string]any must(t, json.Unmarshal(raw, &snapshot)) for _, card := range snapshot["cards"].([]any) { must(t, wireschema.Validate(schemas, card, schema, "thin")) } }