- 新增部署脚本 `build-deploy-bundle.mjs`,用于构建和部署 web 和 server 目录。 - 新增样式文件 `index-acd65452.css`,包含基础样式和响应式设计。 - 新增脚本 `repro-import-text.mjs`,用于测试文本导入 API。 - 新增测试文件 `db-migration-score-zero.test.ts`,验证历史数据库中 questions.score 约束的迁移逻辑。 - 更新数据库初始化逻辑,允许插入 score=0 的问题。
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
process.env.NODE_ENV = 'test';
|
|
process.env.DB_PATH = ':memory:';
|
|
|
|
const { initDatabase } = await import('../api/database');
|
|
await initDatabase();
|
|
|
|
const { app } = await import('../api/server');
|
|
|
|
const server = app.listen(0);
|
|
const addr = server.address();
|
|
const baseUrl = `http://127.0.0.1:${addr.port}`;
|
|
|
|
try {
|
|
const body = {
|
|
mode: 'incremental',
|
|
questions: [
|
|
{
|
|
content:
|
|
'【文字描述题】请简述你对公司“只服务渠道客户,不直接做甲方项目(除深圳周边近的)”这一政策的理解。',
|
|
type: 'text',
|
|
category: '通用',
|
|
score: 0,
|
|
answer: '',
|
|
analysis: '用于人工评阅,关注对渠道保护、资源倾斜、合作共赢等理念的理解。',
|
|
},
|
|
],
|
|
};
|
|
|
|
const res = await fetch(`${baseUrl}/api/questions/import-text`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(body),
|
|
});
|
|
|
|
const text = await res.text();
|
|
console.log('status:', res.status);
|
|
console.log(text);
|
|
} finally {
|
|
await new Promise((resolve) => server.close(resolve));
|
|
}
|