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), [ '怎么新建产品?', '怎么把需求纳入版本?', '开发任务怎么提测?', ]); });