mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-24 09:25:21 +08:00
fix(pipeline): decouple Runner from extension permissions (LANG-54) (#2723)
* fix(pipeline): decouple runner from extension allowlist Co-authored-by: multica-agent <[email protected]> * fix(pipeline): complete runner diagnostics and real runtime coverage Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: multica-agent <[email protected]>
This commit is contained in:
co-authored by
multica-agent
parent
5a6ddbff6f
commit
d9e4e7d9df
@@ -0,0 +1,61 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import test from 'node:test';
|
||||
import ts from 'typescript';
|
||||
|
||||
test('Runner diagnosis and draft-safe repair have all eight complete catalogs', () => {
|
||||
const locales = [
|
||||
'en-US',
|
||||
'zh-Hans',
|
||||
'zh-Hant',
|
||||
'ja-JP',
|
||||
'es-ES',
|
||||
'ru-RU',
|
||||
'th-TH',
|
||||
'vi-VN',
|
||||
];
|
||||
const expected = ['disabled', 'draft', 'missing', 'repair', 'runtime'];
|
||||
for (const locale of locales) {
|
||||
const source = fs.readFileSync(
|
||||
new URL(`../../src/i18n/locales/${locale}.ts`, import.meta.url),
|
||||
'utf8',
|
||||
);
|
||||
const ast = ts.createSourceFile(
|
||||
`${locale}.ts`,
|
||||
source,
|
||||
ts.ScriptTarget.Latest,
|
||||
true,
|
||||
);
|
||||
const found = [];
|
||||
function visit(node) {
|
||||
if (
|
||||
ts.isPropertyAssignment(node) &&
|
||||
node.name.getText(ast) === 'runnerDiagnosis'
|
||||
) {
|
||||
assert.ok(ts.isObjectLiteralExpression(node.initializer), locale);
|
||||
const fields = node.initializer.properties;
|
||||
assert.deepEqual(
|
||||
fields.map((field) => field.name.getText(ast)).sort(),
|
||||
expected,
|
||||
locale,
|
||||
);
|
||||
for (const field of fields) {
|
||||
assert.ok(
|
||||
ts.isStringLiteral(field.initializer) &&
|
||||
field.initializer.text.trim(),
|
||||
locale,
|
||||
);
|
||||
assert.equal(
|
||||
field.initializer.text.match(/{{[^}]+}}/g),
|
||||
null,
|
||||
locale,
|
||||
);
|
||||
}
|
||||
found.push(node);
|
||||
}
|
||||
ts.forEachChild(node, visit);
|
||||
}
|
||||
visit(ast);
|
||||
assert.equal(found.length, 1, locale);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user