From 13ec2c88e270a6e928bf329c036e93d380cf1ba1 Mon Sep 17 00:00:00 2001
From: Ayobami Haastrup <47716486+AyobamiH@users.noreply.github.com>
Date: Fri, 4 Sep 2026 23:37:46 +0100
Subject: [PATCH] fix(map): handle missing MapTiler key
---
SELF-HOSTING.md | 2 ++
src/components/map/map-view.test.tsx | 33 ++++++++++++++++++
src/components/map/map-view.tsx | 50 +++++++++++++++++++++++++++-
3 files changed, 84 insertions(+), 1 deletion(-)
create mode 100644 src/components/map/map-view.test.tsx
diff --git a/SELF-HOSTING.md b/SELF-HOSTING.md
index 228eb97..040f09a 100644
--- a/SELF-HOSTING.md
+++ b/SELF-HOSTING.md
@@ -56,6 +56,8 @@ cp .env.example .env.local
- `NEXT_PUBLIC_MAPTILER_KEY` is required for the map basemap. Free tier, no credit card, at
[cloud.maptiler.com](https://cloud.maptiler.com/account/keys/).
+- If the key is missing or empty, the map shows "Basemap unavailable" instead of loading tiles.
+ Add the key to `.env.local`, then restart the development server or redeploy the site.
- The Supabase variables are optional. Leave them blank and the map, filters, and calendar all
work; you just won't get sign-in or the two private features below. See step 5 to fill them in.
diff --git a/src/components/map/map-view.test.tsx b/src/components/map/map-view.test.tsx
new file mode 100644
index 0000000..ebabe4f
--- /dev/null
+++ b/src/components/map/map-view.test.tsx
@@ -0,0 +1,33 @@
+import { cleanup, render, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import MapView from "@/components/map/map-view";
+
+afterEach(() => {
+ cleanup();
+ vi.unstubAllEnvs();
+ vi.restoreAllMocks();
+});
+
+describe("MapView configuration", () => {
+ it("shows actionable guidance when the MapTiler key is blank", () => {
+ vi.stubEnv("NEXT_PUBLIC_MAPTILER_KEY", " ");
+ const warn = vi.spyOn(console, "warn").mockImplementation(() => undefined);
+
+ render(
Basemap unavailable
+
+ The site administrator needs to configure{" "}
+
+ NEXT_PUBLIC_MAPTILER_KEY
+ {" "}
+ before the map can load.
+