diff --git a/frontend/components/layout/nav-items.test.ts b/frontend/components/layout/nav-items.test.ts index 6e5da1f..6e46274 100644 --- a/frontend/components/layout/nav-items.test.ts +++ b/frontend/components/layout/nav-items.test.ts @@ -122,12 +122,12 @@ test("artifact-narrowed capabilities hide pages the release does not serve", () expect(groups[0].items.map((item) => item.href)).toEqual(["/microcosm"]); }); -test("shows Cross-dataset navigation for every selectable country", () => { +test("shows Cross-dataset navigation only for countries with that capability", () => { for (const country of selectableCountries()) { expect( navGroupsForCountry(country) .flatMap((group) => group.items) .some((item) => item.href === "/microcosm/datasets"), - ).toBe(true); + ).toBe(hasCapability(country, "cross_dataset")); } }); diff --git a/frontend/lib/microcosm/countries.test.ts b/frontend/lib/microcosm/countries.test.ts index b1a21e7..59c0ef7 100644 --- a/frontend/lib/microcosm/countries.test.ts +++ b/frontend/lib/microcosm/countries.test.ts @@ -66,10 +66,20 @@ test("keeps the live registrations on their published repositories and labels", geography: "Belgium", visibility: "private", }); + expect(countryRegistration("nz")).toMatchObject({ + repo: "policyengine/populace-nz", + repo_env: "POPULACE_NZ_HF_REPO", + revision_env: "POPULACE_NZ_HF_REVISION", + label: "New Zealand", + dataset_label: "Microcosm NZ", + geography: "New Zealand", + geography_id: null, + visibility: "public", + }); }); test("selectable countries follow registry order and exclude fixtures", () => { - expect(selectableCountries()).toEqual(["us", "uk", "be"]); + expect(selectableCountries()).toEqual(["us", "uk", "be", "nz"]); expect(countryRegistration("zz").fixture).toBe(true); expect(selectableCountries()).not.toContain("zz"); }); @@ -82,6 +92,7 @@ test("fixture registrations are valid countries without being selectable", () => test("country parsing is exact and defaults to the registry default", () => { expect(DEFAULT_COUNTRY).toBe("us"); expect(parseCountry("be")).toBe("be"); + expect(parseCountry("nz")).toBe("nz"); expect(parseCountry("uk")).toBe("uk"); expect(parseCountry("us")).toBe("us"); expect(parseCountry("BE")).toBe(DEFAULT_COUNTRY); @@ -100,6 +111,8 @@ test("capability gates read the registration", () => { expect(hasCapability("uk", "staging")).toBe(false); expect(hasCapability("be", "pipeline")).toBe(false); expect(hasCapability("be", "cross_dataset")).toBe(true); + expect(hasCapability("nz", "cross_dataset")).toBe(false); + expect(hasCapability("nz", "model_coverage")).toBe(false); expect(countryCapabilities("be")).toEqual([ "calibration", "targets", @@ -107,6 +120,7 @@ test("capability gates read the registration", () => { "cross_dataset", ]); expect(countryCapabilities("zz")).toEqual(["calibration", "targets", "compare"]); + expect(countryCapabilities("nz")).toEqual(["calibration", "targets", "compare"]); expect(isCountryCapability("staging")).toBe(true); expect(isCountryCapability("dashboard_admin")).toBe(false); expect(isCountryCapability(7)).toBe(false); diff --git a/frontend/lib/microcosm/countries.ts b/frontend/lib/microcosm/countries.ts index 2b1de1e..5c61421 100644 --- a/frontend/lib/microcosm/countries.ts +++ b/frontend/lib/microcosm/countries.ts @@ -94,6 +94,18 @@ export const COUNTRY_REGISTRY = { visibility: "private", capabilities: CALIBRATION_CAPABILITIES, }, + nz: { + repo: "policyengine/populace-nz", + revision: "main", + repo_env: "POPULACE_NZ_HF_REPO", + revision_env: "POPULACE_NZ_HF_REVISION", + label: "New Zealand", + dataset_label: "Microcosm NZ", + geography: "New Zealand", + geography_id: null, + visibility: "public", + capabilities: ["calibration", "targets", "compare"], + }, // Synthetic repository used only by the third-country conformance fixture. zz: { repo: "policyengine/microcosm-zz-fixture", diff --git a/frontend/lib/microcosm/latest-artifact.test.ts b/frontend/lib/microcosm/latest-artifact.test.ts index 73acb2b..0c11772 100644 --- a/frontend/lib/microcosm/latest-artifact.test.ts +++ b/frontend/lib/microcosm/latest-artifact.test.ts @@ -14,6 +14,8 @@ import { MICROCOSM_HF_REVISION_ENV, MICROCOSM_BE_HF_REPO_ENV, MICROCOSM_BE_HF_REVISION_ENV, + MICROCOSM_NZ_HF_REPO_ENV, + MICROCOSM_NZ_HF_REVISION_ENV, MICROCOSM_UK_HF_REPO_ENV, MICROCOSM_UK_HF_REVISION_ENV, hfResolveUrl, @@ -42,6 +44,8 @@ test("keeps Microcosm deployment configuration on its published Populace env con MICROCOSM_UK_HF_REVISION_ENV, MICROCOSM_BE_HF_REPO_ENV, MICROCOSM_BE_HF_REVISION_ENV, + MICROCOSM_NZ_HF_REPO_ENV, + MICROCOSM_NZ_HF_REVISION_ENV, ]).toEqual([ "POPULACE_HF_REPO", "POPULACE_HF_REVISION", @@ -49,11 +53,14 @@ test("keeps Microcosm deployment configuration on its published Populace env con "POPULACE_UK_HF_REVISION", "POPULACE_BE_HF_REPO", "POPULACE_BE_HF_REVISION", + "POPULACE_NZ_HF_REPO", + "POPULACE_NZ_HF_REVISION", ]); }); test("coerces supported country parameters and defaults unknown values to US", () => { expect(parseCountry("be")).toBe("be"); + expect(parseCountry("nz")).toBe("nz"); expect(parseCountry("uk")).toBe("uk"); expect(parseCountry("us")).toBe("us"); expect(parseCountry("BE")).toBe("us"); @@ -74,6 +81,14 @@ test("uses the private Belgium repository and country revision", () => { ); }); +test("uses the public New Zealand repository and country revision", () => { + expect(microcosmRepo("nz")).toBe("policyengine/populace-nz"); + expect(microcosmRevision("nz")).toBe("main"); + expect(hfResolveUrl("latest.json", "nz")).toBe( + "https://huggingface.co/datasets/policyengine/populace-nz/resolve/main/latest.json", + ); +}); + test("loads trimmed Belgium diagnostics without optional US artifact fields", () => { expect("loss_trajectory" in beDiagnosticsFixture).toBe(false); expect("past_cap_census" in beDiagnosticsFixture).toBe(false); diff --git a/frontend/lib/microcosm/latest-artifact.ts b/frontend/lib/microcosm/latest-artifact.ts index 6032263..535697c 100644 --- a/frontend/lib/microcosm/latest-artifact.ts +++ b/frontend/lib/microcosm/latest-artifact.ts @@ -58,6 +58,8 @@ export const MICROCOSM_UK_HF_REPO_ENV = COUNTRY_REGISTRY.uk.repo_env; export const MICROCOSM_UK_HF_REVISION_ENV = COUNTRY_REGISTRY.uk.revision_env; export const MICROCOSM_BE_HF_REPO_ENV = COUNTRY_REGISTRY.be.repo_env; export const MICROCOSM_BE_HF_REVISION_ENV = COUNTRY_REGISTRY.be.revision_env; +export const MICROCOSM_NZ_HF_REPO_ENV = COUNTRY_REGISTRY.nz.repo_env; +export const MICROCOSM_NZ_HF_REVISION_ENV = COUNTRY_REGISTRY.nz.revision_env; interface MicrocosmCountryRepository { repo: string; diff --git a/frontend/lib/microcosm/source-attribution.test.ts b/frontend/lib/microcosm/source-attribution.test.ts index 1f6fc03..c86b70b 100644 --- a/frontend/lib/microcosm/source-attribution.test.ts +++ b/frontend/lib/microcosm/source-attribution.test.ts @@ -23,6 +23,13 @@ test("links Microcosm to the public US Hugging Face dataset", () => { }); }); +test("links Microcosm to the public New Zealand Hugging Face dataset", () => { + expect(microcosmSourceAttribution("nz", "policyengine/populace-nz")).toEqual({ + label: "Microcosm", + href: "https://huggingface.co/datasets/policyengine/populace-nz", + }); +}); + test("does not expose the private UK Hugging Face dataset", () => { expect(microcosmSourceAttribution("uk", "policyengine/populace-uk-private")).toEqual({ label: "Microcosm",