diff --git a/apps/stock/web-app/src/app/App.tsx b/apps/stock/web-app/src/app/App.tsx index a0a1d0a5..2f9c251d 100644 --- a/apps/stock/web-app/src/app/App.tsx +++ b/apps/stock/web-app/src/app/App.tsx @@ -1,7 +1,6 @@ import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'; import { Layout } from '@/components/layout'; import { BacktestDetailPageV2, BacktestListPageV2 } from '@/features/backtest'; -import { DashboardPage } from '@/features/dashboard'; import { ExchangesPage } from '@/features/exchanges'; import { ChronologicalValidationDetailPage, @@ -25,8 +24,8 @@ export function App() { }> - } /> - } /> + } /> + } /> } /> } /> diff --git a/apps/stock/web-app/src/components/layout/Header.tsx b/apps/stock/web-app/src/components/layout/Header.tsx index 494524b5..4be7af6d 100644 --- a/apps/stock/web-app/src/components/layout/Header.tsx +++ b/apps/stock/web-app/src/components/layout/Header.tsx @@ -5,7 +5,7 @@ interface HeaderProps { title?: string; } -export function Header({ setSidebarOpen, title = 'Dashboard' }: HeaderProps) { +export function Header({ setSidebarOpen, title = 'Stock Bot' }: HeaderProps) { return (
- ); -} diff --git a/apps/stock/web-app/src/features/dashboard/components/DashboardActivity.tsx b/apps/stock/web-app/src/features/dashboard/components/DashboardActivity.tsx deleted file mode 100644 index fe4d0b83..00000000 --- a/apps/stock/web-app/src/features/dashboard/components/DashboardActivity.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { Card, CardHeader, CardContent } from '@/components/ui'; - -export function DashboardActivity() { - return ( -
- - -

Recent Activity

-
- -
- No recent activity - -- -
-
-
- - - -

Market Overview

-
- -
- Market data loading... - -- -
-
-
-
- ); -} diff --git a/apps/stock/web-app/src/features/dashboard/components/DashboardStats.tsx b/apps/stock/web-app/src/features/dashboard/components/DashboardStats.tsx deleted file mode 100644 index 17547706..00000000 --- a/apps/stock/web-app/src/features/dashboard/components/DashboardStats.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { CurrencyDollarIcon, ChartBarIcon, DocumentTextIcon } from '@heroicons/react/24/outline'; -import { StatCard } from '@/components/ui'; - -export function DashboardStats() { - return ( -
- } - iconBgColor="bg-primary-500/10" - valueColor="text-primary-400" - borderColor="border-primary-500/50" - /> - - } - iconBgColor="bg-success/10" - valueColor="text-success" - borderColor="border-success/50" - /> - - } - iconBgColor="bg-warning/10" - valueColor="text-warning" - borderColor="border-warning/50" - /> -
- ); -} diff --git a/apps/stock/web-app/src/features/dashboard/components/PortfolioTable.tsx b/apps/stock/web-app/src/features/dashboard/components/PortfolioTable.tsx deleted file mode 100644 index daeb6aa4..00000000 --- a/apps/stock/web-app/src/features/dashboard/components/PortfolioTable.tsx +++ /dev/null @@ -1,642 +0,0 @@ -import { DataTable } from '@/components/ui'; -import type { ColumnDef } from '@tanstack/react-table'; -import React from 'react'; - -interface PortfolioItem { - symbol: string; - quantity: number; - avgPrice: number; - currentPrice: number; - value: number; - change: number; - changePercent: number; - // Additional columns for stress testing - volume: number; - marketCap: number; - pe: number; - pb: number; - roe: number; - debt: number; - revenue: number; - earnings: number; - dividend: number; - beta: number; - rsi: number; - macd: number; - sma20: number; - sma50: number; - sma200: number; - support: number; - resistance: number; - volatility: number; - sharpe: number; - alpha: number; - correlation: number; - sector: string; - industry: string; - country: string; - exchange: string; - currency: string; - lastUpdate: string; - analyst1: string; - analyst2: string; - analyst3: string; - rating1: number; - rating2: number; - rating3: number; - target1: number; - target2: number; - target3: number; - risk: string; - esg: number; -} - -export function PortfolioTable() { - // Generate 100,000 rows of sample data - const data: PortfolioItem[] = React.useMemo(() => { - const symbols = [ - 'AAPL', - 'GOOGL', - 'MSFT', - 'TSLA', - 'AMZN', - 'META', - 'NFLX', - 'NVDA', - 'AMD', - 'INTC', - 'CRM', - 'ORCL', - 'IBM', - 'CSCO', - 'UBER', - 'LYFT', - 'SNAP', - 'TWTR', - 'SPOT', - 'SQ', - ]; - const sectors = [ - 'Technology', - 'Healthcare', - 'Finance', - 'Energy', - 'Consumer', - 'Industrial', - 'Materials', - 'Utilities', - 'Real Estate', - 'Telecom', - ]; - const industries = [ - 'Software', - 'Hardware', - 'Biotech', - 'Banking', - 'Oil & Gas', - 'Retail', - 'Manufacturing', - 'Mining', - 'Utilities', - 'REITs', - ]; - const countries = [ - 'USA', - 'Canada', - 'UK', - 'Germany', - 'Japan', - 'China', - 'India', - 'Brazil', - 'Australia', - 'France', - ]; - const exchanges = ['NYSE', 'NASDAQ', 'LSE', 'TSX', 'Nikkei', 'SSE', 'BSE', 'ASX', 'Euronext']; - const currencies = ['USD', 'CAD', 'GBP', 'EUR', 'JPY', 'CNY', 'INR', 'BRL', 'AUD']; - const analysts = [ - 'Goldman Sachs', - 'Morgan Stanley', - 'JPMorgan', - 'Bank of America', - 'Wells Fargo', - 'Credit Suisse', - 'Deutsche Bank', - 'Barclays', - 'UBS', - 'Citigroup', - ]; - const risks = ['Low', 'Medium', 'High', 'Very High']; - - return Array.from({ length: 100000 }, (_, i) => { - const basePrice = 50 + Math.random() * 500; - const change = (Math.random() - 0.5) * 20; - const quantity = Math.floor(Math.random() * 1000) + 1; - - return { - symbol: `${symbols[i % symbols.length]}${Math.floor(i / symbols.length)}`, - quantity, - avgPrice: basePrice, - currentPrice: basePrice + change, - value: (basePrice + change) * quantity, - change: change * quantity, - changePercent: (change / basePrice) * 100, - volume: Math.floor(Math.random() * 10000000), - marketCap: Math.floor(Math.random() * 1000000000000), - pe: Math.random() * 50 + 5, - pb: Math.random() * 10 + 0.5, - roe: Math.random() * 30 + 5, - debt: Math.random() * 50, - revenue: Math.floor(Math.random() * 100000000000), - earnings: Math.floor(Math.random() * 10000000000), - dividend: Math.random() * 5, - beta: Math.random() * 3 + 0.5, - rsi: Math.random() * 100, - macd: (Math.random() - 0.5) * 10, - sma20: basePrice + (Math.random() - 0.5) * 10, - sma50: basePrice + (Math.random() - 0.5) * 20, - sma200: basePrice + (Math.random() - 0.5) * 50, - support: basePrice - Math.random() * 20, - resistance: basePrice + Math.random() * 20, - volatility: Math.random() * 100, - sharpe: Math.random() * 3, - alpha: (Math.random() - 0.5) * 20, - correlation: (Math.random() - 0.5) * 2, - sector: sectors[Math.floor(Math.random() * sectors.length)] || 'Technology', - industry: industries[Math.floor(Math.random() * industries.length)] || 'Software', - country: countries[Math.floor(Math.random() * countries.length)] || 'USA', - exchange: exchanges[Math.floor(Math.random() * exchanges.length)] || 'NYSE', - currency: currencies[Math.floor(Math.random() * currencies.length)] || 'USD', - lastUpdate: new Date(Date.now() - Math.random() * 86400000).toISOString(), - analyst1: analysts[Math.floor(Math.random() * analysts.length)] || 'Goldman Sachs', - analyst2: analysts[Math.floor(Math.random() * analysts.length)] || 'Morgan Stanley', - analyst3: analysts[Math.floor(Math.random() * analysts.length)] || 'JPMorgan', - rating1: Math.random() * 5 + 1, - rating2: Math.random() * 5 + 1, - rating3: Math.random() * 5 + 1, - target1: basePrice + (Math.random() - 0.3) * 50, - target2: basePrice + (Math.random() - 0.3) * 50, - target3: basePrice + (Math.random() - 0.3) * 50, - risk: risks[Math.floor(Math.random() * risks.length)] || 'Medium', - esg: Math.random() * 100, - }; - }); - }, []); - - const columns: ColumnDef[] = [ - { - id: 'symbol', - header: 'Symbol', - accessorKey: 'symbol', - size: 120, - cell: ({ getValue }) => ( - {getValue() as string} - ), - }, - { - id: 'quantity', - header: 'Quantity', - accessorKey: 'quantity', - size: 100, - cell: ({ getValue }) => ( - {(getValue() as number).toLocaleString()} - ), - }, - { - id: 'avgPrice', - header: 'Avg Price', - accessorKey: 'avgPrice', - size: 120, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'currentPrice', - header: 'Current Price', - accessorKey: 'currentPrice', - size: 120, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'value', - header: 'Value', - accessorKey: 'value', - size: 120, - cell: ({ getValue }) => ( - ${(getValue() as number).toLocaleString()} - ), - }, - { - id: 'change', - header: 'P&L', - accessorKey: 'change', - size: 120, - cell: ({ getValue }) => { - const value = getValue() as number; - const isPositive = value >= 0; - return ( - - {isPositive ? '+' : ''}${value.toLocaleString()} - - ); - }, - }, - { - id: 'changePercent', - header: 'P&L %', - accessorKey: 'changePercent', - size: 100, - cell: ({ getValue }) => { - const value = getValue() as number; - const isPositive = value >= 0; - return ( - - {isPositive ? '+' : ''} - {value.toFixed(2)}% - - ); - }, - }, - { - id: 'volume', - header: 'Volume', - accessorKey: 'volume', - size: 120, - cell: ({ getValue }) => ( - - {(getValue() as number).toLocaleString()} - - ), - }, - { - id: 'marketCap', - header: 'Market Cap', - accessorKey: 'marketCap', - size: 120, - cell: ({ getValue }) => { - const value = getValue() as number; - if (value >= 1e12) {return ${(value / 1e12).toFixed(2)}T;} - if (value >= 1e9) {return ${(value / 1e9).toFixed(2)}B;} - if (value >= 1e6) {return ${(value / 1e6).toFixed(2)}M;} - return ${value.toLocaleString()}; - }, - }, - { - id: 'pe', - header: 'P/E', - accessorKey: 'pe', - size: 80, - cell: ({ getValue }) => ( - {(getValue() as number).toFixed(2)} - ), - }, - { - id: 'pb', - header: 'P/B', - accessorKey: 'pb', - size: 80, - cell: ({ getValue }) => ( - {(getValue() as number).toFixed(2)} - ), - }, - { - id: 'roe', - header: 'ROE %', - accessorKey: 'roe', - size: 80, - cell: ({ getValue }) => ( - {(getValue() as number).toFixed(1)}% - ), - }, - { - id: 'debt', - header: 'Debt %', - accessorKey: 'debt', - size: 80, - cell: ({ getValue }) => ( - {(getValue() as number).toFixed(1)}% - ), - }, - { - id: 'revenue', - header: 'Revenue', - accessorKey: 'revenue', - size: 120, - cell: ({ getValue }) => { - const value = getValue() as number; - if (value >= 1e9) {return ${(value / 1e9).toFixed(2)}B;} - if (value >= 1e6) {return ${(value / 1e6).toFixed(2)}M;} - return ${value.toLocaleString()}; - }, - }, - { - id: 'earnings', - header: 'Earnings', - accessorKey: 'earnings', - size: 120, - cell: ({ getValue }) => { - const value = getValue() as number; - if (value >= 1e9) {return ${(value / 1e9).toFixed(2)}B;} - if (value >= 1e6) {return ${(value / 1e6).toFixed(2)}M;} - return ${value.toLocaleString()}; - }, - }, - { - id: 'dividend', - header: 'Dividend %', - accessorKey: 'dividend', - size: 100, - cell: ({ getValue }) => { - const value = getValue() as number; - return {value.toFixed(2)}%; - }, - }, - { - id: 'beta', - header: 'Beta', - accessorKey: 'beta', - size: 80, - cell: ({ getValue }) => { - const value = getValue() as number; - const color = value > 1 ? 'text-warning' : value < 1 ? 'text-success' : 'text-text-primary'; - return {value.toFixed(2)}; - }, - }, - { - id: 'rsi', - header: 'RSI', - accessorKey: 'rsi', - size: 80, - cell: ({ getValue }) => { - const value = getValue() as number; - const color = - value > 70 ? 'text-danger' : value < 30 ? 'text-success' : 'text-text-primary'; - return {value.toFixed(1)}; - }, - }, - { - id: 'macd', - header: 'MACD', - accessorKey: 'macd', - size: 80, - cell: ({ getValue }) => { - const value = getValue() as number; - const color = value > 0 ? 'text-success' : 'text-danger'; - return {value.toFixed(2)}; - }, - }, - { - id: 'sma20', - header: 'SMA 20', - accessorKey: 'sma20', - size: 100, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'sma50', - header: 'SMA 50', - accessorKey: 'sma50', - size: 100, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'sma200', - header: 'SMA 200', - accessorKey: 'sma200', - size: 100, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'support', - header: 'Support', - accessorKey: 'support', - size: 100, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'resistance', - header: 'Resistance', - accessorKey: 'resistance', - size: 100, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'volatility', - header: 'Volatility', - accessorKey: 'volatility', - size: 100, - cell: ({ getValue }) => ( - {(getValue() as number).toFixed(1)}% - ), - }, - { - id: 'sharpe', - header: 'Sharpe', - accessorKey: 'sharpe', - size: 80, - cell: ({ getValue }) => ( - {(getValue() as number).toFixed(2)} - ), - }, - { - id: 'alpha', - header: 'Alpha', - accessorKey: 'alpha', - size: 80, - cell: ({ getValue }) => { - const value = getValue() as number; - const color = value > 0 ? 'text-success' : 'text-danger'; - return {value.toFixed(2)}; - }, - }, - { - id: 'correlation', - header: 'Correlation', - accessorKey: 'correlation', - size: 100, - cell: ({ getValue }) => ( - {(getValue() as number).toFixed(2)} - ), - }, - { - id: 'sector', - header: 'Sector', - accessorKey: 'sector', - size: 150, - cell: ({ getValue }) => {getValue() as string}, - }, - { - id: 'industry', - header: 'Industry', - accessorKey: 'industry', - size: 150, - cell: ({ getValue }) => {getValue() as string}, - }, - { - id: 'country', - header: 'Country', - accessorKey: 'country', - size: 100, - cell: ({ getValue }) => {getValue() as string}, - }, - { - id: 'exchange', - header: 'Exchange', - accessorKey: 'exchange', - size: 100, - cell: ({ getValue }) => {getValue() as string}, - }, - { - id: 'currency', - header: 'Currency', - accessorKey: 'currency', - size: 80, - cell: ({ getValue }) => ( - {getValue() as string} - ), - }, - { - id: 'lastUpdate', - header: 'Last Update', - accessorKey: 'lastUpdate', - size: 150, - cell: ({ getValue }) => ( - - {new Date(getValue() as string).toLocaleString()} - - ), - }, - { - id: 'analyst1', - header: 'Analyst 1', - accessorKey: 'analyst1', - size: 120, - cell: ({ getValue }) => ( - {getValue() as string} - ), - }, - { - id: 'analyst2', - header: 'Analyst 2', - accessorKey: 'analyst2', - size: 120, - cell: ({ getValue }) => ( - {getValue() as string} - ), - }, - { - id: 'analyst3', - header: 'Analyst 3', - accessorKey: 'analyst3', - size: 120, - cell: ({ getValue }) => ( - {getValue() as string} - ), - }, - { - id: 'rating1', - header: 'Rating 1', - accessorKey: 'rating1', - size: 80, - cell: ({ getValue }) => { - const value = getValue() as number; - const color = value >= 4 ? 'text-success' : value >= 3 ? 'text-warning' : 'text-danger'; - return {value.toFixed(1)}; - }, - }, - { - id: 'rating2', - header: 'Rating 2', - accessorKey: 'rating2', - size: 80, - cell: ({ getValue }) => { - const value = getValue() as number; - const color = value >= 4 ? 'text-success' : value >= 3 ? 'text-warning' : 'text-danger'; - return {value.toFixed(1)}; - }, - }, - { - id: 'rating3', - header: 'Rating 3', - accessorKey: 'rating3', - size: 80, - cell: ({ getValue }) => { - const value = getValue() as number; - const color = value >= 4 ? 'text-success' : value >= 3 ? 'text-warning' : 'text-danger'; - return {value.toFixed(1)}; - }, - }, - { - id: 'target1', - header: 'Target 1', - accessorKey: 'target1', - size: 100, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'target2', - header: 'Target 2', - accessorKey: 'target2', - size: 100, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'target3', - header: 'Target 3', - accessorKey: 'target3', - size: 100, - cell: ({ getValue }) => ( - ${(getValue() as number).toFixed(2)} - ), - }, - { - id: 'risk', - header: 'Risk Level', - accessorKey: 'risk', - size: 100, - cell: ({ getValue }) => { - const value = getValue() as string; - const color = - value === 'Low' ? 'text-success' : value === 'Medium' ? 'text-warning' : 'text-danger'; - return {value}; - }, - }, - { - id: 'esg', - header: 'ESG Score', - accessorKey: 'esg', - size: 100, - cell: ({ getValue }) => { - const value = getValue() as number; - const color = value >= 70 ? 'text-success' : value >= 40 ? 'text-warning' : 'text-danger'; - return {value.toFixed(0)}; - }, - }, - ]; - - return ( - {/* Handle row click */}} - className="border border-border rounded-lg" - /> - ); -} diff --git a/apps/stock/web-app/src/features/dashboard/components/index.ts b/apps/stock/web-app/src/features/dashboard/components/index.ts deleted file mode 100644 index fd33d83c..00000000 --- a/apps/stock/web-app/src/features/dashboard/components/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { DashboardStats } from './DashboardStats'; -export { DashboardActivity } from './DashboardActivity'; -export { PortfolioTable } from './PortfolioTable'; diff --git a/apps/stock/web-app/src/features/dashboard/index.ts b/apps/stock/web-app/src/features/dashboard/index.ts deleted file mode 100644 index d1e7bf22..00000000 --- a/apps/stock/web-app/src/features/dashboard/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { DashboardPage } from './DashboardPage'; diff --git a/apps/stock/web-app/src/lib/constants.ts b/apps/stock/web-app/src/lib/constants.ts index d5f0bc3e..4234493b 100644 --- a/apps/stock/web-app/src/lib/constants.ts +++ b/apps/stock/web-app/src/lib/constants.ts @@ -6,7 +6,6 @@ import { CircleStackIcon, CurrencyDollarIcon, DocumentTextIcon, - HomeIcon, ServerStackIcon, } from '@heroicons/react/24/outline'; @@ -18,7 +17,6 @@ export interface NavigationItem { } export const navigation: NavigationItem[] = [ - { name: 'Dashboard', href: '/dashboard', icon: HomeIcon }, { name: 'Market Data', icon: CurrencyDollarIcon, diff --git a/apps/stock/web-app/src/lib/constants/index.ts b/apps/stock/web-app/src/lib/constants/index.ts deleted file mode 100644 index 701e5050..00000000 --- a/apps/stock/web-app/src/lib/constants/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './navigation'; diff --git a/apps/stock/web-app/src/lib/constants/navigation.ts b/apps/stock/web-app/src/lib/constants/navigation.ts deleted file mode 100644 index 84474fca..00000000 --- a/apps/stock/web-app/src/lib/constants/navigation.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { - BeakerIcon, - BuildingOfficeIcon, - ChartBarIcon, - CogIcon, - CurrencyDollarIcon, - DocumentTextIcon, - HomeIcon, - ServerIcon, -} from '@heroicons/react/24/outline'; - -export const navigation = [ - { - name: 'Dashboard', - href: '/', - icon: HomeIcon, - current: true, - }, - { - name: 'Portfolio', - href: '/portfolio', - icon: CurrencyDollarIcon, - current: false, - }, - { - name: 'Analytics', - href: '/analytics', - icon: ChartBarIcon, - current: false, - }, - { - name: 'Backtest', - href: '/backtest', - icon: BeakerIcon, - current: false, - }, - { - name: 'Exchanges', - href: '/exchanges', - icon: BuildingOfficeIcon, - current: false, - }, - { - name: 'Reports', - href: '/reports', - icon: DocumentTextIcon, - current: false, - }, - { - name: 'System', - href: '/system/monitoring', - icon: ServerIcon, - current: false, - }, - { - name: 'Settings', - href: '/settings', - icon: CogIcon, - current: false, - }, -]; diff --git a/docs/development/architecture-cleanup-execution.md b/docs/development/architecture-cleanup-execution.md index 74cda42d..c350e56a 100644 --- a/docs/development/architecture-cleanup-execution.md +++ b/docs/development/architecture-cleanup-execution.md @@ -6,4 +6,6 @@ Agents use root-reserved disjoint files in the integration worktree. Root alone ## Completed changes -None yet. + + +- **CL24:** Root reviewed route compatibility, removed demo-only consumers and real App rendering. Focused home/navigation tests passed; scoped lint/format passed. Final browser gate pending combined source. diff --git a/docs/development/backlog/README.md b/docs/development/backlog/README.md index 774e88ae..029e20ef 100644 --- a/docs/development/backlog/README.md +++ b/docs/development/backlog/README.md @@ -1,6 +1,6 @@ # Canonical development backlog -**Active: E13 architecture cleanup, CL22–CL35 (0/14 complete).** Owner authorized all October 28 audit recommendations and a commit per validated task. Earlier completion counts below are historical. [Execution record](../architecture-cleanup-execution.md). +**Active: E13 architecture cleanup, CL22–CL35 (1/14 complete).** Owner authorized all October 28 audit recommendations and a commit per validated task. Earlier completion counts below are historical. [Execution record](../architecture-cleanup-execution.md). **Current scheduled backlog: 99/99 complete.** The owner resumed performance and authorized review of all seven conditions. P08 and O02 are implemented; five optional extensions remain deliberately deferred, and four merged IDs are redirects. This is not a claim that all 108 retained IDs were implemented. [Decisions, measurements and validation](../conditional-review.md). diff --git a/docs/development/backlog/manifest.json b/docs/development/backlog/manifest.json index 3b7b6d55..6e4d39b7 100644 --- a/docs/development/backlog/manifest.json +++ b/docs/development/backlog/manifest.json @@ -3786,7 +3786,7 @@ "epic": "E13", "priority": "P1", "severity": "High", - "status": "in_progress", + "status": "done", "dependencies": [], "decision_dependencies": [], "task_file": "backlog/tasks/CL24.md", @@ -3796,7 +3796,9 @@ "completed_commit": null, "blocker": null, "release_gates": [], - "completion_evidence": "architecture-cleanup-execution.md" + "completion_evidence": "architecture-cleanup-execution.md", + "integration_state": "accepted", + "validation": "Root reviewed route compatibility, removed demo-only consumers and real App rendering. Focused home/navigation tests passed; scoped lint/format passed. Final browser gate pending combined source." }, { "id": "CL25", @@ -10380,6 +10382,8 @@ "CL35" ], "work_policy": "Root integrates/commits reviewed tasks; agents own disjoint explicit files in the root integration worktree. Only root builds shared outputs and runs combined gates. No isolated native agent build claim.", - "first_wave": ["CL22", "CL23", "CL24"] + "first_wave": ["CL22", "CL23", "CL24"], + "completed": 1, + "last_verification": "Root reviewed route compatibility, removed demo-only consumers and real App rendering. Focused home/navigation tests passed; scoped lint/format passed. Final browser gate pending combined source." } } diff --git a/docs/development/backlog/tasks/CL24.md b/docs/development/backlog/tasks/CL24.md index 394cdfa3..8e6c0d89 100644 --- a/docs/development/backlog/tasks/CL24.md +++ b/docs/development/backlog/tasks/CL24.md @@ -18,3 +18,7 @@ Navigation/render regression and final browser workflows. Focused review/tests p No new service/framework, financial simulator, real trading activation, external research execution, push/PR or .env changes. D04/P03/P05/P06/CL21 remain deferred. Root owns shared outputs, task state and commits; agents own disjoint files in the integration worktree. + +## Accepted verification + +Root reviewed route compatibility, removed demo-only consumers and real App rendering. Focused home/navigation tests passed; scoped lint/format passed. Final browser gate pending combined source. diff --git a/test/integration/research-home.test.tsx b/test/integration/research-home.test.tsx new file mode 100644 index 00000000..7a4f2496 --- /dev/null +++ b/test/integration/research-home.test.tsx @@ -0,0 +1,106 @@ +import { afterAll, afterEach, beforeAll, beforeEach, expect, test } from 'bun:test'; +import { GlobalWindow } from 'happy-dom'; +import { act, createElement } from 'react'; +import type { Root } from 'react-dom/client'; + +const browser = new GlobalWindow({ url: 'http://localhost:5173' }); +const keys = ['window', 'document', 'fetch', 'ResizeObserver', 'IS_REACT_ACT_ENVIRONMENT'] as const; +const originals = new Map(keys.map(key => [key, Object.getOwnPropertyDescriptor(globalThis, key)])); +let createRoot: typeof import('react-dom/client').createRoot; +let App: typeof import('../../apps/stock/web-app/src/app/App').App; +let root: Root | undefined; +let host: HTMLDivElement; +let authenticated = true; +const paths: string[] = []; + +async function flush(action: () => void = () => {}) { + await act(async () => { + action(); + await Promise.resolve(); + }); +} + +beforeAll(async () => { + const values = { + window: browser, + document: browser.document, + ResizeObserver: browser.ResizeObserver, + IS_REACT_ACT_ENVIRONMENT: true, + }; + for (const [key, value] of Object.entries(values)) { + Object.defineProperty(globalThis, key, { configurable: true, value }); + } + ({ createRoot } = await import('react-dom/client')); + ({ App } = await import('../../apps/stock/web-app/src/app/App')); +}); + +beforeEach(() => { + authenticated = true; + paths.length = 0; + const request = async (input: RequestInfo | URL): Promise => { + const path = new URL( + typeof input === 'string' ? input : input instanceof URL ? input.href : input.url + ).pathname; + paths.push(path); + if (path === '/api/auth/session') { + return Response.json( + { authenticated, role: authenticated ? 'admin' : null }, + { status: authenticated ? 200 : 401 } + ); + } + if (path === '/api/v2/backtests') { + return Response.json([]); + } + throw new Error(`Unexpected home-page request: ${path}`); + }; + Object.defineProperty(globalThis, 'fetch', { configurable: true, value: request }); + browser.fetch = request as unknown as typeof browser.fetch; + const element = browser.document.createElement('div'); + browser.document.body.append(element); + host = element as unknown as HTMLDivElement; + root = createRoot(host); +}); + +afterEach(async () => { + await flush(() => root?.unmount()); + root = undefined; + host.remove(); +}); + +afterAll(() => { + for (const key of keys) { + const descriptor = originals.get(key); + if (descriptor) { + Object.defineProperty(globalThis, key, descriptor); + } else { + Reflect.deleteProperty(globalThis, key); + } + } + browser.happyDOM.abort(); +}); + +for (const path of ['/', '/dashboard', '/backtests']) { + test(`${path} opens the authenticated backtest workbench without demo portfolio data`, async () => { + browser.history.replaceState({}, '', path); + await flush(() => root!.render(createElement(App))); + expect(browser.location.pathname).toBe('/backtests'); + expect(paths).toEqual(['/api/auth/session', '/api/v2/backtests']); + expect(host.textContent).toContain('Create and manage backtest configurations'); + expect(host.textContent).toContain('No active backtests.'); + expect(host.textContent).toContain('New Backtest'); + expect(host.querySelector('a[href="/backtests"]')).not.toBeNull(); + expect(host.querySelector('a[href="/dashboard"]')).toBeNull(); + expect(host.textContent).not.toContain('Portfolio Value'); + expect(host.textContent).not.toContain('Market data loading...'); + expect(host.textContent).not.toContain('Welcome to Stock Bot Dashboard'); + }); +} + +test('the research home still requires a session before requesting saved backtests', async () => { + authenticated = false; + browser.history.replaceState({}, '', '/'); + await flush(() => root!.render(createElement(App))); + expect(host.textContent).toContain('Stock Bot access'); + expect(paths).toEqual(['/api/auth/session']); + expect(host.textContent).not.toContain('New Backtest'); +});