feat(小宝): 优化助手入口与预警已读
关键改动: - 更新 README 项目说明和小宝相关入口命名 - 优化问翻小宝页面与侧边栏测试 - 小宝预警已读状态抑制同签名重复 AI 请求 Co-Authored-By: Codex GPT-5 <codex@openai.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
getXiaobaoWarningUpdateSignature,
|
||||
isXiaobaoWarningUpdated,
|
||||
markXiaobaoWarningRead,
|
||||
shouldSkipXiaobaoRiskInsightRequestForReadState,
|
||||
sanitizeRiskInsight,
|
||||
} from './xiaobao-warning-view';
|
||||
|
||||
@@ -192,6 +193,31 @@ test('xiaobao warning update state is unread until the current user reads the sa
|
||||
assert.equal(isXiaobaoWarningUpdated(baseRisk, readStates, 'user-2'), true);
|
||||
});
|
||||
|
||||
test('read current warning state suppresses refresh-triggered AI requests only for the same signature', () => {
|
||||
const baseRisk = risk();
|
||||
const readStates = markXiaobaoWarningRead([], 'user-1', baseRisk, '2026-06-30T11:00:00.000Z');
|
||||
const changedRisk = risk({
|
||||
signals: {
|
||||
...baseRisk.signals,
|
||||
failedTestCount: 1,
|
||||
},
|
||||
riskScore: 72,
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
shouldSkipXiaobaoRiskInsightRequestForReadState(baseRisk, readStates, 'user-1', true),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
shouldSkipXiaobaoRiskInsightRequestForReadState(changedRisk, readStates, 'user-1', true),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
shouldSkipXiaobaoRiskInsightRequestForReadState(baseRisk, readStates, 'user-1', false),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test('xiaobao warning update state becomes unread again when risk facts change', () => {
|
||||
const baseRisk = risk();
|
||||
const readStates = markXiaobaoWarningRead([], 'user-1', baseRisk, '2026-06-30T11:00:00.000Z');
|
||||
|
||||
Reference in New Issue
Block a user