fix restart recovery active groups
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import {
|
||||
buildRestartAnnouncement,
|
||||
getRecoverableInterruptedGroups,
|
||||
getInterruptedRecoveryCandidates,
|
||||
type RestartContext,
|
||||
} from './restart-context.js';
|
||||
@@ -16,8 +18,8 @@ function makeGroup(folder: string): RegisteredGroup {
|
||||
};
|
||||
}
|
||||
|
||||
describe('getInterruptedRecoveryCandidates', () => {
|
||||
it('returns only registered interrupted groups and deduplicates by chatJid', () => {
|
||||
describe('restart recovery context', () => {
|
||||
it('returns only registered processing groups and deduplicates by chatJid', () => {
|
||||
const roomBindings: Record<string, RegisteredGroup> = {
|
||||
'dc:1': makeGroup('group-one'),
|
||||
'dc:2': makeGroup('group-two'),
|
||||
@@ -38,8 +40,8 @@ describe('getInterruptedRecoveryCandidates', () => {
|
||||
pendingTasks: 0,
|
||||
},
|
||||
{
|
||||
chatJid: 'dc:1',
|
||||
groupName: 'one-duplicate',
|
||||
chatJid: 'dc:2',
|
||||
groupName: 'two-waiting',
|
||||
status: 'waiting',
|
||||
elapsedMs: null,
|
||||
pendingMessages: false,
|
||||
@@ -47,7 +49,7 @@ describe('getInterruptedRecoveryCandidates', () => {
|
||||
},
|
||||
{
|
||||
chatJid: 'dc:2',
|
||||
groupName: 'two',
|
||||
groupName: 'two-idle',
|
||||
status: 'idle',
|
||||
elapsedMs: null,
|
||||
pendingMessages: false,
|
||||
@@ -61,6 +63,14 @@ describe('getInterruptedRecoveryCandidates', () => {
|
||||
pendingMessages: true,
|
||||
pendingTasks: 0,
|
||||
},
|
||||
{
|
||||
chatJid: 'dc:1',
|
||||
groupName: 'one-duplicate',
|
||||
status: 'processing',
|
||||
elapsedMs: 2000,
|
||||
pendingMessages: false,
|
||||
pendingTasks: 1,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -72,17 +82,40 @@ describe('getInterruptedRecoveryCandidates', () => {
|
||||
pendingMessages: true,
|
||||
pendingTasks: 0,
|
||||
},
|
||||
{
|
||||
chatJid: 'dc:2',
|
||||
groupFolder: 'group-two',
|
||||
status: 'idle',
|
||||
pendingMessages: false,
|
||||
pendingTasks: 0,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns empty when there is no explicit restart context', () => {
|
||||
expect(getInterruptedRecoveryCandidates(null, {})).toEqual([]);
|
||||
});
|
||||
|
||||
it('uses only processing groups for restart announcements', () => {
|
||||
const context: RestartContext = {
|
||||
chatJid: 'dc:main',
|
||||
summary: 'restart',
|
||||
verify: [],
|
||||
writtenAt: '2026-05-21T00:00:00.000Z',
|
||||
interruptedGroups: [
|
||||
{
|
||||
chatJid: 'dc:processing',
|
||||
groupName: 'processing',
|
||||
status: 'processing',
|
||||
elapsedMs: 1000,
|
||||
pendingMessages: false,
|
||||
pendingTasks: 0,
|
||||
},
|
||||
{
|
||||
chatJid: 'dc:waiting',
|
||||
groupName: 'waiting',
|
||||
status: 'waiting',
|
||||
elapsedMs: null,
|
||||
pendingMessages: true,
|
||||
pendingTasks: 1,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(getRecoverableInterruptedGroups(context)).toHaveLength(1);
|
||||
expect(buildRestartAnnouncement(context)).toContain('중단 작업 감지: 1개');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user