test(ai-review): 補行號定位、誤報裁決邊界、統計與 appendExclusions 測試
This commit is contained in:
+24
-1
@@ -1,6 +1,6 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { parseRoleFile, loadRoles, loadRole, buildAnalysisPrompt, getRoleIntro } from './roles.js';
|
||||
import { parseRoleFile, loadRoles, loadRole, buildAnalysisPrompt, buildLocateLinePrompt, getRoleIntro } from './roles.js';
|
||||
|
||||
const SAMPLE = `---
|
||||
name: Tester
|
||||
@@ -81,6 +81,29 @@ describe('buildAnalysisPrompt', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildAnalysisPrompt 行號要求', () => {
|
||||
it('requires a line number in location', () => {
|
||||
const prompt = buildAnalysisPrompt(parseRoleFile(SAMPLE));
|
||||
assert.match(prompt, /行號為必填/);
|
||||
assert.match(prompt, /每一條問題都必須帶行號/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildLocateLinePrompt', () => {
|
||||
it('asks the same role to return a JSON line number', () => {
|
||||
const prompt = buildLocateLinePrompt({ name: 'Maya', badge: '🧪', focus: 'testing' });
|
||||
assert.match(prompt, /Maya/);
|
||||
assert.match(prompt, /找出.*行號|實際行號/);
|
||||
assert.match(prompt, /\{"line": 數字\}/);
|
||||
});
|
||||
|
||||
it('tolerates a bare role object without badge/focus', () => {
|
||||
const prompt = buildLocateLinePrompt({ name: 'Leo' });
|
||||
assert.match(prompt, /Leo/);
|
||||
assert.doesNotMatch(prompt, /undefined/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getRoleIntro', () => {
|
||||
it('renders a table row per role with its badge', () => {
|
||||
const intro = getRoleIntro([parseRoleFile(SAMPLE)]);
|
||||
|
||||
Reference in New Issue
Block a user