test(roles): 補 focus/personality 缺漏時的輸出防護測試

This commit is contained in:
Jeffery
2026-06-16 17:00:29 +08:00
parent 60001499da
commit fa95a463f8
+11
View File
@@ -72,6 +72,11 @@ describe('buildAnalysisPrompt', () => {
assert.match(prompt, /審查重點:邊界與空值/);
assert.match(prompt, /只回傳 JSON 陣列/);
});
it('falls back to a default when focus is missing instead of showing undefined', () => {
const prompt = buildAnalysisPrompt({ name: 'NoFocus', body: 'x' });
assert.doesNotMatch(prompt, /undefined/);
});
});
describe('getRoleIntro', () => {
@@ -80,4 +85,10 @@ describe('getRoleIntro', () => {
assert.match(intro, /🔮 Tester/);
assert.match(intro, /logic/);
});
it('renders empty cells instead of undefined when focus/personality are missing', () => {
const intro = getRoleIntro([{ name: 'Bare' }]);
assert.match(intro, /Bare/);
assert.doesNotMatch(intro, /undefined/);
});
});