FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring, source collection, LLM-based change analysis, enrichment, and account security (Turnstile, escalating lockout, email verification).
65 lines
2.0 KiB
TypeScript
65 lines
2.0 KiB
TypeScript
import { render, screen } from "@testing-library/react";
|
|
import { describe, expect, it } from "vitest";
|
|
import { DashboardAnalyticsSection } from "@/components/dashboard/analytics-section";
|
|
import type { DashboardAnalytics } from "@/lib/types";
|
|
|
|
const EMPTY_ANALYTICS: DashboardAnalytics = {
|
|
changes_by_type: {
|
|
new_document: 0,
|
|
removed_document: 0,
|
|
content_modified: 0,
|
|
price_change: 0,
|
|
leadership_change: 0,
|
|
filing_new: 0,
|
|
},
|
|
alerts_by_severity: { critical: 0, high: 0, medium: 0, low: 0 },
|
|
sources_by_status: {
|
|
active: 0,
|
|
disabled: 0,
|
|
rate_limited: 0,
|
|
auth_required: 0,
|
|
blocked_by_policy: 0,
|
|
failed: 0,
|
|
},
|
|
runs_by_day: [],
|
|
recent_signals: [],
|
|
};
|
|
|
|
describe("DashboardAnalyticsSection", () => {
|
|
it("shows empty states when there is no activity yet", () => {
|
|
render(<DashboardAnalyticsSection analytics={EMPTY_ANALYTICS} />);
|
|
|
|
expect(screen.getByText(/no changes detected in the last 30 days/i)).toBeInTheDocument();
|
|
expect(screen.getByText(/no alerts in the last 30 days/i)).toBeInTheDocument();
|
|
expect(screen.getByText(/no monitoring runs in the last 30 days/i)).toBeInTheDocument();
|
|
expect(screen.getByText(/no signals detected yet/i)).toBeInTheDocument();
|
|
});
|
|
|
|
it("renders a recent signal with company link and severity", () => {
|
|
const analytics: DashboardAnalytics = {
|
|
...EMPTY_ANALYTICS,
|
|
recent_signals: [
|
|
{
|
|
id: "change-1",
|
|
company_id: "company-1",
|
|
company_name: "Acme Mobility",
|
|
change_type: "leadership_change",
|
|
severity: "high",
|
|
confidence_score: 0.8,
|
|
summary: "New CEO announced",
|
|
created_at: new Date().toISOString(),
|
|
},
|
|
],
|
|
};
|
|
|
|
render(<DashboardAnalyticsSection analytics={analytics} />);
|
|
|
|
expect(screen.getByText("New CEO announced")).toBeInTheDocument();
|
|
expect(screen.getByRole("link", { name: "Acme Mobility" })).toHaveAttribute(
|
|
"href",
|
|
"/companies/company-1",
|
|
);
|
|
expect(screen.getByText("high")).toBeInTheDocument();
|
|
});
|
|
});
|