Test Types
Functional Tests
Test complete user workflows and feature interactions.
What Are Functional Tests?
Functional tests verify that features work correctly from the user's perspective. They test complete workflows like login, form submission, or data manipulation.
Example Generated Test
test_login_flow.spec.ts
1import { test, expect } from '@playwright/test';2 3test.describe('Login Flow', () => {4 test('should login with valid credentials', async ({ page }) => {5 await page.goto('/login');6 7 // Fill login form8 await page.fill('[name="email"]', 'user@example.com');9 await page.fill('[name="password"]', 'password123');10 11 // Submit form12 await page.click('[type="submit"]');13 14 // Verify redirect to dashboard15 await expect(page).toHaveURL('/dashboard');16 await expect(page.locator('.welcome-message')).toContainText('Welcome');17 });18 19 test('should show error for invalid credentials', async ({ page }) => {20 await page.goto('/login');21 22 await page.fill('[name="email"]', 'wrong@example.com');23 await page.fill('[name="password"]', 'wrongpassword');24 await page.click('[type="submit"]');25 26 await expect(page.locator('.error-message')).toBeVisible();27 await expect(page.locator('.error-message')).toContainText('Invalid');28 });29});Common Workflows Tested
- User registration and onboarding
- Login and authentication flows
- Form submissions and validation
- Search and filtering
- CRUD operations
Generate Functional Tests
bash
1curl -X POST http://localhost:3000/api/brain/generate-test \2 -H "Content-Type: application/json" \3 -d '{4 "type": "functional",5 "target": "User login flow with email and password"6 }'