diff --git a/internal/check-selection-kinds.mjs b/internal/check-selection-kinds.mjs index 6022e3a53..9b0833545 100644 --- a/internal/check-selection-kinds.mjs +++ b/internal/check-selection-kinds.mjs @@ -166,6 +166,27 @@ for (const fn of ['onLegendExport', 'makeSelectionPacket', 'makeSelectionPoster' } } +// ── 4. A TAPPED FEATURE RESOLVES AT ITS REAL LEVEL, FROM ITS REAL PROPERTIES ────────────────────── +// Sections 1-2 start from hand-made KEYS ('adm0:IND'), so they could not see the resolver itself +// misfile a country: once the world ADM0 boundaries carried a shapeName, "shapeName → ADM1" turned +// every tapped country into a province (key 'adm1:Sudan', count null, 0 UUPG), and the Prayer List +// refused it (reported from a phone, 2026-09-30). These are the properties the map ACTUALLY hands the +// click handler (read off the live tapestry), so a resolver that keys on the wrong field fails here. +{ + const { resolveTerritory, COUNTRY_COUNTS, ADM1_COUNTS } = await import(resolve(ROOT, 'plugin-designs/my-upg-100-list/data/territory-counts.js')) + const country = resolveTerritory({ shapeGroup: 'SDN', shapeName: 'Sudan', iso3: 'SDN', zoneKey: 'sudan', zoneLabel: 'Sudan' }) + ok(country && country.kind === 'adm0' && country.key === 'adm0:SDN', + `a tapped COUNTRY (shapeName + iso3, no listId) resolved as ${JSON.stringify(country)}, not adm0:SDN — every country tap would count 0 UUPG`) + ok(country && country.count === COUNTRY_COUNTS.SDN && country.count > 0, + `a tapped country's count is ${country && country.count}, not its COUNTRY_COUNTS entry (${COUNTRY_COUNTS.SDN})`) + const state = resolveTerritory({ iso3: 'IND', shapeGroup: 'IND', listId: 'asia-india-madhya-pradesh', shapeName: 'Madhya Pradesh', zoneKey: 'asia-india-madhya-pradesh' }) + ok(state && state.kind === 'adm1' && state.key === 'adm1:Madhya Pradesh' && state.count === ADM1_COUNTS['Madhya Pradesh'], + `a tapped India STATE (listId + shapeName + iso3) resolved as ${JSON.stringify(state)}, not adm1 with its ADM1_COUNTS entry`) + const nepal = resolveTerritory({ shapeGroup: 'NPL', shapeName: 'Nepal', iso3: 'NPL', zoneKey: 'asia-india-uttarakhand' }) + ok(nepal && nepal.kind === 'adm0' && nepal.key === 'adm0:NPL', + `a country drawn inside an Asia zone (zone.adm0, no listId) resolved as ${JSON.stringify(nepal)}, not adm0:NPL`) +} + if (fails.length) { console.error('SELECTION-KINDS: FAIL') for (const f of fails) console.error(` ✗ ${f}`)