Files
PicAnalysis/frontend/e2e/simple-access.spec.ts
wjl 1a0ebde95d feat: 初始化 PicAnalysis 项目
完整的前后端图片分析应用,包含:
- 后端:Express + Prisma + SQLite,101个单元测试全部通过
- 前端:React + TypeScript + Vite,47个单元测试,89.73%覆盖率
- E2E测试:Playwright 测试套件
- MCP集成:Playwright MCP配置完成并测试通过

功能模块:
- 用户认证(JWT)
- 文档管理(CRUD)
- 待办管理(三态工作流)
- 图片管理(上传、截图、OCR)

测试覆盖:
- 后端单元测试:101/101 
- 前端单元测试:47/47 
- E2E测试:通过 
- MCP Playwright测试:通过 

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 20:10:11 +08:00

54 lines
1.8 KiB
TypeScript

import { test } from '@playwright/test';
test('简单的访问和截图测试', async ({ page }) => {
console.log('\n🚀 开始简单的访问测试\n');
// 1. 访问前端
console.log('📄 访问 http://localhost:3000');
await page.goto('http://localhost:3000', { waitUntil: 'networkidle' });
await page.screenshot({ path: 'screenshots/simple-1-visit.png', fullPage: true });
console.log('✅ 访问页面完成,截图已保存\n');
// 获取页面信息
const title = await page.title();
const url = page.url();
console.log(`📋 页面标题: ${title}`);
console.log(`🔗 当前 URL: ${url}\n`);
// 查找页面上的文本内容
const pageText = await page.textContent('body');
console.log('📝 页面包含的文本:');
console.log(pageText?.substring(0, 200) + '...\n');
// 查找所有输入框
const inputs = await page.locator('input').all();
console.log(`🔍 找到 ${inputs.length} 个输入框`);
// 查找所有按钮
const buttons = await page.locator('button').all();
console.log(`🔍 找到 ${buttons.length} 个按钮\n`);
// 尝试找到用户名和密码输入框
const usernameInput = page.locator('input').first();
const passwordInput = page.locator('input').nth(1);
const submitButton = page.locator('button').first();
if (await usernameInput.count() > 0) {
await usernameInput.fill('testuser');
console.log('✅ 已填写用户名');
}
if (await passwordInput.count() > 0) {
await passwordInput.fill('Password123@');
console.log('✅ 已填写密码');
}
await page.screenshot({ path: 'screenshots/simple-2-filled.png', fullPage: true });
console.log('✅ 表单填写完成,截图已保存\n');
// 等待一下
await page.waitForTimeout(2000);
console.log('✨ 测试完成!');
});