Files
ftb-project-management/apps/web/lib/wenfan-xiaobao-ui.test.ts
Script Generator d2a07b0da2 feat(小宝): 优化助手入口与预警已读
关键改动:

- 更新 README 项目说明和小宝相关入口命名

- 优化问翻小宝页面与侧边栏测试

- 小宝预警已读状态抑制同签名重复 AI 请求

Co-Authored-By: Codex GPT-5 <codex@openai.com>
2026-07-01 13:35:52 +08:00

72 lines
3.2 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
test('sidebar labels AI assistant before smart warning', () => {
const sidebar = readFileSync(join(process.cwd(), 'components/layout/Sidebar.tsx'), 'utf8');
const askIndex = sidebar.indexOf("label: 'AI 助手'");
const warningIndex = sidebar.indexOf("label: '智能预警'");
assert.notEqual(askIndex, -1);
assert.notEqual(warningIndex, -1);
assert.ok(askIndex < warningIndex);
assert.doesNotMatch(sidebar, /label: '问翻小宝'/);
assert.doesNotMatch(sidebar, /label: '小宝预警'/);
assert.match(sidebar, /path: '\/wenfan-xiaobao'/);
});
test('wenfan xiaobao page provides records, chat, and voice input surfaces', () => {
const pagePath = join(process.cwd(), 'app/wenfan-xiaobao/page.tsx');
assert.equal(existsSync(pagePath), true);
const page = readFileSync(pagePath, 'utf8');
assert.match(page, /历史记录/);
assert.match(page, /对话/);
assert.match(page, /textarea/);
assert.match(page, /Mic/);
assert.match(page, /searchHelpArticles/);
assert.match(page, /HelpAnswer/);
assert.match(page, /shouldShowGenericHelpSuggestions/);
assert.match(page, /showGenericSuggestions/);
assert.match(page, /showStarterQuestions/);
assert.match(page, /showGenericSuggestions && message\.suggestions\.length > 0/);
assert.match(page, /createWenfanConversationRecord/);
assert.match(page, /updateWenfanConversationRecord/);
assert.match(page, /deleteWenfanConversationRecord/);
assert.match(page, /删除历史记录/);
assert.doesNotMatch(page, /setHistory\(\(current\) => \[question/);
assert.doesNotMatch(page, /<p className="mb-1 text-\[13px\] font-semibold text-\[#171717\]">问翻小宝<\/p>/);
assert.match(page, /入口路径/);
assert.match(page, /必填字段/);
assert.match(page, /状态流转/);
assert.match(page, /注意事项/);
assert.match(page, /previewImage/);
assert.match(page, /aria-modal="true"/);
assert.match(page, /点击放大/);
assert.match(page, /lg:grid-cols-\[300px_minmax\(0,1fr\)\]/);
assert.match(page, /rounded-\[28px\]/);
assert.doesNotMatch(page, /: 'border-\[var\(--line\)\] bg-\[var\(--bg\)\]/);
assert.match(page, /: 'bg-white hover:bg-\[var\(--bg-subtle\)\]'/);
});
test('wenfan help screenshot script targets version detail tabs and failed test case bug entry', () => {
const script = readFileSync(join(process.cwd(), 'scripts/capture-wenfan-help-screenshots.mjs'), 'utf8');
assert.match(script, /resolveScreenshotContext/);
assert.match(script, /loadDataKey\('test-cases'\)/);
assert.match(script, /loadDataKey\('version-plans'\)/);
assert.match(script, /findFailedTestCase/);
assert.match(script, /findAiReadyProductPlan/);
assert.match(script, /openProductPlanAiEntry/);
assert.match(script, /tabLabel: '关联需求'/);
assert.match(script, /tabLabel: '产品方案'/);
assert.match(script, /tabLabel: '开发任务'/);
assert.match(script, /tabLabel: '测试用例'/);
assert.match(script, /openFailedTestCaseBugEntry/);
assert.match(script, /提 BUG/);
assert.doesNotMatch(script, /\{ file: 'bug-workflow\.png', route: '\/versions' \}/);
});