- Create PageHeader component with title, description, and action slots - Create StatCard component with trend indicators and icons - Update dashboard with KPI cards, Quick Actions, and Allocation Preview - Polish login page with branding and centered layout - Fix auth redirect: authenticated users accessing /login go to dashboard - Fix page refresh: auth state persists, no blank page - Fix sidebar: visible after login, toggle works, state persists - Fix CSS import: add app.css to layout, fix DaisyUI import path - Fix breadcrumbs: home icon links to /dashboard - Add comprehensive E2E and unit tests Refs: openspec/changes/p03-dashboard-enhancement Closes: p03-dashboard-enhancement
50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Dashboard Page', () => {
|
|
test.beforeEach(async ({ page }) => {
|
|
// Login first
|
|
await page.goto('/login');
|
|
await page.fill('input[type="email"]', 'admin@example.com');
|
|
await page.fill('input[type="password"]', 'password');
|
|
await page.click('button[type="submit"]');
|
|
|
|
// Wait for navigation to dashboard
|
|
await page.waitForURL('/dashboard');
|
|
});
|
|
|
|
test('dashboard renders correctly', async ({ page }) => {
|
|
// Check page title
|
|
await expect(page).toHaveTitle(/Dashboard/);
|
|
|
|
// Check PageHeader renders
|
|
await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
|
|
await expect(page.getByText('Overview of your resource allocation')).toBeVisible();
|
|
|
|
// Check New Allocation button
|
|
await expect(page.getByRole('button', { name: /New Allocation/i })).toBeVisible();
|
|
|
|
// Check all 4 StatCards render
|
|
await expect(page.getByText('Active Projects')).toBeVisible();
|
|
await expect(page.getByText('Team Members')).toBeVisible();
|
|
await expect(page.getByText('Allocations (hrs)')).toBeVisible();
|
|
await expect(page.getByText('Avg Utilization')).toBeVisible();
|
|
|
|
// Check stat values
|
|
await expect(page.getByText('14')).toBeVisible(); // Active Projects
|
|
await expect(page.getByText('8')).toBeVisible(); // Team Members
|
|
await expect(page.getByText('186')).toBeVisible(); // Allocations
|
|
await expect(page.getByText('87%')).toBeVisible(); // Avg Utilization
|
|
|
|
// Check Quick Actions section
|
|
await expect(page.getByRole('heading', { name: 'Quick Actions' })).toBeVisible();
|
|
await expect(page.getByRole('link', { name: /Team/i })).toBeVisible();
|
|
await expect(page.getByRole('link', { name: /Projects/i })).toBeVisible();
|
|
await expect(page.getByRole('link', { name: /Allocate/i })).toBeVisible();
|
|
await expect(page.getByRole('link', { name: /Forecast/i })).toBeVisible();
|
|
|
|
// Check Allocation Preview section
|
|
await expect(page.getByRole('heading', { name: 'Allocation Preview' })).toBeVisible();
|
|
await expect(page.getByText(/Allocation matrix for/)).toBeVisible();
|
|
});
|
|
});
|