You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@texera.apache.org by gi...@apache.org on 2026/07/22 07:48:14 UTC

(texera) branch gh-readonly-queue/main/pr-6757-53bd675c35e76df4b698f093624cbff278b58d1e created (now 06c1799a73)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-6757-53bd675c35e76df4b698f093624cbff278b58d1e
in repository https://gitbox.apache.org/repos/asf/texera.git


      at 06c1799a73 test(frontend): cover MenuComponent grid/worker toggles, report generation, and name sizing (#6757)

This branch includes the following new commits:

     new 06c1799a73 test(frontend): cover MenuComponent grid/worker toggles, report generation, and name sizing (#6757)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(texera) 01/01: test(frontend): cover MenuComponent grid/worker toggles, report generation, and name sizing (#6757)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-6757-53bd675c35e76df4b698f093624cbff278b58d1e
in repository https://gitbox.apache.org/repos/asf/texera.git

commit 06c1799a73b131c9877e9876857a5eb4602d5403
Author: Meng Wang <me...@uci.edu>
AuthorDate: Wed Jul 22 00:47:53 2026 -0700

    test(frontend): cover MenuComponent grid/worker toggles, report generation, and name sizing (#6757)
    
    ### What changes were proposed in this PR?
    
    Extends the existing `MenuComponent` spec to cover the toolbar methods
    it had
    left untested
    (`frontend/src/app/workspace/component/menu/menu.component.ts`).
    
    > Note: the existing spec already covers most of the methods the issue
    lists
    > (`getRunButtonBehavior`, `applyRunButtonBehavior`, `hasOperators`, the
    other
    > toggles/handlers, name change). The remaining gaps were the four
    below.
    
    5 tests cover:
    
    - `toggleGrid` — sets the joint paper grid size from the `showGrid`
    flag.
    - `toggleNumWorkers` — toggles the `hide-worker-count` class from the
    flag.
    - `onClickGenerateReport` — shows the blocking notification and builds
    the report HTML from the snapshot + operator results.
    - `adjustWorkflowNameWidth` — no-op without the name input; sizes the
    input in px otherwise.
    
    The joint-graph wrapper, notification, and report services are stubbed.
    No
    production code was changed.
    
    ### Any related issues, documentation, discussions?
    
    Closes #6746
    
    ### How was this PR tested?
    
    Extended unit tests, run locally in `frontend/` (all green; the failure
    path was
    verified by breaking an assertion to confirm the suite goes red):
    
    ```
    ng test --watch=false --include src/app/workspace/component/menu/menu.component.spec.ts
    # Test Files 1 passed (1) | Tests 55 passed (55)
    prettier --write <spec>   # clean
    eslint  <spec>            # clean
    ```
    
    ### Was this PR authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code (Opus 4.8 [1M context])
---
 .../component/menu/menu.component.spec.ts          | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/frontend/src/app/workspace/component/menu/menu.component.spec.ts b/frontend/src/app/workspace/component/menu/menu.component.spec.ts
index ebec65bb10..caa86bf614 100644
--- a/frontend/src/app/workspace/component/menu/menu.component.spec.ts
+++ b/frontend/src/app/workspace/component/menu/menu.component.spec.ts
@@ -48,6 +48,7 @@ import type { ModalOptions } from "ng-zorro-antd/modal";
 import type { ComputingUnitSelectionComponent } from "../power-button/computing-unit-selection.component";
 import { WorkflowContent } from "../../../common/type/workflow";
 import { Router } from "@angular/router";
+import { ReportGenerationService } from "../../service/report-generation/report-generation.service";
 import { USER_WORKFLOW } from "../../../app-routing.constant";
 import type { Mocked } from "vitest";
 
@@ -785,4 +786,62 @@ describe("MenuComponent", () => {
       expect(cuComponent.computingUnitStatus).toBe(ComputingUnitState.Running);
     });
   });
+
+  describe("grid / worker-count toggles, report, and name sizing", () => {
+    it("toggleGrid sets the joint paper grid size from the flag", () => {
+      const setGridSize = vi.fn();
+      vi.spyOn(workflowActionService, "getJointGraphWrapper").mockReturnValue({ mainPaper: { setGridSize } } as any);
+
+      component.showGrid = true;
+      component.toggleGrid();
+      expect(setGridSize).toHaveBeenCalledWith(2);
+
+      component.showGrid = false;
+      component.toggleGrid();
+      expect(setGridSize).toHaveBeenCalledWith(1);
+    });
+
+    it("toggleNumWorkers toggles the hide-worker-count class from the flag", () => {
+      const el = document.createElement("div");
+      vi.spyOn(workflowActionService, "getJointGraphWrapper").mockReturnValue({
+        mainPaper: { el, model: { getElements: () => [] } },
+      } as any);
+
+      component.showNumWorkers = false;
+      component.toggleNumWorkers();
+      expect(el.classList.contains("hide-worker-count")).toBe(true);
+
+      component.showNumWorkers = true;
+      component.toggleNumWorkers();
+      expect(el.classList.contains("hide-worker-count")).toBe(false);
+    });
+
+    it("onClickGenerateReport shows a blocking notification and builds the report html", () => {
+      const reportService = TestBed.inject(ReportGenerationService);
+      const blankSpy = vi.spyOn(notificationService, "blank");
+      vi.spyOn(reportService, "generateWorkflowSnapshot").mockReturnValue(of("snap-url"));
+      vi.spyOn(reportService, "getAllOperatorResults").mockReturnValue(of([]));
+      const htmlSpy = vi.spyOn(reportService, "generateReportAsHtml").mockImplementation(() => {});
+
+      component.onClickGenerateReport();
+
+      expect(blankSpy).toHaveBeenCalled();
+      expect(htmlSpy).toHaveBeenCalledWith("snap-url", [], expect.any(String));
+    });
+
+    it("adjustWorkflowNameWidth is a no-op when the name input is absent", () => {
+      component.workflowNameInput = undefined;
+      expect(() => component.adjustWorkflowNameWidth()).not.toThrow();
+    });
+
+    it("adjustWorkflowNameWidth sizes the input in px to fit its text", () => {
+      const input = document.createElement("input");
+      input.value = "my workflow";
+      component.workflowNameInput = { nativeElement: input } as typeof component.workflowNameInput;
+
+      component.adjustWorkflowNameWidth();
+
+      expect(input.style.width).toMatch(/^\d+px$/);
+    });
+  });
 });