"""Mapping-metadata catalog — authoritative source-field + transform list. The admin mapping builder renders dropdowns from this endpoint so the frontend can never drift from what the renderer actually accepts (the old hard-coded FE transform list silently dropped strip_company_prefix). """ from __future__ import annotations from app.domains.identity_sync.mapping import ( SUPPORTED_SOURCE_FIELDS, SUPPORTED_TRANSFORMS, mapping_metadata, ) def test_metadata_covers_every_supported_field_and_transform(): meta = mapping_metadata() field_names = {f["name"] for f in meta["source_fields"]} transform_names = {x["name"] for x in meta["transforms"]} # The catalog must be a complete projection of the renderer whitelist # — no field the renderer accepts may be missing from the picker. assert field_names == set(SUPPORTED_SOURCE_FIELDS) assert transform_names == set(SUPPORTED_TRANSFORMS) # Every source field carries a category (drives the grouped picker). assert all(f.get("category") for f in meta["source_fields"]) # The historically-dropped transform is present. assert "strip_company_prefix" in transform_names async def test_metadata_endpoint_admin_ok(client, admin_headers): resp = await client.get( "/api/v1/identity-sync/mapping-metadata", headers=admin_headers, ) assert resp.status_code == 200, resp.text data = resp.json()["data"] assert {f["name"] for f in data["source_fields"]} == set(SUPPORTED_SOURCE_FIELDS)