mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-19 22:45:45 +00:00
Fix rerunning stopped automation scripts
This commit is contained in:
1 parent
26a923c498
commit
0c7f69dc8f
4 files changed
+788
-116
No files matched your search
@@ -427,3 +427,41 @@ test("createScriptRuntime convenience dialog controls return single values", asy
|
||||
assert.deepEqual(calls.map((call) => call.fieldType), ["select", "radio", "checkbox"]);
|
||||
assert.deepEqual(values, ["prod", "safe", "true"]);
|
||||
});
|
||||
|
||||
test("createScriptRuntime does not open dialogs after a script is stopped", async () => {
|
||||
let aborted = false;
|
||||
let dialogCalls = 0;
|
||||
const runtime = createScriptRuntime({
|
||||
sessionId: "s1",
|
||||
runId: "r1",
|
||||
appendLog: () => {},
|
||||
writeToSession: () => {},
|
||||
getOutputBuffer: () => ({
|
||||
waitFor: async () => "ok",
|
||||
waitForAny: async () => 0,
|
||||
getText: () => "",
|
||||
}),
|
||||
getSessionMeta: () => ({ connected: true, hostname: "host", username: "user" }),
|
||||
showDialog: async () => {
|
||||
dialogCalls += 1;
|
||||
return true;
|
||||
},
|
||||
isPaused: () => false,
|
||||
isAborted: () => aborted,
|
||||
onStatusChange: () => {},
|
||||
});
|
||||
|
||||
const run = runtime.execute(`
|
||||
try {
|
||||
await nct.sleep(5000);
|
||||
} catch {
|
||||
await nct.dialog.confirm('still there?');
|
||||
}
|
||||
`);
|
||||
setTimeout(() => {
|
||||
aborted = true;
|
||||
}, 30);
|
||||
|
||||
await assert.rejects(run, /Script stopped/);
|
||||
assert.equal(dialogCalls, 0);
|
||||
});
|
||||
Reference in new issue
Block a user