mengw15 commented on code in PR #7915:
URL: https://github.com/apache/texera/pull/7915#discussion_r3842351246


##########
frontend/src/app/workspace/component/menu/menu.component.spec.ts:
##########
@@ -1216,4 +1358,293 @@ describe("MenuComponent", () => {
       });
     });
   });
+
+  describe("ngOnInit subscriptions", () => {
+    afterEach(() => {
+      vi.restoreAllMocks();
+    });
+
+    it("re-applies the run button behavior on every execution state event", () 
=> {
+      const stateEvents$ = new Subject<{ current: { state: ExecutionState } 
}>();
+      vi.spyOn(executeWorkflowService, 
"getExecutionStateStream").mockReturnValue(
+        stateEvents$.asObservable() as ReturnType<typeof 
executeWorkflowService.getExecutionStateStream>
+      );
+      const stateFixture = TestBed.createComponent(MenuComponent);
+      const stateComponent = stateFixture.componentInstance;
+      stateFixture.detectChanges();
+      stateComponent.isWorkflowValid = true;
+      stateComponent.isWorkflowEmpty = false;
+      stateComponent.computingUnitStatus = ComputingUnitState.Running;
+      Object.defineProperty(stateComponent.workflowWebsocketService, 
"isConnected", {
+        get: () => true,
+        configurable: true,
+      });
+
+      try {
+        stateEvents$.next({ current: { state: ExecutionState.Running } });
+        expect(stateComponent.executionState).toBe(ExecutionState.Running);
+        expect(stateComponent.runButtonText).toBe("Pause");
+
+        stateEvents$.next({ current: { state: ExecutionState.Paused } });
+        expect(stateComponent.runButtonText).toBe("Resume");
+      } finally {
+        stateFixture.destroy();
+      }
+    });
+
+    it("deactivates the export button unless the feature is on and results 
exist", () => {
+      const guiConfig = TestBed.inject(GuiConfigService);
+      const results$ = 
component.workflowResultExportService.hasResultToExportOnAllOperators;
+
+      // Feature off: deactivated whatever the results say.
+      guiConfig.env.exportExecutionResultEnabled = false;
+      results$.next(true);
+      expect(component.isExportDeactivate).toBe(true);
+
+      // Feature on, but nothing to export.
+      guiConfig.env.exportExecutionResultEnabled = true;
+      results$.next(false);
+      expect(component.isExportDeactivate).toBe(true);
+
+      results$.next(true);
+      expect(component.isExportDeactivate).toBe(false);

Review Comment:
   `GuiConfigService` is provided per-TestBed (`useClass` in 
`commonTestProviders`) and TestBed is reset between tests, so the mutation 
cannot leak — probed: a different instance in the next test, with the flag back 
to `false`. The flag is also read inside the export-status subscription 
callback rather than at `ngOnInit`, which is what the third assertion here 
proves. Left as is, matching the neighbouring `timetravelEnabled` test.



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