feat(问翻小宝): 接入静态帮助中心

This commit is contained in:
Script Generator
2026-06-30 19:27:23 +08:00
parent 846bf9e8d1
commit 8683b341e2
21 changed files with 1422 additions and 47 deletions

View File

@@ -0,0 +1,48 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { getFallbackHelpSuggestions, searchHelpArticles } from './wenfan-help-search';
import { WENFAN_HELP_ARTICLES } from './wenfan-help-articles';
test('searchHelpArticles matches common product creation phrasing', () => {
const result = searchHelpArticles('产品怎么新建,要填什么字段', WENFAN_HELP_ARTICLES);
assert.equal(result[0]?.article.id, 'product-create');
});
test('searchHelpArticles matches demand adoption and version inclusion synonyms', () => {
const result = searchHelpArticles('需求怎么纳入版本号里面', WENFAN_HELP_ARTICLES);
assert.equal(result[0]?.article.id, 'version-requirement-include');
});
test('searchHelpArticles matches dev task test submission phrasing', () => {
const result = searchHelpArticles('开发任务怎么提测', WENFAN_HELP_ARTICLES);
assert.equal(result[0]?.article.id, 'dev-task-workflow');
});
test('searchHelpArticles matches bug creation from failed test cases', () => {
const result = searchHelpArticles('测试用例失败了怎么提bug', WENFAN_HELP_ARTICLES);
assert.equal(result[0]?.article.id, 'bug-workflow');
});
test('searchHelpArticles keeps related article ids from the matched article', () => {
const result = searchHelpArticles('AI拆解测试用例在哪里', WENFAN_HELP_ARTICLES);
assert.equal(result[0]?.article.id, 'ai-decompose');
assert.ok(result[0]?.relatedArticles.some((article) => article.id === 'product-plan'));
});
test('searchHelpArticles returns no article for short or unknown input', () => {
assert.deepEqual(searchHelpArticles('?', WENFAN_HELP_ARTICLES), []);
assert.deepEqual(searchHelpArticles('完全无关的问题', WENFAN_HELP_ARTICLES), []);
});
test('getFallbackHelpSuggestions returns starter examples when no article matches', () => {
assert.deepEqual(getFallbackHelpSuggestions().slice(0, 3), [
'怎么新建产品?',
'怎么把需求纳入版本?',
'开发任务怎么提测?',
]);
});