5de58af9ed
Use a lightweight LLM over active task lists to pick taskId for cancel, exclude page.generate from scheduled-task inbound, and remove single-task auto-cancel so Cursor page generation stays isolated. Co-authored-by: Cursor <cursoragent@cursor.com>
57 lines
2.0 KiB
JavaScript
57 lines
2.0 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
createWechatScheduledTaskManageLlmConfigService,
|
|
wechatScheduledTaskManageLlmConfigInternals,
|
|
} from './wechat-scheduled-task-manage-llm-config.mjs';
|
|
|
|
function createPool(seedRow = null) {
|
|
const state = { row: seedRow };
|
|
return {
|
|
async query(sql, params) {
|
|
if (sql.includes('CREATE TABLE')) return [[], []];
|
|
if (sql.includes('SELECT config_json')) {
|
|
return [state.row ? [state.row] : [], []];
|
|
}
|
|
if (sql.includes('INSERT INTO h5_wechat_admin_config')) {
|
|
state.row = {
|
|
config_json: params[1],
|
|
updated_by: params[2],
|
|
updated_at: params[3],
|
|
};
|
|
return [[], []];
|
|
}
|
|
throw new Error(`Unexpected query: ${sql}`);
|
|
},
|
|
};
|
|
}
|
|
|
|
test('scheduled task manage llm config defaults to enabled', async () => {
|
|
const service = createWechatScheduledTaskManageLlmConfigService(createPool(), {
|
|
env: {},
|
|
});
|
|
const result = await service.getConfig();
|
|
assert.equal(result.manageLlmEnabled, true);
|
|
});
|
|
|
|
test('scheduled task manage llm config persists admin toggle', async () => {
|
|
const service = createWechatScheduledTaskManageLlmConfigService(createPool(), {
|
|
env: { H5_WECHAT_SCHEDULED_TASK_MANAGE_LLM_ENABLED: '0' },
|
|
});
|
|
const updated = await service.updateConfig({ manageLlmEnabled: true }, { updatedBy: 'admin-1' });
|
|
assert.equal(updated.manageLlmEnabled, true);
|
|
assert.equal(updated.updatedBy, 'admin-1');
|
|
assert.equal(await service.isManageLlmEnabled(), true);
|
|
});
|
|
|
|
test('scheduled task manage llm config internals normalize booleans consistently', () => {
|
|
assert.equal(wechatScheduledTaskManageLlmConfigInternals.normalizeBoolean('1', false), true);
|
|
assert.equal(wechatScheduledTaskManageLlmConfigInternals.normalizeBoolean('off', true), false);
|
|
assert.equal(
|
|
wechatScheduledTaskManageLlmConfigInternals.defaultsFromEnv({
|
|
H5_WECHAT_SCHEDULED_TASK_MANAGE_LLM_ENABLED: 'false',
|
|
}).manageLlmEnabled,
|
|
false,
|
|
);
|
|
});
|