From af478fdea24e07dca1406f5b0e56ae07d5cbb20d Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Thu, 26 Oct 2023 09:43:17 +0100 Subject: [PATCH] fix: isWUComplete fails for compile + Attach Signed-off-by: Gordon Smith --- packages/comms/src/ecl/workunit.ts | 4 ++++ tests/test-comms/.vscode/launch.json | 26 +++-------------------- tests/test-comms/src/ecl/workunit.spec.ts | 24 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/packages/comms/src/ecl/workunit.ts b/packages/comms/src/ecl/workunit.ts index 21ad052614..e975e5d589 100644 --- a/packages/comms/src/ecl/workunit.ts +++ b/packages/comms/src/ecl/workunit.ts @@ -424,6 +424,10 @@ export class Workunit extends StateObject implem async refreshState(): Promise { await this.WUQuery(); + // Ensure "isComplete" is correct for WUs that are only "Compiled". + if (this.StateID === WUStateID.Compiled && !this.ActionEx && !this._submitAction) { + await this.refreshInfo(); + } return this; } diff --git a/tests/test-comms/.vscode/launch.json b/tests/test-comms/.vscode/launch.json index 609e414690..a2272ec190 100644 --- a/tests/test-comms/.vscode/launch.json +++ b/tests/test-comms/.vscode/launch.json @@ -6,29 +6,9 @@ "configurations": [ { "name": "Mocha Tests", - "type": "node", - "request": "launch", - "cwd": "${workspaceRoot}", - "runtimeExecutable": "${workspaceRoot}/../../node_modules/.bin/mocha", - "windows": { - "runtimeExecutable": "${workspaceRoot}/../../node_modules/.bin/mocha.cmd" - }, - "linux": { - "runtimeExecutable": "${workspaceRoot}/../../node_modules/.bin/mocha" - }, - "runtimeArgs": [ - "-u", - "tdd", - "--timeout", - "999999", - "--colors", - "--exit", - "${workspaceRoot}/lib-umd/index.node.spec.js" - ], - "internalConsoleOptions": "openOnSessionStart", - "outFiles": [ - "${workspaceRoot}/build/**/*" - ] + "type": "node-terminal", + "command": "npm run test:node && exit", + "request": "launch" }, { "name": "Launch Edge", diff --git a/tests/test-comms/src/ecl/workunit.spec.ts b/tests/test-comms/src/ecl/workunit.spec.ts index bbe41869c5..15c8ac1752 100644 --- a/tests/test-comms/src/ecl/workunit.spec.ts +++ b/tests/test-comms/src/ecl/workunit.spec.ts @@ -272,4 +272,28 @@ allPeople; }); }); }); + + describe.only("Compile + watchUntilComplete", function () { + it("Simple", function () { + return Workunit.compile({ baseUrl: ESP_URL }, "hthor", "'Hello and Welcome!';").then((wu) => { + return wu.watchUntilComplete(); + }).then((wu) => { + return wu.delete(); + }).catch((e) => { + logger.debug(e); + }); + }); + + it("Compile + Attach", function () { + return Workunit.compile({ baseUrl: ESP_URL }, "hthor", "'Hello and Welcome!';").then((wu) => { + return Workunit.attach({ baseUrl: ESP_URL }, wu.Wuid); + }).then(wu => { + return wu.watchUntilComplete(); + }).then((wu) => { + return wu.delete(); + }).catch((e) => { + logger.debug(e); + }); + }); + }); });