import assert from "node:assert/strict"; import { describe, it } from "node:test"; import { buildEnvironmentExposure } from "../src/environmentExposure.mjs"; describe("environment exposure map", () => { it("separates passive, network, permission, wireless, and blocked surfaces", () => { const cards = buildEnvironmentExposure({ features: { bluetooth: true, bluetoothRememberedDevices: true, networkInformation: true, geolocation: true, mediaDevices: true, permissions: true, webRtc: true, }, diagnostics: { status: "done", server: { forwardedFor: "203.0.113.8" }, webrtc: { summary: { public: 1, private: 0, mdns: 1 } }, }, }); assert.deepEqual(cards.map((card) => card.id), [ "passive", "network", "permission", "wireless", "blocked", ]); assert.equal(cards.find((card) => card.id === "network").state, "active"); assert.equal(cards.find((card) => card.id === "wireless").state, "gated"); assert.ok(cards.find((card) => card.id === "wireless").items.includes("bluetooth-gated")); assert.ok(cards.find((card) => card.id === "wireless").items.includes("wifi-blocked")); assert.ok(cards.find((card) => card.id === "blocked").items.includes("ambient-bluetooth-blocked")); }); it("marks network and bluetooth as unavailable or pending when the browser has not exposed them", () => { const cards = buildEnvironmentExposure({ features: { bluetooth: false, networkInformation: false, geolocation: false, mediaDevices: false, permissions: false, webRtc: false, }, diagnostics: { status: "idle" }, }); assert.equal(cards.find((card) => card.id === "network").state, "pending"); assert.equal(cards.find((card) => card.id === "wireless").state, "limited"); assert.ok(cards.find((card) => card.id === "wireless").items.includes("bluetooth-unavailable")); assert.ok(cards.find((card) => card.id === "wireless").items.includes("netinfo-unavailable")); }); });