feat(stats): add Paths and Hashes analytics (#57)

This commit is contained in:
n30nex authored and GitHub committed 2026-09-23 20:16:23 -04:00
1 parent 2405e1ac96
commit 929ba83cf1
12 files changed
+303 -3

No files matched your search

+12 -1
View File
@@ -1,8 +1,19 @@
import { afterEach, expect, it, vi } from "vitest";
import { getStatsObservations, getStatsScopes, getSignalStats } from "../../src/api/client";
import { getStatsObservations, getStatsScopes, getSignalStats, getPathStats } from "../../src/api/client";
afterEach(() => vi.unstubAllGlobals());
it("sends path window bounds, regional filters and cancellation", async () => {
const fetcher = vi.fn<typeof fetch>(async () => ({ ok: true, json: async () => ({}) }) as Response);
vi.stubGlobal("fetch", fetcher);
const controller = new AbortController();
await getPathStats(0, 1000, ["YVR", "YYJ"], controller.signal);
const url = new URL(fetcher.mock.calls[0]![0] as string);
expect(url.pathname).toContain("/stats/paths");
expect(Object.fromEntries(url.searchParams)).toEqual({ since: "0", until: "1000", iatas: "YVR,YYJ" });
expect(fetcher.mock.calls[0]![1]).toEqual({ signal: controller.signal });
});
it("forwards region and cancellation to both aggregate endpoints, omitting an empty global filter", async () => {
const fetcher = vi.fn<typeof fetch>(async () => ({ ok: true, json: async () => [] }) as Response);
vi.stubGlobal("fetch", fetcher);