完整的前后端图片分析应用,包含: - 后端: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>
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
/**
|
|
* 测试后端 API 编码
|
|
*/
|
|
const axios = require('axios');
|
|
|
|
async function testEncoding() {
|
|
try {
|
|
// 首先登录
|
|
console.log('1. 登录...');
|
|
const loginResponse = await axios.post('http://localhost:4000/api/auth/login', {
|
|
username: 'testuser',
|
|
password: 'Password123@'
|
|
});
|
|
|
|
const token = loginResponse.data.data.token;
|
|
console.log('✅ 登录成功');
|
|
|
|
// 获取文档
|
|
console.log('\n2. 获取文档...');
|
|
const docsResponse = await axios.get('http://localhost:4000/api/documents', {
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
|
|
console.log('响应头:', docsResponse.headers['content-type']);
|
|
console.log('响应数据:', JSON.stringify(docsResponse.data, null, 2));
|
|
|
|
// 检查中文字符
|
|
if (docsResponse.data.data && docsResponse.data.data.length > 0) {
|
|
const firstDoc = docsResponse.data.data[0];
|
|
console.log('\n第一个文档:');
|
|
console.log(' 标题:', firstDoc.title);
|
|
console.log(' 内容:', firstDoc.content?.substring(0, 50));
|
|
|
|
// 检查编码
|
|
const hasChinese = /[\u4e00-\u9fa5]/.test(firstDoc.title + firstDoc.content);
|
|
console.log(' 包含中文:', hasChinese ? '是' : '否');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ 错误:', error.message);
|
|
if (error.response) {
|
|
console.error('响应数据:', error.response.data);
|
|
}
|
|
}
|
|
}
|
|
|
|
testEncoding();
|