mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
fix(admin): name the configured geo provider in the system snapshot
The admin system snapshot hardcoded "ipwho.is" for the offline-geo-off state, so an operator who points IP_GEO_LOOKUP_URL at another provider still read the wrong host. Resolve the actual provider host from the env and surface it through /api/version, so the snapshot reads "Online (ip-api.com)" — the host it really queries.
This commit is contained in:
1 parent
6fe552ffdf
commit
45ca6ff24b
13 files changed
+98
-18
No files matched your search
@@ -5,8 +5,10 @@ vi.mock("@/lib/api-handler", () => ({
|
||||
}));
|
||||
|
||||
const offlineGeoReadyMock = vi.fn(() => false);
|
||||
const resolveGeoProviderHostMock = vi.fn(() => "ipwho.is");
|
||||
vi.mock("@/lib/geo", () => ({
|
||||
offlineGeoReady: () => offlineGeoReadyMock(),
|
||||
resolveGeoProviderHost: () => resolveGeoProviderHostMock(),
|
||||
}));
|
||||
|
||||
import { GET } from "../route";
|
||||
@@ -16,6 +18,7 @@ beforeEach(() => {
|
||||
delete process.env.NEXT_PUBLIC_APP_BUILT_AT;
|
||||
delete process.env.NEXT_PUBLIC_APP_VERSION;
|
||||
offlineGeoReadyMock.mockReturnValue(false);
|
||||
resolveGeoProviderHostMock.mockReturnValue("ipwho.is");
|
||||
});
|
||||
|
||||
interface VersionEnvelope {
|
||||
@@ -28,6 +31,7 @@ interface VersionEnvelope {
|
||||
changelog: string;
|
||||
docs: string;
|
||||
offlineGeoEnabled: boolean;
|
||||
geoProviderHost: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -95,4 +99,11 @@ describe("GET /api/version", () => {
|
||||
const body = (await response.json()) as VersionEnvelope;
|
||||
expect(body.data.offlineGeoEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it("surfaces the resolved online geo provider host", async () => {
|
||||
resolveGeoProviderHostMock.mockReturnValue("ip-api.com");
|
||||
const response = await (GET as unknown as () => Promise<Response>)();
|
||||
const body = (await response.json()) as VersionEnvelope;
|
||||
expect(body.data.geoProviderHost).toBe("ip-api.com");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user