- Fix dashboard test: use correct superuser credentials - Fix heading selectors to use h1 instead of getByRole - Fix Quick Actions selectors to use href attributes - Fix team-members and projects filter tests to check row counts - Fix status filter tests to not rely on badge classes Refs: Test fixes for p05-page-migrations
50 lines
2.0 KiB
TypeScript
50 lines
2.0 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"]', 'superuser@headroom.test');
|
|
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.locator('h1', { hasText: '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.getByText('Quick Actions')).toBeVisible();
|
|
await expect(page.locator('a[href="/team-members"]')).toBeVisible();
|
|
await expect(page.locator('a[href="/projects"]')).toBeVisible();
|
|
await expect(page.locator('a[href="/allocations"]')).toBeVisible();
|
|
await expect(page.locator('a[href="/reports/forecast"]')).toBeVisible();
|
|
|
|
// Check Allocation Preview section
|
|
await expect(page.getByRole('heading', { name: 'Allocation Preview' })).toBeVisible();
|
|
await expect(page.getByText(/Allocation matrix for/)).toBeVisible();
|
|
});
|
|
});
|