import { test, expect } from '@playwright/test'; test.describe('Projects 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"]'); await page.waitForURL('/dashboard'); // Navigate to projects await page.goto('/projects'); }); test('page renders with title and table', async ({ page }) => { await expect(page).toHaveTitle(/Projects/); await expect(page.locator('h1', { hasText: 'Projects' })).toBeVisible(); await expect(page.getByText('Manage project lifecycle')).toBeVisible(); await expect(page.getByRole('button', { name: /New Project/i })).toBeVisible(); }); test('search filters projects', async ({ page }) => { // Wait for the table to render (not loading state) await expect(page.locator('table tbody tr').first()).toBeVisible({ timeout: 5000 }); // Get initial row count const initialRows = await page.locator('table tbody tr').count(); expect(initialRows).toBeGreaterThan(0); // Search for specific project await page.fill('input[placeholder="Search projects..."]', 'Website'); await page.waitForTimeout(300); // Should show fewer or equal rows after filtering const filteredRows = await page.locator('table tbody tr').count(); expect(filteredRows).toBeLessThanOrEqual(initialRows); }); test('status filter works', async ({ page }) => { // Wait for the table to render (not loading state) await expect(page.locator('table tbody tr').first()).toBeVisible({ timeout: 5000 }); // Get initial row count const initialRows = await page.locator('table tbody tr').count(); // Select status filter await page.selectOption('select >> nth=0', 'In Progress'); await page.waitForTimeout(300); // Should show filtered results (fewer or equal rows) const filteredRows = await page.locator('table tbody tr').count(); expect(filteredRows).toBeLessThanOrEqual(initialRows); }); });