Skip to content

Commit

Permalink
Merge pull request #4145 from dehilsterlexis/WU_ADD_PROTECT
Browse files Browse the repository at this point in the history
feat: Add Protect & Unprotect functions to Visualization WU Class
  • Loading branch information
GordonSmith authored Dec 18, 2023
2 parents e61ff70 + fb2b4e9 commit 16ee388
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
8 changes: 8 additions & 0 deletions packages/comms/src/ecl/workunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,14 @@ export class Workunit extends StateObject<UWorkunitState, IWorkunitState> implem
abort() {
return this.WUAction("Abort");
}

protect() {
return this.WUAction("Protect");
}

unprotect() {
return this.WUAction("Unprotect");
}

delete() {
return this.WUAction("Delete");
Expand Down
2 changes: 1 addition & 1 deletion packages/comms/src/services/wsWorkunits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ export namespace WUQueryDetails {
}

export namespace WUAction {
export type Type = "SetToFailed" | "Pause" | "PauseNow" | "Resume" | "Abort" | "Delete" | "Restore" | "Deschedule" | "Reschedule";
export type Type = "SetToFailed" | "Pause" | "PauseNow" | "Resume" | "Abort" | "Delete" | "Restore" | "Deschedule" | "Reschedule" | "Protect" | "Unprotect";
export interface Request {
Wuids: string[];
WUActionType: Type;
Expand Down
3 changes: 3 additions & 0 deletions tests/test-comms/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
"type": "msedge",
"url": "file:///${workspaceRoot}/test.html",
"webRoot": "${workspaceFolder}",
"runtimeArgs": [
"--disable-web-security"
],
"sourceMapPathOverrides": {
"webpack:///./*": "${workspaceRoot}/*",
"webpack:///*": "/*"
Expand Down
21 changes: 19 additions & 2 deletions tests/test-comms/src/ecl/workunit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ allPeople;
});
it("result schema", function () {
return wu1.fetchResults().then((results) => {
expect(wu1.isComplete(), "isComplete").is.true;
expect(results.length).equals(1);
expect(results[0].Name).to.equal("Result 1");
expect(results[0].Sequence).to.equal(0);
Expand All @@ -68,6 +69,7 @@ allPeople;
});
it("results", function () {
return wu1.fetchResults().then((results) => {
expect(wu1.isComplete(), "isComplete").is.true;
expect(results.length).equals(1);
return wu1.CResults[0].fetchRows().then(response => {
expect(response.length).to.equal(3);
Expand Down Expand Up @@ -97,9 +99,24 @@ allPeople;
await newWu.delete();
expect(newWu.isDeleted(), "isDeleted").is.true;
});
it("delete", function () {
it("protect", function () {
return wu1.protect().then(() => {
expect(wu1.Protected).to.be.true;
});
});
it("delete (protected - should fail)", function () {
return wu1.delete().then(function (response) {
expect(wu1.isDeleted(), "isDeleted").is.false;
return response;
});
});
it("unprotect", function () {
return wu1.unprotect().then(() => {
expect(wu1.Protected).to.be.false;
});
});
it("delete (unprotected)", function () {
return wu1.delete().then(function (response) {
expect(wu1.isComplete(), "isComplete").is.true;
expect(wu1.isDeleted(), "isDeleted").is.true;
return response;
});
Expand Down

0 comments on commit 16ee388

Please sign in to comment.