Initial import
This commit is contained in:
54
etc/servers/work-server/src/services/plan-policy.test.ts
Executable file
54
etc/servers/work-server/src/services/plan-policy.test.ts
Executable file
@@ -0,0 +1,54 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { buildPlanNotificationData } from './plan-notification-service.js';
|
||||
import { shouldNotifyPlanRestart } from './plan-notification-policy.js';
|
||||
import { shouldTriggerRetryFromActionNote } from './plan-retry-policy.js';
|
||||
import { issueActionSchema } from './plan-service.js';
|
||||
|
||||
test('shouldTriggerRetryFromActionNote detects missing-fix and verification follow-up requests', () => {
|
||||
assert.equal(shouldTriggerRetryFromActionNote('누락된 거 다시 고쳐서 테스트해 줘'), true);
|
||||
assert.equal(shouldTriggerRetryFromActionNote('빠진 내용 보완하고 검증해줘'), true);
|
||||
});
|
||||
|
||||
test('shouldTriggerRetryFromActionNote ignores simple status comments', () => {
|
||||
assert.equal(shouldTriggerRetryFromActionNote('확인했습니다. 메모만 남깁니다.'), false);
|
||||
});
|
||||
|
||||
test('issueActionSchema defaults retry to false', () => {
|
||||
assert.deepEqual(
|
||||
issueActionSchema.parse({
|
||||
actionNote: '원인 분석과 조치 내용을 남깁니다.',
|
||||
}),
|
||||
{
|
||||
actionNote: '원인 분석과 조치 내용을 남깁니다.',
|
||||
resolve: false,
|
||||
retry: false,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test('shouldNotifyPlanRestart only allows restart alerts when a retry was actually scheduled', () => {
|
||||
assert.equal(
|
||||
shouldNotifyPlanRestart({
|
||||
didScheduleRetry: false,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
shouldNotifyPlanRestart({
|
||||
didScheduleRetry: true,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
assert.equal(shouldNotifyPlanRestart(null), false);
|
||||
});
|
||||
|
||||
test('buildPlanNotificationData uses stable task key per plan', () => {
|
||||
assert.deepEqual(buildPlanNotificationData(17, 'WK-123', 'plan-restarted'), {
|
||||
planId: '17',
|
||||
workId: 'WK-123',
|
||||
eventType: 'plan-restarted',
|
||||
targetUrl: 'https://sm-home.cloud/?topMenu=plans&planId=17&workId=WK-123',
|
||||
notificationKey: 'plan:17',
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user