Files
CyberStrikeAI/web/static/js/settings-eino-resilience.test.cjs
T
2026-08-15 01:33:33 +08:00

54 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const root = process.cwd();
const settings = fs.readFileSync(path.join(root, 'web/static/js/settings.js'), 'utf8');
const template = fs.readFileSync(path.join(root, 'web/templates/index.html'), 'utf8');
const zh = JSON.parse(fs.readFileSync(path.join(root, 'web/static/i18n/zh-CN.json'), 'utf8'));
const en = JSON.parse(fs.readFileSync(path.join(root, 'web/static/i18n/en-US.json'), 'utf8'));
test('Eino 模型 retry/failover 设置页读写链路完整', () => {
[
'eino-model-retry-max-retries',
'eino-model-retry-max-backoff-sec',
'eino-model-failover-channels',
'eino-model-failover-max-retries'
].forEach((id) => {
assert.match(template, new RegExp(`id="${id}"`));
assert.match(settings, new RegExp(`getElementById\\('${id}'\\)`));
});
[
'model_retry_max_retries',
'model_retry_max_backoff_sec',
'model_failover_channels',
'model_failover_max_retries'
].forEach((key) => {
assert.match(settings, new RegExp(`${key}`));
});
assert.match(settings, /failoverChannelsRaw\.split\(\s*\/\[\\n,\]\//);
assert.match(settings, /Array\.from\(new Set\(/);
});
test('Eino 模型 retry/failover 设置项有中英文文案', () => {
[
'einoModelRetryMaxRetries',
'einoModelRetryMaxRetriesHint',
'einoModelRetryMaxBackoffSec',
'einoModelRetryMaxBackoffSecHint',
'einoModelFailoverChannels',
'einoModelFailoverChannelsPlaceholder',
'einoModelFailoverChannelsHint',
'einoModelFailoverMaxRetries',
'einoModelFailoverMaxRetriesHint'
].forEach((key) => {
assert.equal(typeof zh.settingsBasic[key], 'string', `zh ${key}`);
assert.ok(zh.settingsBasic[key].length > 0, `zh ${key} is empty`);
assert.equal(typeof en.settingsBasic[key], 'string', `en ${key}`);
assert.ok(en.settingsBasic[key].length > 0, `en ${key} is empty`);
});
});