51 lines
1.9 KiB
JavaScript
51 lines
1.9 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import path from 'node:path';
|
|
import test from 'node:test';
|
|
import { fileURLToPath } from 'node:url';
|
|
import {
|
|
buildPublicSkillRuntimeConfig,
|
|
buildSkillRuntimeCatalogSummary,
|
|
} from './skill-runtime-policy.mjs';
|
|
import { buildAutoChatSkillPrefixOptions } from './chat-skills.mjs';
|
|
|
|
const h5Root = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
test('buildPublicSkillRuntimeConfig omits manifest routes when disabled', () => {
|
|
const config = buildPublicSkillRuntimeConfig(
|
|
{ router: { v2Enabled: false, manifestRoutingEnabled: false } },
|
|
h5Root,
|
|
);
|
|
assert.equal(config.routerV2Enabled, false);
|
|
assert.equal(config.manifestRoutingEnabled, false);
|
|
assert.deepEqual(config.manifestRoutes, []);
|
|
});
|
|
|
|
test('buildSkillRuntimeCatalogSummary includes product-campaign-page manifest', () => {
|
|
const catalog = buildSkillRuntimeCatalogSummary(h5Root);
|
|
const product = catalog.find((item) => item.name === 'product-campaign-page');
|
|
assert.ok(product);
|
|
assert.equal(product.hasManifest, true);
|
|
assert.ok(product.triggerKeywords.includes('带货'));
|
|
});
|
|
|
|
test('buildSkillRuntimeCatalogSummary includes Excel Analyst manifest for MemindAdm', () => {
|
|
const catalog = buildSkillRuntimeCatalogSummary(h5Root);
|
|
const excel = catalog.find((item) => item.name === 'excel-analyst');
|
|
assert.ok(excel);
|
|
assert.equal(excel.hasManifest, true);
|
|
assert.equal(excel.version, '0.2.0');
|
|
assert.ok(excel.triggerKeywords.includes('分析Excel'));
|
|
assert.equal(excel.routerPromptKey, 'excel-analyst');
|
|
});
|
|
|
|
test('buildAutoChatSkillPrefixOptions returns empty object when router is disabled', () => {
|
|
assert.deepEqual(
|
|
buildAutoChatSkillPrefixOptions({
|
|
routerV2Enabled: false,
|
|
manifestRoutingEnabled: false,
|
|
manifestRoutes: [{ skillName: 'web', keywords: ['新闻'], priority: 1, promptKey: 'web', promptVariant: null }],
|
|
}),
|
|
{},
|
|
);
|
|
});
|