diff --git a/apps/web/src/app/(authenticated)/page.test.tsx b/apps/web/src/app/(authenticated)/page.test.tsx index 4702f0d..98da381 100644 --- a/apps/web/src/app/(authenticated)/page.test.tsx +++ b/apps/web/src/app/(authenticated)/page.test.tsx @@ -1,85 +1,55 @@ import { describe, it, expect, vi } from "vitest"; -import { render, screen, waitFor } from "@testing-library/react"; +import { render, screen } from "@testing-library/react"; import DashboardPage from "./page"; -// Mock dashboard widgets -vi.mock("@/components/dashboard/RecentTasksWidget", () => ({ - RecentTasksWidget: ({ - tasks, - isLoading, - }: { - tasks: unknown[]; - isLoading: boolean; - }): React.JSX.Element => ( -
- {isLoading ? "Loading tasks" : `${String(tasks.length)} tasks`} -
+// Mock Phase 3 dashboard widgets +vi.mock("@/components/dashboard/DashboardMetrics", () => ({ + DashboardMetrics: (): React.JSX.Element => ( +
Dashboard Metrics
), })); -vi.mock("@/components/dashboard/UpcomingEventsWidget", () => ({ - UpcomingEventsWidget: ({ - events, - isLoading, - }: { - events: unknown[]; - isLoading: boolean; - }): React.JSX.Element => ( -
- {isLoading ? "Loading events" : `${String(events.length)} events`} -
+vi.mock("@/components/dashboard/OrchestratorSessions", () => ({ + OrchestratorSessions: (): React.JSX.Element => ( +
Orchestrator Sessions
), })); -vi.mock("@/components/dashboard/QuickCaptureWidget", () => ({ - QuickCaptureWidget: (): React.JSX.Element =>
Quick Capture
, +vi.mock("@/components/dashboard/QuickActions", () => ({ + QuickActions: (): React.JSX.Element =>
Quick Actions
, })); -vi.mock("@/components/dashboard/DomainOverviewWidget", () => ({ - DomainOverviewWidget: ({ - tasks, - isLoading, - }: { - tasks: unknown[]; - isLoading: boolean; - }): React.JSX.Element => ( -
- {isLoading ? "Loading overview" : `${String(tasks.length)} tasks overview`} -
- ), +vi.mock("@/components/dashboard/ActivityFeed", () => ({ + ActivityFeed: (): React.JSX.Element =>
Activity Feed
, +})); + +vi.mock("@/components/dashboard/TokenBudget", () => ({ + TokenBudget: (): React.JSX.Element =>
Token Budget
, })); describe("DashboardPage", (): void => { - it("should render the page title", (): void => { + it("should render the DashboardMetrics widget", (): void => { render(); - expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Dashboard"); + expect(screen.getByTestId("dashboard-metrics")).toBeInTheDocument(); }); - it("should show loading state initially", (): void => { + it("should render the OrchestratorSessions widget", (): void => { render(); - expect(screen.getByTestId("recent-tasks")).toHaveTextContent("Loading tasks"); - expect(screen.getByTestId("upcoming-events")).toHaveTextContent("Loading events"); - expect(screen.getByTestId("domain-overview")).toHaveTextContent("Loading overview"); + expect(screen.getByTestId("orchestrator-sessions")).toBeInTheDocument(); }); - it("should render all widgets with data after loading", async (): Promise => { + it("should render the QuickActions widget", (): void => { render(); - await waitFor((): void => { - expect(screen.getByTestId("recent-tasks")).toHaveTextContent("4 tasks"); - expect(screen.getByTestId("upcoming-events")).toHaveTextContent("3 events"); - expect(screen.getByTestId("domain-overview")).toHaveTextContent("4 tasks overview"); - expect(screen.getByTestId("quick-capture")).toBeInTheDocument(); - }); + expect(screen.getByTestId("quick-actions")).toBeInTheDocument(); }); - it("should have proper layout structure", (): void => { - const { container } = render(); - const main = container.querySelector("main"); - expect(main).toBeInTheDocument(); + it("should render the ActivityFeed widget", (): void => { + render(); + expect(screen.getByTestId("activity-feed")).toBeInTheDocument(); }); - it("should render the welcome subtitle", (): void => { + it("should render the TokenBudget widget", (): void => { render(); - expect(screen.getByText(/Welcome back/)).toBeInTheDocument(); + expect(screen.getByTestId("token-budget")).toBeInTheDocument(); }); }); diff --git a/apps/web/src/components/dashboard/DomainOverviewWidget.tsx b/apps/web/src/components/dashboard/DomainOverviewWidget.tsx deleted file mode 100644 index 577bf3c..0000000 --- a/apps/web/src/components/dashboard/DomainOverviewWidget.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import type { Task } from "@mosaic/shared"; -import { TaskStatus, TaskPriority } from "@mosaic/shared"; - -interface DomainOverviewWidgetProps { - tasks: Task[]; - isLoading: boolean; -} - -export function DomainOverviewWidget({ - tasks, - isLoading, -}: DomainOverviewWidgetProps): React.JSX.Element { - if (isLoading) { - return ( -
-
-
- Loading overview... -
-
- ); - } - - const stats = { - total: tasks.length, - inProgress: tasks.filter((t) => t.status === TaskStatus.IN_PROGRESS).length, - completed: tasks.filter((t) => t.status === TaskStatus.COMPLETED).length, - highPriority: tasks.filter((t) => t.priority === TaskPriority.HIGH).length, - }; - - const StatCard = ({ - label, - value, - color, - }: { - label: string; - value: number; - color: string; - }): React.JSX.Element => ( -
-
{value}
-
{label}
-
- ); - - return ( -
-

Domain Overview

-
- - - - -
-
- ); -} diff --git a/apps/web/src/components/dashboard/QuickCaptureWidget.tsx b/apps/web/src/components/dashboard/QuickCaptureWidget.tsx deleted file mode 100644 index 96cac82..0000000 --- a/apps/web/src/components/dashboard/QuickCaptureWidget.tsx +++ /dev/null @@ -1,85 +0,0 @@ -"use client"; - -import { useState } from "react"; -import { Button } from "@mosaic/ui"; -import { useRouter } from "next/navigation"; -import { ComingSoon } from "@/components/ui/ComingSoon"; - -/** - * Check if we're in development mode (runtime check for testability) - */ -function isDevelopment(): boolean { - return process.env.NODE_ENV === "development"; -} - -/** - * Internal Quick Capture Widget implementation - */ -function QuickCaptureWidgetInternal(): React.JSX.Element { - const [idea, setIdea] = useState(""); - const router = useRouter(); - - const handleSubmit = (e: React.SyntheticEvent): void => { - e.preventDefault(); - if (!idea.trim()) return; - - // TODO: Implement quick capture API call - // For now, just show a success indicator - console.log("Quick capture:", idea); - setIdea(""); - }; - - const goToTasks = (): void => { - router.push("/tasks"); - }; - - return ( -
-

Quick Capture

-

Quickly jot down ideas or brain dumps

-
-