You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "aglinxinyuan (via GitHub)" <gi...@apache.org> on 2026/07/12 01:33:22 UTC

[PR] test(frontend): extend UserWorkflowComponent coverage [texera]

aglinxinyuan opened a new pull request, #6359:
URL: https://github.com/apache/texera/pull/6359

   ### What changes were proposed in this PR?
   
   Extends the `UserWorkflowComponent` spec (was ~33% covered): delete/duplicate/bulk-delete flows, download-zip, local-file and zip import (real JSZip), workflow-name dedup, selection toggling, view-type persistence, tooltips, and add/remove-workflow modal callbacks.
   
   ### Any related issues, documentation, discussions?
   
   Closes #6357.
   
   ### How was this PR tested?
   
   Added tests to the existing spec (now 36) reusing its stubbed SearchResultsComponent + service harness, with a real in-test JSZip fixture and FileReader-driven async reads. Verified locally with Vitest and CI's `format:ci` gate clean. Test-only change — no production code is modified.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 4.8 [1M context])


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(frontend): extend UserWorkflowComponent coverage [texera]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #6359:
URL: https://github.com/apache/texera/pull/6359#issuecomment-4949500387

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/6359?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 63.79%. Comparing base ([`0ed4816`](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`bc67b6a`](https://app.codecov.io/gh/apache/texera/commit/bc67b6a4ca72705e9afffe1987cd6c46654e947c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 4 commits behind head on main.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #6359      +/-   ##
   ============================================
   + Coverage     61.12%   63.79%   +2.67%     
     Complexity     3381     3381              
   ============================================
     Files          1142     1142              
     Lines         45020    45020              
     Branches       4948     4948              
   ============================================
   + Hits          27518    28722    +1204     
   + Misses        15983    14723    -1260     
   - Partials       1519     1575      +56     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | *Carryforward flag |
   |---|---|---|---|
   | [access-control-service](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.00% <ø> (ø)` | | Carriedforward from [0ed4816](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [agent-service](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `44.59% <ø> (ø)` | | Carriedforward from [0ed4816](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [amber](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.58% <ø> (ø)` | | Carriedforward from [0ed4816](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [computing-unit-managing-service](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `9.97% <ø> (ø)` | | Carriedforward from [0ed4816](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [config-service](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `52.30% <ø> (ø)` | | Carriedforward from [0ed4816](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [file-service](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `63.97% <ø> (ø)` | | Carriedforward from [0ed4816](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [frontend](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `59.51% <ø> (+6.24%)` | :arrow_up: | |
   | [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.94% <ø> (ø)` | | Carriedforward from [0ed4816](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [pyamber](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `91.18% <ø> (ø)` | | Carriedforward from [0ed4816](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [workflow-compiling-service](https://app.codecov.io/gh/apache/texera/pull/6359/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.14% <ø> (ø)` | | Carriedforward from [0ed4816](https://app.codecov.io/gh/apache/texera/commit/0ed48161419e5b4fa17bee10a17cdf2e43c28304?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   *This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/texera/pull/6359?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(frontend): extend UserWorkflowComponent coverage [texera]

Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan commented on code in PR #6359:
URL: https://github.com/apache/texera/pull/6359#discussion_r3565440671


##########
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.spec.ts:
##########
@@ -357,4 +366,343 @@ describe("SavedWorkflowSectionComponent", () => {
     expect(testWorkflowFileNameConflictEntries[0].checked).toBe(true);
     expect(testWorkflowFileNameConflictEntries[2].checked).toBe(true);
   });
+
+  describe("additional UserWorkflowComponent behaviors", () => {
+    const VIEW_MODE_KEY = "texera.userWorkflow.viewMode";
+
+    const makeDashboardWorkflow = (wid: number | undefined, name: string): DashboardWorkflow => ({
+      workflow: {
+        wid,
+        name,
+        description: "desc",
+        content: testWorkflowContent([]),
+        creationTime: 0,
+        lastModifiedTime: 0,
+        isPublished: 0,
+        readonly: false,
+      },
+      isOwner: true,
+      ownerName: "Texera",
+      accessLevel: "Write",
+      projectIDs: [],
+      ownerId: 1,
+    });
+
+    const makeEntry = (wid: number | undefined, name: string, checked = false): DashboardEntry => {
+      const entry = new DashboardEntry(makeDashboardWorkflow(wid, name));
+      entry.checked = checked;
+      return entry;
+    };
+
+    const setEntries = (entries: DashboardEntry[]): void => {
+      component.searchResultsComponent.entries = entries;
+    };
+
+    afterEach(() => {
+      vi.restoreAllMocks();
+      localStorage.removeItem(VIEW_MODE_KEY);
+    });
+
+    describe("deleteWorkflow", () => {
+      it("deletes an entry with a wid and removes it from the results", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn().mockReturnValue(of(null));
+        const target = makeEntry(5, "to delete");
+        setEntries([target, makeEntry(6, "keep")]);
+
+        component.deleteWorkflow(target);
+
+        expect(persist.deleteWorkflow).toHaveBeenCalledWith([5]);
+        expect(component.searchResultsComponent.entries.map(e => e.name)).toEqual(["keep"]);
+      });
+
+      it("does nothing when the entry has no wid", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn();
+
+        component.deleteWorkflow(makeEntry(undefined, "no wid"));
+
+        expect(persist.deleteWorkflow).not.toHaveBeenCalled();
+      });
+    });
+
+    describe("onClickDuplicateSelectedWorkflows", () => {
+      it("duplicates checked wids without a pid and prepends the new entries", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.duplicateWorkflow = vi
+          .fn()
+          .mockReturnValue(of([makeDashboardWorkflow(101, "dup a"), makeDashboardWorkflow(102, "dup b")]));
+        component.pid = undefined;
+        setEntries([makeEntry(1, "wf 1", true), makeEntry(2, "wf 2", true), makeEntry(3, "wf 3", false)]);
+
+        component.onClickDuplicateSelectedWorkflows();
+
+        expect(persist.duplicateWorkflow).toHaveBeenCalledWith([1, 2]);
+        expect(component.searchResultsComponent.entries.map(e => e.name)).toEqual([
+          "dup a",
+          "dup b",
+          "wf 1",
+          "wf 2",
+          "wf 3",
+        ]);
+      });
+
+      it("passes the pid to duplicateWorkflow when the section belongs to a project", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.duplicateWorkflow = vi.fn().mockReturnValue(of([makeDashboardWorkflow(101, "dup a")]));
+        component.pid = 9;
+        setEntries([makeEntry(1, "wf 1", true), makeEntry(2, "wf 2", true)]);
+
+        component.onClickDuplicateSelectedWorkflows();
+
+        expect(persist.duplicateWorkflow).toHaveBeenCalledWith([1, 2], 9);
+      });
+
+      it("early-returns without calling the service when a checked entry has no wid", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.duplicateWorkflow = vi.fn();
+        setEntries([makeEntry(1, "wf 1", true), makeEntry(undefined, "wf 2", true)]);
+
+        component.onClickDuplicateSelectedWorkflows();
+
+        expect(persist.duplicateWorkflow).not.toHaveBeenCalled();
+      });
+
+      it("alerts on a duplication error", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.duplicateWorkflow = vi.fn().mockReturnValue(throwError(() => "boom"));
+        const alertSpy = vi.spyOn(window, "alert").mockImplementation(() => {});
+        component.pid = undefined;
+        setEntries([makeEntry(1, "wf 1", true)]);
+
+        component.onClickDuplicateSelectedWorkflows();
+
+        expect(alertSpy).toHaveBeenCalledWith("boom");
+      });
+    });
+
+    describe("handleConfirmDeleteSelectedWorkflows", () => {
+      it("deletes checked wids and keeps undefined-wid entries", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn().mockReturnValue(of(null));
+        setEntries([
+          makeEntry(1, "a", true),
+          makeEntry(2, "b", true),
+          makeEntry(undefined, "c", false),
+          makeEntry(3, "d", false),
+        ]);
+
+        component.handleConfirmDeleteSelectedWorkflows();
+
+        expect(persist.deleteWorkflow).toHaveBeenCalledWith([1, 2]);
+        expect(component.searchResultsComponent.entries.map(e => e.name)).toEqual(["c", "d"]);
+      });
+
+      it("early-returns when a checked entry has no wid", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn();
+        setEntries([makeEntry(undefined, "a", true)]);
+
+        component.handleConfirmDeleteSelectedWorkflows();
+
+        expect(persist.deleteWorkflow).not.toHaveBeenCalled();
+      });
+
+      it("alerts on a deletion error", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn().mockReturnValue(throwError(() => "delfail"));
+        const alertSpy = vi.spyOn(window, "alert").mockImplementation(() => {});
+        setEntries([makeEntry(1, "a", true)]);
+
+        component.handleConfirmDeleteSelectedWorkflows();
+
+        expect(alertSpy).toHaveBeenCalledWith("delfail");
+      });
+    });
+
+    describe("onClickOpenDownloadZip", () => {
+      it("does not call the download service when nothing is checked", () => {
+        setEntries([makeEntry(1, "a", false)]);
+
+        component.onClickOpenDownloadZip();
+
+        expect(downloadServiceSpy.downloadWorkflowsAsZip).not.toHaveBeenCalled();
+      });
+
+      it("logs an error when the download fails", () => {
+        setEntries([makeEntry(1, "a", true)]);
+        downloadServiceSpy.downloadWorkflowsAsZip.mockReturnValue(throwError(() => "dlfail"));
+        const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
+
+        component.onClickOpenDownloadZip();
+
+        expect(downloadServiceSpy.downloadWorkflowsAsZip).toHaveBeenCalledWith([{ id: 1, name: "a" }]);
+        expect(errorSpy).toHaveBeenCalledWith("Error downloading workflows:", "dlfail");
+      });
+    });
+
+    describe("workflow uploads", () => {
+      it("imports a valid .json workflow, appending an entry and toasting success", async () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.createWorkflow = vi.fn().mockReturnValue(of(makeDashboardWorkflow(42, "wf")));
+        const searchSpy = vi.spyOn(component, "search").mockResolvedValue(undefined);
+        const successSpy = vi
+          .spyOn(TestBed.inject(NotificationService), "success")
+          .mockImplementation(() => undefined as any);
+        const content = testWorkflowContent([]);
+        const file = new File([JSON.stringify(content)], "wf.json");
+        setEntries([]);
+
+        const result = await firstValueFrom(component.onClickUploadExistingWorkflowFromLocal(file as any));
+
+        expect(result).toBe(false);
+        expect(persist.createWorkflow).toHaveBeenCalledWith(content, "wf");
+        expect(component.searchResultsComponent.entries.map(e => e.name)).toContain("wf");
+        expect(searchSpy).toHaveBeenCalledWith(true);
+        expect(successSpy).toHaveBeenCalledWith("Upload Successful");
+      });
+
+      it("toasts an error and errors the stream when the file is not JSON", async () => {
+        const errorSpy = vi
+          .spyOn(TestBed.inject(NotificationService), "error")
+          .mockImplementation(() => undefined as any);
+        const file = new File(["this is not json"], "bad.json");
+
+        await expect(firstValueFrom(component.onClickUploadExistingWorkflowFromLocal(file as any))).rejects.toThrow();
+
+        expect(errorSpy).toHaveBeenCalledWith(
+          "An error occurred when importing the workflow. Please import a workflow json file."
+        );
+      });
+
+      it("falls back to DEFAULT_WORKFLOW_NAME when the stripped name is empty", async () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.createWorkflow = vi.fn().mockReturnValue(of(makeDashboardWorkflow(1, "x")));
+        vi.spyOn(component, "search").mockResolvedValue(undefined);
+        const content = testWorkflowContent([]);
+        const file = new File([JSON.stringify(content)], ".json");
+
+        await firstValueFrom(component.onClickUploadExistingWorkflowFromLocal(file as any));
+
+        expect(persist.createWorkflow).toHaveBeenCalledWith(content, DEFAULT_WORKFLOW_NAME);
+      });
+
+      // handleZipUploads is intentionally not covered here: its first statement is
+      // `new JSZip()` against the `import * as JSZip from "jszip"` namespace, which
+      // crashes under Vitest ("... is not a constructor"). The same limitation is
+      // documented and skipped in download.service.spec.ts. nameWorkflow's dedup
+      // logic is exercised below with a lightweight fake that mimics `zip.files`.

Review Comment:
   Went with option (1): covered the zip path for real. The `import * as JSZip; new JSZip()` pattern only worked under webpack interop and throws under the esbuild/Vitest runner, so I switched the component to `import JSZip from "jszip"` (default import — works under both) and added a test that builds a real 2-file JSZip archive and asserts `createWorkflow` is invoked once per entry (c0add7f). #6357's zip-import goal is now genuinely met. (`download.service.ts` still has the same `import *` pattern — pre-existing, out of scope for this PR, and only a warning.)



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(frontend): extend UserWorkflowComponent coverage [texera]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #6359:
URL: https://github.com/apache/texera/pull/6359#discussion_r3565408223


##########
frontend/src/app/dashboard/component/user/user-workflow/user-workflow.component.spec.ts:
##########
@@ -357,4 +366,343 @@ describe("SavedWorkflowSectionComponent", () => {
     expect(testWorkflowFileNameConflictEntries[0].checked).toBe(true);
     expect(testWorkflowFileNameConflictEntries[2].checked).toBe(true);
   });
+
+  describe("additional UserWorkflowComponent behaviors", () => {
+    const VIEW_MODE_KEY = "texera.userWorkflow.viewMode";
+
+    const makeDashboardWorkflow = (wid: number | undefined, name: string): DashboardWorkflow => ({
+      workflow: {
+        wid,
+        name,
+        description: "desc",
+        content: testWorkflowContent([]),
+        creationTime: 0,
+        lastModifiedTime: 0,
+        isPublished: 0,
+        readonly: false,
+      },
+      isOwner: true,
+      ownerName: "Texera",
+      accessLevel: "Write",
+      projectIDs: [],
+      ownerId: 1,
+    });
+
+    const makeEntry = (wid: number | undefined, name: string, checked = false): DashboardEntry => {
+      const entry = new DashboardEntry(makeDashboardWorkflow(wid, name));
+      entry.checked = checked;
+      return entry;
+    };
+
+    const setEntries = (entries: DashboardEntry[]): void => {
+      component.searchResultsComponent.entries = entries;
+    };
+
+    afterEach(() => {
+      vi.restoreAllMocks();
+      localStorage.removeItem(VIEW_MODE_KEY);
+    });
+
+    describe("deleteWorkflow", () => {
+      it("deletes an entry with a wid and removes it from the results", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn().mockReturnValue(of(null));
+        const target = makeEntry(5, "to delete");
+        setEntries([target, makeEntry(6, "keep")]);
+
+        component.deleteWorkflow(target);
+
+        expect(persist.deleteWorkflow).toHaveBeenCalledWith([5]);
+        expect(component.searchResultsComponent.entries.map(e => e.name)).toEqual(["keep"]);
+      });
+
+      it("does nothing when the entry has no wid", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn();
+
+        component.deleteWorkflow(makeEntry(undefined, "no wid"));
+
+        expect(persist.deleteWorkflow).not.toHaveBeenCalled();
+      });
+    });
+
+    describe("onClickDuplicateSelectedWorkflows", () => {
+      it("duplicates checked wids without a pid and prepends the new entries", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.duplicateWorkflow = vi
+          .fn()
+          .mockReturnValue(of([makeDashboardWorkflow(101, "dup a"), makeDashboardWorkflow(102, "dup b")]));
+        component.pid = undefined;
+        setEntries([makeEntry(1, "wf 1", true), makeEntry(2, "wf 2", true), makeEntry(3, "wf 3", false)]);
+
+        component.onClickDuplicateSelectedWorkflows();
+
+        expect(persist.duplicateWorkflow).toHaveBeenCalledWith([1, 2]);
+        expect(component.searchResultsComponent.entries.map(e => e.name)).toEqual([
+          "dup a",
+          "dup b",
+          "wf 1",
+          "wf 2",
+          "wf 3",
+        ]);
+      });
+
+      it("passes the pid to duplicateWorkflow when the section belongs to a project", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.duplicateWorkflow = vi.fn().mockReturnValue(of([makeDashboardWorkflow(101, "dup a")]));
+        component.pid = 9;
+        setEntries([makeEntry(1, "wf 1", true), makeEntry(2, "wf 2", true)]);
+
+        component.onClickDuplicateSelectedWorkflows();
+
+        expect(persist.duplicateWorkflow).toHaveBeenCalledWith([1, 2], 9);
+      });
+
+      it("early-returns without calling the service when a checked entry has no wid", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.duplicateWorkflow = vi.fn();
+        setEntries([makeEntry(1, "wf 1", true), makeEntry(undefined, "wf 2", true)]);
+
+        component.onClickDuplicateSelectedWorkflows();
+
+        expect(persist.duplicateWorkflow).not.toHaveBeenCalled();
+      });
+
+      it("alerts on a duplication error", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.duplicateWorkflow = vi.fn().mockReturnValue(throwError(() => "boom"));
+        const alertSpy = vi.spyOn(window, "alert").mockImplementation(() => {});
+        component.pid = undefined;
+        setEntries([makeEntry(1, "wf 1", true)]);
+
+        component.onClickDuplicateSelectedWorkflows();
+
+        expect(alertSpy).toHaveBeenCalledWith("boom");
+      });
+    });
+
+    describe("handleConfirmDeleteSelectedWorkflows", () => {
+      it("deletes checked wids and keeps undefined-wid entries", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn().mockReturnValue(of(null));
+        setEntries([
+          makeEntry(1, "a", true),
+          makeEntry(2, "b", true),
+          makeEntry(undefined, "c", false),
+          makeEntry(3, "d", false),
+        ]);
+
+        component.handleConfirmDeleteSelectedWorkflows();
+
+        expect(persist.deleteWorkflow).toHaveBeenCalledWith([1, 2]);
+        expect(component.searchResultsComponent.entries.map(e => e.name)).toEqual(["c", "d"]);
+      });
+
+      it("early-returns when a checked entry has no wid", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn();
+        setEntries([makeEntry(undefined, "a", true)]);
+
+        component.handleConfirmDeleteSelectedWorkflows();
+
+        expect(persist.deleteWorkflow).not.toHaveBeenCalled();
+      });
+
+      it("alerts on a deletion error", () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.deleteWorkflow = vi.fn().mockReturnValue(throwError(() => "delfail"));
+        const alertSpy = vi.spyOn(window, "alert").mockImplementation(() => {});
+        setEntries([makeEntry(1, "a", true)]);
+
+        component.handleConfirmDeleteSelectedWorkflows();
+
+        expect(alertSpy).toHaveBeenCalledWith("delfail");
+      });
+    });
+
+    describe("onClickOpenDownloadZip", () => {
+      it("does not call the download service when nothing is checked", () => {
+        setEntries([makeEntry(1, "a", false)]);
+
+        component.onClickOpenDownloadZip();
+
+        expect(downloadServiceSpy.downloadWorkflowsAsZip).not.toHaveBeenCalled();
+      });
+
+      it("logs an error when the download fails", () => {
+        setEntries([makeEntry(1, "a", true)]);
+        downloadServiceSpy.downloadWorkflowsAsZip.mockReturnValue(throwError(() => "dlfail"));
+        const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
+
+        component.onClickOpenDownloadZip();
+
+        expect(downloadServiceSpy.downloadWorkflowsAsZip).toHaveBeenCalledWith([{ id: 1, name: "a" }]);
+        expect(errorSpy).toHaveBeenCalledWith("Error downloading workflows:", "dlfail");
+      });
+    });
+
+    describe("workflow uploads", () => {
+      it("imports a valid .json workflow, appending an entry and toasting success", async () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.createWorkflow = vi.fn().mockReturnValue(of(makeDashboardWorkflow(42, "wf")));
+        const searchSpy = vi.spyOn(component, "search").mockResolvedValue(undefined);
+        const successSpy = vi
+          .spyOn(TestBed.inject(NotificationService), "success")
+          .mockImplementation(() => undefined as any);
+        const content = testWorkflowContent([]);
+        const file = new File([JSON.stringify(content)], "wf.json");
+        setEntries([]);
+
+        const result = await firstValueFrom(component.onClickUploadExistingWorkflowFromLocal(file as any));
+
+        expect(result).toBe(false);
+        expect(persist.createWorkflow).toHaveBeenCalledWith(content, "wf");
+        expect(component.searchResultsComponent.entries.map(e => e.name)).toContain("wf");
+        expect(searchSpy).toHaveBeenCalledWith(true);
+        expect(successSpy).toHaveBeenCalledWith("Upload Successful");
+      });
+
+      it("toasts an error and errors the stream when the file is not JSON", async () => {
+        const errorSpy = vi
+          .spyOn(TestBed.inject(NotificationService), "error")
+          .mockImplementation(() => undefined as any);
+        const file = new File(["this is not json"], "bad.json");
+
+        await expect(firstValueFrom(component.onClickUploadExistingWorkflowFromLocal(file as any))).rejects.toThrow();
+
+        expect(errorSpy).toHaveBeenCalledWith(
+          "An error occurred when importing the workflow. Please import a workflow json file."
+        );
+      });
+
+      it("falls back to DEFAULT_WORKFLOW_NAME when the stripped name is empty", async () => {
+        const persist = TestBed.inject(WorkflowPersistService) as any;
+        persist.createWorkflow = vi.fn().mockReturnValue(of(makeDashboardWorkflow(1, "x")));
+        vi.spyOn(component, "search").mockResolvedValue(undefined);
+        const content = testWorkflowContent([]);
+        const file = new File([JSON.stringify(content)], ".json");
+
+        await firstValueFrom(component.onClickUploadExistingWorkflowFromLocal(file as any));
+
+        expect(persist.createWorkflow).toHaveBeenCalledWith(content, DEFAULT_WORKFLOW_NAME);
+      });
+
+      // handleZipUploads is intentionally not covered here: its first statement is
+      // `new JSZip()` against the `import * as JSZip from "jszip"` namespace, which
+      // crashes under Vitest ("... is not a constructor"). The same limitation is
+      // documented and skipped in download.service.spec.ts. nameWorkflow's dedup
+      // logic is exercised below with a lightweight fake that mimics `zip.files`.

Review Comment:
   This block states `handleZipUploads` (the .zip import path) is intentionally not covered due to the `new JSZip()`/`import * as JSZip from "jszip"` constructor crash in Vitest, but the PR description and issue #6357 both list “zip import (real JSZip)” / `handleZipUploads` coverage as an explicit goal and the PR is marked `Closes #6357`. As written, the zip-import behavior is still untested, so the PR metadata/closure appears premature.
   
   Consider either (1) enabling zip-import coverage by fixing the underlying JSZip import/constructor usage (so `new JSZip()` works in Vitest and at runtime) and then adding the `.zip` test, or (2) updating the PR description and removing the issue closure until zip-import coverage is actually added.



-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(frontend): extend UserWorkflowComponent coverage [texera]

Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan merged PR #6359:
URL: https://github.com/apache/texera/pull/6359


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] test(frontend): extend UserWorkflowComponent coverage [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6359:
URL: https://github.com/apache/texera/pull/6359#issuecomment-4949486986

   <!-- texera-reviewer-suggestion -->
   ### Automated Reviewer Suggestions
   
   Based on the `git blame` history of the changed files, we recommend the following reviewers:
   
   - **Contributors with relevant context:** `@Ma77Ball`
     You can notify them by mentioning `@Ma77Ball` in a comment.
   


-- 
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: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org