Files
memind/skills-registry.test.mjs
T
john fde6503bdf
Memind CI / Test, build, and release guards (push) Has been cancelled
feat(mindspace): add SEO/GEO delivery, page template catalog, and admin hooks
Enable optional SEO/GEO injection and discovery routes for confirmed public pages while keeping private pages noindex. Add premium page template skills, portal catalog API, template shop UI, and Baidu push gated by memind_adm config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 08:06:12 +08:00

88 lines
3.8 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
applySkillGrantsToCapabilities,
DEFAULT_USER_SKILLS,
listPlatformSkillCatalog,
normalizeSkillPatch,
resolveSkillMap,
USER_ROLE_SKILL_PRESETS,
} from './skills-registry.mjs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const h5Root = path.dirname(fileURLToPath(import.meta.url));
test('lists static-page-publish in platform catalog', () => {
const catalog = listPlatformSkillCatalog(h5Root);
assert.ok(catalog.some((item) => item.name === 'static-page-publish'));
assert.ok(catalog.some((item) => item.name === 'page-data-collect'));
assert.ok(catalog.some((item) => item.name === 'schedule-assistant'));
assert.ok(catalog.some((item) => item.name === 'scheduled-task-automation'));
assert.ok(catalog.some((item) => item.name === 'service-integration-smoke'));
assert.ok(catalog.some((item) => item.name === 'product-campaign-page'));
assert.ok(catalog.some((item) => item.name === 'long-image-download'));
const imageGeneration = catalog.find((item) => item.name === 'image-generation');
assert.ok(imageGeneration);
assert.ok(imageGeneration.manifest.trigger.keywords.includes('AI配图'));
assert.equal(imageGeneration.manifest.router.promptKey, 'image-generation');
assert.ok(catalog.some((item) => item.name === 'excel-analyst'));
const aiderDevelopment = catalog.find((item) => item.name === 'aider-development');
assert.ok(aiderDevelopment);
assert.deepEqual(aiderDevelopment.executors, ['aider']);
});
test('granting page-data-collect enables static_publish capability', () => {
const caps = applySkillGrantsToCapabilities(
{ static_publish: false, skills: false },
{ 'page-data-collect': true },
);
assert.equal(caps.static_publish, true);
assert.equal(caps.skills, true);
});
test('granting publish skill enables static_publish capability', () => {
const caps = applySkillGrantsToCapabilities(
{ static_publish: false, skills: false },
{ 'static-page-publish': true },
);
assert.equal(caps.static_publish, true);
assert.equal(caps.skills, true);
});
test('resolveSkillMap prefers user overrides', () => {
const catalog = listPlatformSkillCatalog(h5Root);
const resolved = resolveSkillMap(
{ 'static-page-publish': false },
{ 'static-page-publish': true },
catalog,
);
assert.equal(resolved['static-page-publish'], true);
});
test('normalizeSkillPatch ignores unknown skills', () => {
const catalog = listPlatformSkillCatalog(h5Root);
assert.deepEqual(normalizeSkillPatch(catalog, { unknown: true }), {});
});
test('DEFAULT_USER_SKILLS enables common platform skills', () => {
assert.equal(DEFAULT_USER_SKILLS.web, true);
assert.equal(DEFAULT_USER_SKILLS.search, true);
assert.equal(DEFAULT_USER_SKILLS['schedule-assistant'], true);
assert.equal(DEFAULT_USER_SKILLS['scheduled-task-automation'], true);
assert.equal(DEFAULT_USER_SKILLS['service-integration-smoke'], true);
assert.equal(DEFAULT_USER_SKILLS['form-builder'], true);
assert.equal(DEFAULT_USER_SKILLS['table-viewer'], true);
assert.equal(DEFAULT_USER_SKILLS['product-campaign-page'], true);
assert.equal(DEFAULT_USER_SKILLS['long-image-download'], true);
assert.equal(DEFAULT_USER_SKILLS['image-generation'], true);
assert.equal(DEFAULT_USER_SKILLS['page-data-collect'], true);
assert.equal(DEFAULT_USER_SKILLS['static-page-publish'], false);
assert.equal(DEFAULT_USER_SKILLS['page-template-travel'], false);
assert.equal(DEFAULT_USER_SKILLS['page-template-campaign'], false);
assert.equal(DEFAULT_USER_SKILLS['page-template-survey'], false);
assert.equal(DEFAULT_USER_SKILLS['excel-analyst'], false);
assert.equal(DEFAULT_USER_SKILLS['aider-development'], false);
assert.equal(USER_ROLE_SKILL_PRESETS.developer['aider-development'], true);
});