mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
85524afc0d
subscribeScriptRuns invokes listeners synchronously; finish() must not call unsubscribe before assignment when the run is already terminal. Drop the connectScriptRetryTick loop so a post-run error no longer re-queues scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1013 B
TypeScript
42 lines
1013 B
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
setScriptRuns,
|
|
waitForScriptRun,
|
|
} from './scriptAutomationCoordinator.ts';
|
|
|
|
test('waitForScriptRun resolves when run is already completed on subscribe', async () => {
|
|
const runId = 'run-already-done';
|
|
setScriptRuns([{
|
|
runId,
|
|
scriptId: 's1',
|
|
sessionId: 'sess1',
|
|
status: 'completed',
|
|
startedAt: Date.now() - 1000,
|
|
endedAt: Date.now(),
|
|
logs: [],
|
|
}]);
|
|
|
|
const run = await waitForScriptRun(runId, { timeoutMs: 5000 });
|
|
assert.equal(run.runId, runId);
|
|
assert.equal(run.status, 'completed');
|
|
});
|
|
|
|
test('waitForScriptRun rejects when run already failed on subscribe', async () => {
|
|
const runId = 'run-already-failed';
|
|
setScriptRuns([{
|
|
runId,
|
|
sessionId: 'sess1',
|
|
status: 'failed',
|
|
startedAt: Date.now() - 1000,
|
|
endedAt: Date.now(),
|
|
error: 'boom',
|
|
logs: [],
|
|
}]);
|
|
|
|
await assert.rejects(
|
|
() => waitForScriptRun(runId, { timeoutMs: 5000 }),
|
|
/boom/,
|
|
);
|
|
});
|