Users with BO_DASHBOARD get period presets, capture and win tiles, the status funnel, a captures/wins trend and breakdowns by event, salesperson and interest; everyone else keeps the welcome. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
23 lines
890 B
TypeScript
23 lines
890 B
TypeScript
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
|
const mocks = vi.hoisted(() => ({ apiGet: vi.fn() }));
|
|
vi.mock("@/app/lib/clientApi", () => mocks);
|
|
|
|
import { getLeadDashboard } from "./adminDashboard";
|
|
|
|
beforeEach(() => mocks.apiGet.mockReset().mockResolvedValue({}));
|
|
|
|
describe("adminDashboard", () => {
|
|
it("sends no query string when no params are given", async () => {
|
|
await getLeadDashboard({});
|
|
expect(mocks.apiGet).toHaveBeenCalledWith("/api/dashboard/leads");
|
|
});
|
|
|
|
it("sends only the given params", async () => {
|
|
await getLeadDashboard({ from: "2026-11-01", to: "2026-11-30", companyId: 2 });
|
|
expect(mocks.apiGet).toHaveBeenCalledWith("/api/dashboard/leads?from=2026-11-01&to=2026-11-30&companyId=2");
|
|
await getLeadDashboard({ companyId: 3 });
|
|
expect(mocks.apiGet).toHaveBeenLastCalledWith("/api/dashboard/leads?companyId=3");
|
|
});
|
|
});
|