- Login: company-code hint after an invalid-credentials failure with an empty company. - Password forms show the active rules (label-first, count-safe) and tie hint and refusal to the input. - Interests and roles: soft delete with confirm dialogs; deactivate now confirms too. - Dashboard figure explanations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
38 lines
1.9 KiB
TypeScript
38 lines
1.9 KiB
TypeScript
import { render, screen, within } from "@testing-library/react";
|
|
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
|
const mocks = vi.hoisted(() => ({ getLeadDashboard: vi.fn(), useAdminAuth: vi.fn(), useCompanyScope: vi.fn() }));
|
|
vi.mock("@/app/lib/services/adminDashboard", () => ({ getLeadDashboard: mocks.getLeadDashboard }));
|
|
vi.mock("@/app/lib/AdminAuthContext", () => ({ useAdminAuth: mocks.useAdminAuth }));
|
|
vi.mock("@/app/lib/CompanyScope", () => ({ useCompanyScope: mocks.useCompanyScope }));
|
|
vi.mock("next/navigation", async () => (await import("@/test/memoryRouter")).navigationMock);
|
|
|
|
import HomePage from "./page";
|
|
|
|
const DATA = {
|
|
from: "2026-12-01", to: "2026-12-01", bucket: "DAY",
|
|
captures: 40, newLeads: 25, wonInPeriod: 8, medianDaysToWin: 4.5, overdueFollowUps: 3,
|
|
funnel: { OPEN: 11, CONTACTED: 12, QUALIFIED: 13, WON: 8, LOST: 6 },
|
|
trend: [], events: [], salespeople: [], interests: [],
|
|
};
|
|
|
|
beforeEach(() => {
|
|
mocks.getLeadDashboard.mockReset().mockResolvedValue(DATA);
|
|
mocks.useAdminAuth.mockReset().mockReturnValue({ name: "Alice", loading: false, isSuper: false, hasModule: (m: string) => m === "BO_DASHBOARD" });
|
|
mocks.useCompanyScope.mockReset().mockReturnValue({ companyId: undefined, companies: [], showCompanyColumn: false, codeOf: () => "", setCompanyId: vi.fn() });
|
|
});
|
|
|
|
describe("dashboard explanation lines", () => {
|
|
it("explains Won in period as visible text inside its tile", async () => {
|
|
render(<HomePage />);
|
|
const tile = within(await screen.findByRole("group", { name: "Won in period" }));
|
|
expect(tile.getByText("Leads won in this period, whenever they were captured.")).toBeVisible();
|
|
});
|
|
|
|
it("explains the funnel as visible text", async () => {
|
|
render(<HomePage />);
|
|
await screen.findByRole("group", { name: "Captures" });
|
|
expect(screen.getByText("This period's captures, by their current stage.")).toBeVisible();
|
|
});
|
|
});
|