mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
cleanupClosedTerminalSessions,
|
|
cleanupDeletedAIChatSessions,
|
|
cleanupSdkAgentSessions,
|
|
} from './aiStateSnapshots';
|
|
|
|
test('orphan cleanup keeps durable Catty output while explicit deletion removes it', async () => {
|
|
const sdkCleanups: string[] = [];
|
|
const outputCleanups: string[] = [];
|
|
const terminalOutputCleanups: string[] = [];
|
|
const previousWindow = globalThis.window;
|
|
Object.defineProperty(globalThis, 'window', {
|
|
configurable: true,
|
|
value: {
|
|
netcatty: {
|
|
aiSdkAgentCleanup: async (chatSessionId: string) => {
|
|
sdkCleanups.push(chatSessionId);
|
|
return { ok: true };
|
|
},
|
|
deleteChatToolOutputsTemp: async (chatSessionId: string) => {
|
|
outputCleanups.push(chatSessionId);
|
|
return { deletedCount: 1 };
|
|
},
|
|
deleteTerminalToolOutputsEverywhereTemp: async (terminalSessionId: string) => {
|
|
terminalOutputCleanups.push(terminalSessionId);
|
|
return { deletedCount: 1 };
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
try {
|
|
cleanupSdkAgentSessions(['history-kept']);
|
|
cleanupDeletedAIChatSessions(['history-deleted']);
|
|
cleanupClosedTerminalSessions(['terminal-closed', 'terminal-closed']);
|
|
await new Promise(resolve => setTimeout(resolve, 0));
|
|
|
|
assert.deepEqual(sdkCleanups, ['history-kept', 'history-deleted']);
|
|
assert.deepEqual(outputCleanups, ['history-deleted']);
|
|
assert.deepEqual(terminalOutputCleanups, ['terminal-closed']);
|
|
} finally {
|
|
Object.defineProperty(globalThis, 'window', {
|
|
configurable: true,
|
|
value: previousWindow,
|
|
});
|
|
}
|
|
});
|