import { test, expect } from '@playwright/test'; import { login } from './helpers/auth'; test.describe('Leads', () => { test.beforeEach(async ({ page }) => { await login(page); await page.goto('/leads'); }); test('leads page renders with pipeline summary', async ({ page }) => { await expect(page.locator('h1:has-text("Leads")')).toBeVisible(); }); test('leads list loads', async ({ page }) => { await page.waitForTimeout(2000); // Either shows rows or empty state const hasRows = await page.locator('tbody tr').count(); const hasEmpty = await page.locator('text=No leads').isVisible().catch(() => false); expect(hasRows > 0 || hasEmpty).toBeTruthy(); }); test('Add Lead modal opens and closes', async ({ page }) => { const addBtn = page.locator('button:has-text("Add Lead")'); if (await addBtn.isVisible()) { await addBtn.click(); await page.waitForTimeout(300); await expect(page.locator('text=Add Lead, text=New Lead').first()).toBeVisible(); await page.keyboard.press('Escape'); } }); });