eugenegujing commented on code in PR #8936:
URL: https://github.com/apache/texera/pull/8936#discussion_r4520528242


##########
frontend/src/app/workspace/service/execute-workflow/execute-workflow.service.spec.ts:
##########
@@ -238,6 +245,171 @@ describe("ExecuteWorkflowService", () => {
     });
   });
 
+  describe("losing the selected computing unit mid-run", () => {
+    const unit = (cuid: number): DashboardWorkflowComputingUnit =>
+      ({ computingUnit: { cuid }, status: "Running" }) as unknown as 
DashboardWorkflowComputingUnit;
+
+    it("ends a running execution when the selection empties", () => {
+      const enable = vi.spyOn(service["workflowActionService"], 
"enableWorkflowModification");
+      const seen: ExecutionState[] = [];
+      service.getExecutionStateStream().subscribe(({ current }) => 
seen.push(current.state));
+      emitWsEvent({ type: "WorkflowStateEvent", state: ExecutionState.Running 
});
+      emitWsEvent({ type: "WorkerAssignmentUpdateEvent", operatorId: "op1", 
workerIds: ["w1", "w2"] });
+      selectedUnit$.next(unit(7));
+      enable.mockClear();
+
+      selectedUnit$.next(null);
+
+      
expect(service.getExecutionState().state).toBe(ExecutionState.Uninitialized);
+      expect(service.getWorkerIds("op1")).toEqual([]);
+      expect(enable).toHaveBeenCalled();
+      expect(seen).toEqual([ExecutionState.Running, 
ExecutionState.Uninitialized]);
+    });
+
+    it("ends a paused execution when the selection empties", () => {
+      emitWsEvent({ type: "WorkflowStateEvent", state: ExecutionState.Running 
});
+      emitWsEvent({ type: "WorkflowStateEvent", state: ExecutionState.Paused 
});
+      selectedUnit$.next(unit(7));
+
+      selectedUnit$.next(null);
+
+      
expect(service.getExecutionState().state).toBe(ExecutionState.Uninitialized);
+    });

Review Comment:
   Done in 8d8847ef1cdd891cdea381d8e7937115e3313b11. All of them: 
   - Removed the standalone Paused, finished-execution, no-execution, 
error-messages and clock tests.
   - The switch, first-selection and status cases are one table. Failed moved 
out of it into two tests of its own, since it now resets, and the table gained 
a row for a unit that is still Running with the socket down.
   - The four Kill tests and the old two-row table are one six-row `it.each`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to