From 3bd55846a43542cf0d7c1e0fd4eb6d42958c9a73 Mon Sep 17 00:00:00 2001 From: Nico Date: Thu, 4 Jun 2026 18:54:08 -0700 Subject: [PATCH] fix: hide zero map overview rows --- .../maps/LocationMapBottomSheet.jsx | 13 +++--- frontend/tests/location-map-manager.spec.ts | 43 +++++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/frontend/src/components/maps/LocationMapBottomSheet.jsx b/frontend/src/components/maps/LocationMapBottomSheet.jsx index 52da9e9..13747a6 100644 --- a/frontend/src/components/maps/LocationMapBottomSheet.jsx +++ b/frontend/src/components/maps/LocationMapBottomSheet.jsx @@ -28,7 +28,7 @@ export default function LocationMapBottomSheet({ selectedZoneItems = EMPTY_ITEMS, visibleAssignedItemCount = 0, visibleUnmappedItems = EMPTY_ITEMS, - unmappedItemCount, + unmappedItemCount = 0, hiddenAreaCount, saving, savingAction, @@ -129,6 +129,11 @@ export default function LocationMapBottomSheet({ : visibleUnmappedItems.length === unmappedItemCount ? String(unmappedItemCount) : `${visibleUnmappedItems.length} shown`; + const mapOverviewRows = [ + { label: "Areas", value: filters.showZones ? `${visibleAreaCount} shown` : "Hidden" }, + ...(assignedItemCount > 0 ? [{ label: "Mapped items", value: mappedItemSummary }] : []), + ...(unmappedItemCount > 0 ? [{ label: "Unmapped", value: unmappedItemSummary }] : []), + ]; const resetLayerFilters = () => setFilters({ ...DEFAULT_MAP_FILTERS }); const showSelectedZoneItems = () => { setFilters((current) => ({ @@ -252,11 +257,7 @@ export default function LocationMapBottomSheet({ {showMapOverview ? ( ) : null} diff --git a/frontend/tests/location-map-manager.spec.ts b/frontend/tests/location-map-manager.spec.ts index b504337..a6d4af6 100644 --- a/frontend/tests/location-map-manager.spec.ts +++ b/frontend/tests/location-map-manager.spec.ts @@ -2777,6 +2777,49 @@ test("viewer shows a compact map overview before selecting an area", async ({ pa await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Bakery"); }); +test("viewer omits zero item rows from the map overview", async ({ page }) => { + await mockMapShell(page); + + const mapState = { + ...publishedMapState([ + { + id: 1531, + location_map_id: 901, + zone_id: 501, + zone_name: "Bakery", + type: "zone", + label: "Bakery", + x: 40, + y: 40, + width: 260, + height: 160, + rotation: 0, + locked: false, + visible: true, + sort_order: 1, + }, + ], true), + items: [], + unmapped_count: 0, + }; + + await page.route("**/households/1/locations/10/map", async (route) => { + await route.fulfill({ + status: 200, + contentType: "application/json", + body: JSON.stringify(mapState), + }); + }); + + await page.goto("/stores/100/locations/10/map"); + + const overview = page.getByLabel("Map summary"); + await expect(overview.locator(".location-map-overview-row")).toHaveCount(1); + await expect(overview.locator(".location-map-overview-row", { hasText: "Areas" }).locator("strong")).toHaveText("1 shown"); + await expect(overview.locator(".location-map-overview-row", { hasText: "Mapped items" })).toHaveCount(0); + await expect(overview.locator(".location-map-overview-row", { hasText: "Unmapped" })).toHaveCount(0); +}); + test("viewer shows a compact overflow cue for long unmapped lists", async ({ page }) => { await mockMapShell(page);