mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-27 20:57:13 +00:00
be3734ffda
* feat(wizard): rework agent onboarding flow * fix(web): support LAN development access * fix(wizard): parse ranked model selection entries * feat(wizard): add inbound bot verification * feat(wizard): add floating page bot verification * fix(wizard): repair HTTP bot inbound test setup * feat(wizard): streamline custom model onboarding * feat(wizard): label page bot test preview * style(space): apply ruff formatting * fix(wizard): polish AI engine onboarding * fix(wizard): clarify local account message test * feat(wizard): animate AI engine transitions * fix(wizard): align AI engine setup headers --------- Co-authored-by: langbot-dev <langbot@users.noreply.github.com> Co-authored-by: RockChinQ <rockchinq@gmail.com>
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import test from 'node:test';
|
|
import ts from 'typescript';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const currentDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
const sourcePath = path.resolve(
|
|
currentDirectory,
|
|
'../../src/app/infra/entities/adapter-categories.ts',
|
|
);
|
|
|
|
function loadCategoryHelpers(language = 'zh-Hans') {
|
|
const source = fs.readFileSync(sourcePath, 'utf8');
|
|
const compiled = ts.transpileModule(source, {
|
|
compilerOptions: {
|
|
esModuleInterop: true,
|
|
module: ts.ModuleKind.CommonJS,
|
|
target: ts.ScriptTarget.ES2020,
|
|
},
|
|
}).outputText;
|
|
const loadedModule = { exports: {} };
|
|
new Function('require', 'module', 'exports', compiled)(
|
|
(name) => {
|
|
if (name === 'i18next') return { language };
|
|
throw new Error(`Unexpected runtime import: ${name}`);
|
|
},
|
|
loadedModule,
|
|
loadedModule.exports,
|
|
);
|
|
return loadedModule.exports;
|
|
}
|
|
|
|
test('places an adapter only once when metadata repeats a category', () => {
|
|
const { groupByCategory } = loadCategoryHelpers();
|
|
const adapter = { name: 'http_bot', categories: ['popular', 'popular'] };
|
|
|
|
assert.deepEqual(groupByCategory([adapter]), [
|
|
{ categoryId: 'popular', items: [adapter] },
|
|
]);
|
|
});
|