diff --git a/client/src/pages/AtlasPage.test.tsx b/client/src/pages/AtlasPage.test.tsx
index b18d2563..7bcf4be4 100644
--- a/client/src/pages/AtlasPage.test.tsx
+++ b/client/src/pages/AtlasPage.test.tsx
@@ -127,6 +127,23 @@ const geoJsonWithFR = {
],
};
+const geoJsonWithFranceA3Fallback = {
+ type: 'FeatureCollection',
+ features: [
+ {
+ type: 'Feature',
+ properties: {
+ ISO_A2: '-99',
+ ADM0_A3: 'FRA',
+ ISO_A3: 'FRA',
+ NAME: 'France',
+ ADMIN: 'France',
+ },
+ geometry: null,
+ },
+ ],
+};
+
// ── Atlas API response fixture ────────────────────────────────────────────────
const atlasStatsResponse = {
countries: [{ code: 'FR', tripCount: 2, placeCount: 5, firstVisit: '2023-01-01', lastVisit: '2024-06-01' }],
@@ -1323,6 +1340,33 @@ describe('AtlasPage', () => {
});
});
+ describe('FE-PAGE-ATLAS-041: country search falls back from A3 when ISO_A2 is invalid', () => {
+ it('returns France in search results when GeoJSON provides ADM0_A3 but ISO_A2 is -99', async () => {
+ vi.spyOn(global, 'fetch').mockImplementation((url) => {
+ const urlStr = String(url);
+ if (urlStr.includes('geojson') || urlStr.includes('githubusercontent')) {
+ return Promise.resolve({ ok: true, json: () => Promise.resolve(geoJsonWithFranceA3Fallback) } as Response);
+ }
+ return Promise.reject(new Error(`Unmocked fetch: ${urlStr}`));
+ });
+
+ const user = userEvent.setup();
+ render();
+
+ await waitFor(() => {
+ expect(screen.getByPlaceholderText(/search a country/i)).toBeInTheDocument();
+ });
+
+ const searchInput = screen.getByPlaceholderText(/search a country/i);
+ await user.type(searchInput, 'france');
+
+ await waitFor(() => {
+ const franceButton = screen.getAllByRole('button').find((button) => button.textContent?.includes('France'));
+ expect(franceButton).toBeTruthy();
+ });
+ });
+ });
+
describe('FE-PAGE-ATLAS-042: bucket form submit with actual name value', () => {
it('submitting bucket form with a non-empty name covers handleAddBucketItem', async () => {
server.use(
diff --git a/client/src/pages/AtlasPage.tsx b/client/src/pages/AtlasPage.tsx
index 4dc4047e..85459b43 100644
--- a/client/src/pages/AtlasPage.tsx
+++ b/client/src/pages/AtlasPage.tsx
@@ -189,8 +189,15 @@ export default function AtlasPage(): React.ReactElement {
const opts: { code: string; label: string }[] = []
const seen = new Set()
for (const f of (geoData as any).features || []) {
- const a2 = f?.properties?.ISO_A2
- if (!a2 || a2 === '-99' || typeof a2 !== 'string' || a2.length !== 2) continue
+ let a2 = f?.properties?.ISO_A2
+ if (!a2 || a2 === '-99' || typeof a2 !== 'string' || a2.length !== 2) {
+ const a3 = f?.properties?.ADM0_A3 || f?.properties?.ISO_A3 || f?.properties?.['ISO3166-1-Alpha-3'] || null
+ if (a3 && a3 !== '-99') {
+ const a3ToA2Entry = Object.entries(A2_TO_A3).find(([, v]) => v === a3)
+ a2 = a3ToA2Entry ? a3ToA2Entry[0] : null
+ }
+ }
+ if (!a2 || typeof a2 !== 'string' || a2.length !== 2) continue
if (seen.has(a2)) continue
seen.add(a2)
const label = String(resolveName(a2) || f?.properties?.NAME || f?.properties?.ADMIN || a2)