44 lines
1.5 KiB
JavaScript
44 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const root = path.join(__dirname, '..');
|
|
const appSource = fs.readFileSync(path.join(root, 'public', 'app.js'), 'utf8');
|
|
const operationsSource = fs.readFileSync(path.join(root, 'src', 'routes', 'operations.js'), 'utf8');
|
|
const databaseSource = fs.readFileSync(path.join(root, 'src', 'core', 'database.js'), 'utf8');
|
|
|
|
assert.match(
|
|
appSource,
|
|
/taskType === 'aistudio_combo'[\s\S]{0,300}accountEmails:\s*taskAccounts\.map/,
|
|
'AI Studio 一键组合必须只提交邮箱引用,不能上传完整账号对象',
|
|
);
|
|
assert.match(
|
|
operationsSource,
|
|
/taskType === 'aistudio_combo'[\s\S]{0,120}Array\.isArray\(req\.body\.accountEmails\)/,
|
|
'服务端必须接受 AI Studio 邮箱引用列表',
|
|
);
|
|
assert.match(
|
|
operationsSource,
|
|
/db\.getAccountsByEmails\(requestedEmails\)/,
|
|
'服务端必须从数据库重新加载完整账号',
|
|
);
|
|
assert.match(
|
|
databaseSource,
|
|
/for \(let i = 0; i < normalizedEmails\.length; i \+= 200\)/,
|
|
'批量账号查询必须分块,避免 SQLite 绑定参数上限',
|
|
);
|
|
|
|
const emailOnlyPayload = {
|
|
taskType: 'aistudio_combo',
|
|
accountEmails: Array.from({ length: 10513 }, (_, index) => `account-${index}@example.com`),
|
|
params: { threadCount: 1 },
|
|
};
|
|
assert(
|
|
Buffer.byteLength(JSON.stringify(emailOnlyPayload), 'utf8') < 10 * 1024 * 1024,
|
|
'10513 个邮箱的 AI Studio 请求必须低于 10MB',
|
|
);
|
|
|
|
console.log('aistudio large batch request tests passed');
|