Copilot commented on code in PR #6819:
URL: https://github.com/apache/texera/pull/6819#discussion_r3635675016


##########
frontend/src/app/common/service/computing-unit/computing-unit-status/computing-unit-status.service.spec.ts:
##########
@@ -294,4 +294,130 @@ describe("ComputingUnitStatusService", () => {
       vi.useRealTimers();
     }
   });
+
+  describe("selectComputingUnit() cache-miss and guard branches", () => {
+    it("refreshes then selects a unit that is not yet in the cache", () => {
+      const openSpy = vi.spyOn(websocketService, 
"openWebsocket").mockImplementation(() => {});
+      const managing = TestBed.inject(WorkflowComputingUnitManagingService);
+      const unit9 = mockUnit(9);
+      // The cache starts empty, so cuid 9 is a miss: selection must trigger a
+      // refresh and wait for the unit to appear before opening the socket.
+      vi.spyOn(managing, "listComputingUnits").mockReturnValue(of([unit9]));
+
+      service.selectComputingUnit(5, 9);
+
+      // MOCK_USER_ID (1) is threaded through from the stub user service.
+      expect(openSpy).toHaveBeenCalledWith(5, 1, 9);
+      expect(service.getSelectedComputingUnitValue()).toBe(unit9);

Review Comment:
   This assertion hard-codes the stub user id (1). That makes the test brittle 
if the stub changes, and it also doesn't explicitly verify that `uid` is 
defined before opening the websocket. Consider deriving the expected uid from 
the injected `UserService` instead of using a magic number.



-- 
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