51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
/**
|
|
* 认证流程 E2E 测试
|
|
*/
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Authentication Flow', () => {
|
|
test('should complete login flow', async ({ page }) => {
|
|
await page.goto('/login');
|
|
|
|
// 填写表单
|
|
await page.fill('input[placeholder="邮箱"]', 'test@example.com');
|
|
await page.fill('input[placeholder="密码"]', 'Password123!');
|
|
|
|
// 点击登录
|
|
await page.click('button:has-text("登录")');
|
|
|
|
// 验证跳转到工作空间页面
|
|
await expect(page).toHaveURL('/workspaces');
|
|
await expect(page.locator('h1')).toContainText('工作空间');
|
|
});
|
|
|
|
test('should complete registration flow', async ({ page }) => {
|
|
await page.goto('/register');
|
|
|
|
// 填写注册表单
|
|
await page.fill('input[placeholder="用户名"]', 'newuser');
|
|
await page.fill('input[placeholder="邮箱"]', 'newuser@example.com');
|
|
await page.fill('input[placeholder="密码"]', 'Password123!');
|
|
await page.fill('input[placeholder="确认密码"]', 'Password123!');
|
|
|
|
// 点击注册
|
|
await page.click('button:has-text("注册")');
|
|
|
|
// 验证成功消息
|
|
await expect(page.locator('.ant-message-success')).toBeVisible();
|
|
});
|
|
|
|
test('should handle forgot password', async ({ page }) => {
|
|
await page.goto('/forgot-password');
|
|
|
|
// 填写邮箱
|
|
await page.fill('input[placeholder="邮箱"]', 'test@example.com');
|
|
|
|
// 点击发送
|
|
await page.click('button:has-text("发送重置邮件")');
|
|
|
|
// 验证成功消息
|
|
await expect(page.locator('text=重置邮件已发送')).toBeVisible();
|
|
});
|
|
});
|