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


##########
frontend/src/app/common/service/computing-unit/computing-unit-status/computing-unit-status.service.spec.ts:
##########
@@ -257,6 +257,68 @@ describe("ComputingUnitStatusService", () => {
     expect(latest).toEqual(newUnits);
   });
 
+  it("keeps refreshing the list after one failed list fetch", () => {

Review Comment:
   Fixed in 22602e6353cc3b7369e3e319cc61f118be7cd363.



##########
frontend/src/app/common/service/computing-unit/computing-unit-status/computing-unit-status.service.spec.ts:
##########
@@ -328,6 +390,62 @@ describe("ComputingUnitStatusService", () => {
     }
   });
 
+  it("keeps polling the selected unit after one failed fetch", () => {
+    vi.useFakeTimers();
+    try {
+      const managing = TestBed.inject(WorkflowComputingUnitManagingService);
+      const polled = { computingUnit: { cuid: 3 }, status: "Running" } as 
unknown as DashboardWorkflowComputingUnit;
+      const getSpy = vi
+        .spyOn(managing, "getComputingUnit")
+        .mockReturnValueOnce(throwError(() => new Error("boom")))
+        .mockReturnValue(of(polled));
+      (service as any).allComputingUnitsSubject.next([mockUnit(3)]);
+      (service as any).selectedUnitSubject.next(mockUnit(3));
+
+      (service as any).startPollingSelectedUnit(3);
+      vi.advanceTimersByTime((service as any).REFRESH_INTERVAL_MS * 5);
+
+      // The failed first poll must not end the interval: every later tick 
still fetches.
+      expect(getSpy).toHaveBeenCalledTimes(5);
+      expect(service.getSelectedComputingUnitValue()).toBe(polled);
+    } finally {
+      (service as any).stopPollingSelectedUnit();
+      vi.useRealTimers();
+    }
+  });
+
+  it("a failed poll keeps the poll alive and leaves the selection intact", () 
=> {
+    vi.useFakeTimers();
+    try {
+      const managing = TestBed.inject(WorkflowComputingUnitManagingService);
+      const original = mockUnit(3);
+      const polled = { computingUnit: { cuid: 3 }, status: "Running" } as 
unknown as DashboardWorkflowComputingUnit;
+      const getSpy = vi
+        .spyOn(managing, "getComputingUnit")
+        .mockReturnValueOnce(throwError(() => new Error("boom")))
+        .mockReturnValue(of(polled));
+      const stopSpy = vi.spyOn(service as any, "stopPollingSelectedUnit");
+      (service as any).allComputingUnitsSubject.next([original]);
+      (service as any).selectedUnitSubject.next(original);
+
+      (service as any).startPollingSelectedUnit(3);
+      vi.advanceTimersByTime((service as any).REFRESH_INTERVAL_MS);
+      expect(getSpy).toHaveBeenCalledTimes(1);
+
+      // The failed poll leaves the selected unit object as it was and the 
poll subscription open.
+      expect(service.getSelectedComputingUnitValue()).toBe(original);
+      expect(stopSpy).not.toHaveBeenCalled();
+      expect((service as any).selectedUnitPoll.closed).toBe(false);

Review Comment:
   Fixed in 22602e6353cc3b7369e3e319cc61f118be7cd363.



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