Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/components/layout/nav-items.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
});
16 changes: 15 additions & 1 deletion frontend/lib/microcosm/countries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
Expand All @@ -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);
Expand All @@ -100,13 +111,16 @@ 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",
"compare",
"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);
Expand Down
12 changes: 12 additions & 0 deletions frontend/lib/microcosm/countries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 15 additions & 0 deletions frontend/lib/microcosm/latest-artifact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -42,18 +44,23 @@ 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",
"POPULACE_UK_HF_REPO",
"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");
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions frontend/lib/microcosm/latest-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions frontend/lib/microcosm/source-attribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading