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


##########
frontend/src/app/workspace/component/left-panel/time-travel/time-travel.component.spec.ts:
##########
@@ -231,6 +231,69 @@ describe("TimeTravelComponent", () => {
     });
   });
 
+  /**
+   * The panel keeps itself up to date from a `timer(0, 5000)` poller started 
in ngOnInit.
+   * The fixture built by the outer beforeEach cannot be used to drive it: 
`src/test-zone-setup.ts`
+   * installs the ProxyZone that fakeAsync patches around the `it` body only, 
so anything
+   * scheduled from a beforeEach — including the poller that beforeEach's 
detectChanges starts
+   * (inert there, since the metadata stub reports no wid) — lives in the real 
zone, out of
+   * tick()'s reach. These tests therefore re-run ngOnInit from inside the 
fakeAsync body,
+   * which is where timer(0, 5000) has to be created for tick() to drive it, 
and destroy the
+   * fixture at the end so @UntilDestroy unsubscribes the periodic timer.
+   */
+  describe("ngOnInit polling", () => {
+    it("skips the refresh while the workflow has no id", fakeAsync(() => {
+      metadataSpy.mockReturnValue(undefined as any);
+      const widSpy = vi.spyOn(component, "getWid");
+      const displaySpy = vi.spyOn(component, 
"displayExecutionWithLogs").mockImplementation(() => {});
+
+      component.ngOnInit();
+      tick(0); // the first emission of timer(0, 5000) is asynchronous
+
+      // getWid pins that the poller actually ran: without it the negative 
assertion
+      // below would also pass with the poller never firing at all.
+      expect(widSpy).toHaveBeenCalledTimes(1);
+      expect(displaySpy).not.toHaveBeenCalled();
+
+      fixture.destroy();

Review Comment:
   This `fixture.destroy()` runs inside the test, but the suite-level 
`afterEach` already unconditionally calls `fixture.destroy()`. Double-destroy 
can throw (and is guarded against in other specs), making these polling tests 
flaky. Stop the poller within fakeAsync by invoking the component's OnDestroy 
hook, and let `afterEach` do the actual fixture teardown once.
   
   This issue also appears in the following locations of the same file:
   - line 279
   - line 290



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