fix(dashboard): show enriched network details
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { groupMapLocations, parseUserLocation, projectWorldPoint } from "./user-location-map";
|
||||
import { groupMapLocations, parseUserLocation, parseUserNetwork, projectWorldPoint } from "./user-location-map";
|
||||
|
||||
describe("user location map", () => {
|
||||
it("extracts a valid approximate location from cached IP intelligence", () => {
|
||||
@@ -19,6 +19,29 @@ describe("user location map", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("extracts enriched network fields from existing ProxyCheck cache entries", () => {
|
||||
expect(parseUserNetwork({
|
||||
network: { asn: "AS7922", provider: "Comcast Cable Communications, LLC" },
|
||||
rawResponse: {
|
||||
status: "ok",
|
||||
"203.0.113.10": { type: "Residential", proxy: "no" },
|
||||
},
|
||||
})).toEqual({
|
||||
asn: "AS7922",
|
||||
provider: "Comcast Cable Communications, LLC",
|
||||
connectionType: "Residential",
|
||||
proxy: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers normalized network fields and preserves unavailable values", () => {
|
||||
expect(parseUserNetwork({
|
||||
network: { asn: "AS62371", provider: "Proton AG", connectionType: "VPN", proxy: true },
|
||||
rawResponse: { "198.51.100.5": { type: "Residential", proxy: "no" } },
|
||||
})).toEqual({ asn: "AS62371", provider: "Proton AG", connectionType: "VPN", proxy: true });
|
||||
expect(parseUserNetwork({ network: {} })).toEqual({ asn: null, provider: null, connectionType: null, proxy: null });
|
||||
});
|
||||
|
||||
it("rejects missing and out-of-range coordinates", () => {
|
||||
expect(parseUserLocation({ location: { latitude: 91, longitude: 0 } })).toBeNull();
|
||||
expect(parseUserLocation({ location: { city: "Unknown" } })).toBeNull();
|
||||
|
||||
Reference in New Issue
Block a user