feat: 重构测试框架并优化代码结构
refactor(tests): 将e2e_tests迁移到tests_suite和api_integration_tests style: 为Java类添加文档注释 docs: 更新.gitignore和配置文件 test: 添加性能测试和Playwright测试脚本 chore: 清理旧测试文件和配置
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('用户认证 E2E 测试', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/login');
|
||||
});
|
||||
|
||||
test('成功登录流程', async ({ page }) => {
|
||||
await expect(page).toHaveTitle(/登录/);
|
||||
|
||||
await page.fill('input[placeholder*="用户名"]', 'admin');
|
||||
await page.fill('input[type="password"]', 'admin123');
|
||||
|
||||
await page.click('button:has-text("登录")');
|
||||
|
||||
await page.waitForURL('**/dashboard');
|
||||
await expect(page.locator('.user-info')).toContainText('admin');
|
||||
});
|
||||
|
||||
test('登录失败 - 无效凭证', async ({ page }) => {
|
||||
await page.fill('input[placeholder*="用户名"]', 'invalid');
|
||||
await page.fill('input[type="password"]', 'invalid');
|
||||
|
||||
await page.click('button:has-text("登录")');
|
||||
|
||||
await expect(page.locator('.error-message')).toBeVisible();
|
||||
await expect(page.locator('.error-message')).toContainText('用户名或密码错误');
|
||||
});
|
||||
|
||||
test('登录失败 - 缺少必填字段', async ({ page }) => {
|
||||
await page.fill('input[name="username"]', 'admin');
|
||||
|
||||
await page.click('button[type="submit"]');
|
||||
|
||||
await expect(page.locator('.error-message')).toBeVisible();
|
||||
});
|
||||
|
||||
test('登出流程', async ({ page }) => {
|
||||
await page.fill('input[name="username"]', 'admin');
|
||||
await page.fill('input[name="password"]', 'admin123');
|
||||
await page.click('button[type="submit"]');
|
||||
|
||||
await page.waitForURL('**/');
|
||||
|
||||
await page.click('text=登出');
|
||||
|
||||
await page.waitForURL('**/login');
|
||||
await expect(page).toHaveTitle(/登录/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user