Files
headroom/frontend/tests/e2e/team-members.spec.ts
Santhosh Janardhanan 5422a324fc fix(e2e): Fix 12 failing E2E tests - DataTable reactivity and selector issues
- Fix DataTable reactivity: use $derived with getters for data/columns props
- Fix auth.spec.js: open user dropdown before clicking Logout button
- Fix dashboard.spec.ts: scope selectors to layout-content, use exact matches
- Fix layout.spec.ts: clear localStorage before breakpoint tests, wait for focus
- Fix projects/team-members.spec.ts: wait for table rows to be visible

Root causes:
1. DataTable options object captured initial empty array, not reactive updates
2. Selectors matched multiple elements (sidebar, user menu, main content)
3. Dropdown menus need to be opened before clicking items
4. Keyboard shortcuts need element focus

All 94 tests now pass (47 chromium + 47 firefox)
2026-02-18 19:53:12 -05:00

56 lines
2.0 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('Team Members 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 team members
await page.goto('/team-members');
});
test('page renders with title and table', async ({ page }) => {
await expect(page).toHaveTitle(/Team Members/);
await expect(page.locator('h1', { hasText: 'Team Members' })).toBeVisible();
await expect(page.getByText('Manage your team roster')).toBeVisible();
await expect(page.getByRole('button', { name: /Add Member/i })).toBeVisible();
});
test('search filters team members', 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 member
await page.fill('input[placeholder="Search team members..."]', 'Alice');
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 active filter
await page.selectOption('select', 'active');
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);
});
});