Files
memind/chat-skills.test.mjs
T
John 6ee6fd64dd Add MindSpace page live edit, chat skills, and H5 deploy tooling.
Introduce page edit sessions with draft preview and patch API, chat skill picker, user memory profile, h5ApiBase resolution, voice WAV transport, and scripts for 105/g2 deployment and Plaza local dev.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-15 22:09:38 -07:00

40 lines
1.7 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
buildChatSkillPrompt,
CHAT_SKILL_DEFINITIONS,
filterChatSkills,
} from './chat-skills.mjs';
test('filterChatSkills shows summarize and analyze without granted skills', () => {
const visible = filterChatSkills(CHAT_SKILL_DEFINITIONS, { canPublish: false });
assert.ok(visible.some((item) => item.id === 'summarize'));
assert.ok(visible.some((item) => item.id === 'analyze'));
assert.equal(visible.some((item) => item.id === 'generate-page'), false);
});
test('filterChatSkills gates platform skills by grantedSkills', () => {
const visible = filterChatSkills(CHAT_SKILL_DEFINITIONS, {
canPublish: false,
grantedSkills: ['web', 'search'],
});
assert.ok(visible.some((item) => item.id === 'web-search'));
assert.ok(visible.some((item) => item.id === 'code-search'));
assert.equal(visible.some((item) => item.id === 'form-collect'), false);
});
test('filterChatSkills shows generate-page when publish is allowed', () => {
const visible = filterChatSkills(CHAT_SKILL_DEFINITIONS, { canPublish: true });
assert.ok(visible.some((item) => item.id === 'generate-page'));
});
test('buildChatSkillPrompt includes skill name for platform skills', () => {
assert.match(buildChatSkillPrompt('web', 'web'), /请使用 web 技能/);
assert.match(buildChatSkillPrompt('generate-page'), /static-page-publish/);
});
test('prefillOnly is set for open-ended chat skills', () => {
assert.equal(CHAT_SKILL_DEFINITIONS.find((item) => item.id === 'web-search')?.prefillOnly, true);
assert.equal(CHAT_SKILL_DEFINITIONS.find((item) => item.id === 'generate-page')?.prefillOnly, undefined);
});