You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "mengw15 (via GitHub)" <gi...@apache.org> on 2026/08/15 03:44:19 UTC

[PR] test(frontend): cover DatasetDetail upload failures and the remaining template controls [texera]

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

   ### What changes were proposed in this PR?
   
   Extends the `DatasetDetailComponent` spec with the upload failure handling and the
   template controls that were still unexecuted. No production code was changed.
   
   **Upload failures** (+5) — driven by erroring the spec's existing upload subject,
   so no real time passes:
   
   - a `409` produces the specific "Upload blocked (409)" notification, any other
     status the generic `"Upload failed. Please retry."`;
   - the task is marked `failed` and **keeps its progress** (a partially uploaded
     file stays at 42%, rather than being left at 100);
   - the concurrency slot is freed, so a queued fourth upload starts;
   - the `taskIndex === -1` arm still reports the failure.
   
   **Template** (+7) — contributor rows and their actions trigger, edit and delete,
   the toolbar's download and scale controls, and the sider resize.
   
   Three notes on how the DOM actually behaves here, recorded in comments:
   
   - The toolbar's download/scale buttons sit behind `*ngIf="selectedVersion"`, so
     the tests seed a version; the scale icon is `expand`/`compress`.
   - A contributor's Edit/Delete items live in an `nz-dropdown-menu`, which only
     mounts into a CDK overlay on a real user open — jsdom does not drive that.
     Those two tests assert the handlers the menu items bind to, while a separate
     test asserts the rendered rows and one dropdown trigger per contributor.
   - `onSideResize` defers to `requestAnimationFrame`; the test awaits a real frame
     and asserts `siderWidth`, and a second test spies `cancelAnimationFrame` to
     check the previous frame is dropped. No fake timers are introduced, and no
     pixel width is asserted (zero under jsdom).
   
   ### Any related issues, documentation, discussions?
   
   Closes #7679
   
   ### 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/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.spec.ts
   # Test Files 1 passed (1) | Tests 141 passed (141)
   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])
   


-- 
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): cover DatasetDetail upload failures and the remaining template controls [texera]

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


##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.spec.ts:
##########
@@ -2050,5 +2109,99 @@ describe("DatasetDetailComponent behavior", () => {
       switches[1].triggerEventHandler("ngModelChange", false);
       expect(datasetServiceStub.updateDatasetDownloadable).toHaveBeenCalledWith(5);
     });
+
+    // ─── contributor management ─────────────────────────────────────────────
+    const contributors = [
+      { name: "Ada", email: "ada@x.io", affiliation: "" } as Contributor,
+      { name: "Grace", email: "grace@x.io", affiliation: "" } as Contributor,
+    ];
+
+    it("renders a row per contributor with the actions trigger", () => {
+      renderWith({ did: 5, datasetContributors: [...contributors], userDatasetAccessLevel: "WRITE" });
+
+      const rendered = fixture.nativeElement.textContent ?? "";
+      expect(rendered).toContain("Ada");
+      expect(rendered).toContain("Grace");
+      // each row carries the dropdown trigger that hosts Edit/Delete
+      const triggers = fixture.debugElement
+        .queryAll(By.css("button[nz-dropdown]"))
+        .filter(btn => btn.nativeElement.querySelector("i.anticon-more"));
+      expect(triggers.length).toBe(contributors.length);
+    });
+
+    // Edit/Delete live inside an nz-dropdown-menu, which only mounts into a CDK overlay on a
+    // real user open — jsdom does not drive that. Assert the handlers those menu items bind to
+    // instead; the rendered trigger is covered above.
+    it("edits the chosen contributor through the menu's binding target", () => {
+      const updated = { ...contributors[0], affiliation: "Lab" };
+      modalServiceStub.create.mockReturnValue({ afterClose: of(updated) });
+      renderWith({ did: 5, datasetContributors: [...contributors], userDatasetAccessLevel: "WRITE" });
+
+      component.onEditContributor(contributors[0]);
+
+      expect(component.datasetContributors[0]).toEqual(updated);
+    });
+
+    it("deletes the chosen contributor through the popconfirm's binding target", () => {
+      renderWith({ did: 5, datasetContributors: [...contributors], userDatasetAccessLevel: "WRITE" });
+
+      component.onDeleteContributor(contributors[0]);
+
+      expect(component.datasetContributors.map(c => c.name)).toEqual(["Grace"]);
+    });
+
+    // ─── view controls ──────────────────────────────────────────────────────
+
+    it("downloads the current file from the toolbar", () => {
+      // the toolbar controls are behind *ngIf="selectedVersion"
+      renderWith({ did: 5, selectedVersion: { dvid: 1, name: "v1" } as DatasetVersion });
+      openTab("Versions & Files");
+      const onDownload = vi.spyOn(component, "onClickDownloadCurrentFile").mockImplementation(() => {});
+
+      const downloadBtn = fixture.debugElement
+        .queryAll(By.css("button"))
+        .find(btn => btn.nativeElement.querySelector("i.anticon-download"));
+      expect(downloadBtn).toBeTruthy();
+      downloadBtn!.triggerEventHandler("click", null);
+
+      expect(onDownload).toHaveBeenCalled();
+    });
+
+    it("toggles the scaled view from the toolbar", () => {
+      renderWith({ did: 5, isMaximized: false, selectedVersion: { dvid: 1, name: "v1" } as DatasetVersion });
+      openTab("Versions & Files");
+
+      const scaleBtn = fixture.debugElement
+        .queryAll(By.css("button"))
+        .find(btn => btn.nativeElement.querySelector("i.anticon-expand, i.anticon-compress"));
+      expect(scaleBtn).toBeTruthy();
+      scaleBtn!.triggerEventHandler("click", null);
+      fixture.detectChanges();
+
+      expect(component.isMaximized).toBe(true);
+    });
+
+    // ─── sider resize ───────────────────────────────────────────────────────
+
+    it("applies the dragged sider width on the next animation frame", async () => {
+      renderWith({ did: 5 });
+
+      component.onSideResize({ width: 321 } as NzResizeEvent);
+      // the handler defers to requestAnimationFrame; let that frame run
+      await new Promise(resolve => requestAnimationFrame(() => resolve(null)));
+
+      expect(component.siderWidth).toBe(321);
+    });
+
+    it("cancels a pending resize frame before scheduling the next one", () => {
+      renderWith({ did: 5 });
+      const cancel = vi.spyOn(globalThis, "cancelAnimationFrame");
+
+      component.onSideResize({ width: 100 } as NzResizeEvent);
+      component.onSideResize({ width: 200 } as NzResizeEvent);
+
+      expect(cancel).toHaveBeenCalled();
+      cancel.mockRestore();
+    });

Review Comment:
   This test asserts `cancelAnimationFrame` was called, but the first `onSideResize` call already invokes `cancelAnimationFrame(this.id)` with the initial `id = -1`. That means the assertion can pass even if a previously scheduled frame is never canceled. Consider also spying on `requestAnimationFrame` to return a known id, clear the cancel spy after the first call, and then assert the second call cancels the first id (e.g., `toHaveBeenCalledWith(100)`).



-- 
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): cover DatasetDetail upload failures and the remaining template controls [texera]

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

   ## [Codecov](https://app.codecov.io/gh/apache/texera/pull/7682?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 90.27%. Comparing base ([`4b526eb`](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ab2a7ed`](https://app.codecov.io/gh/apache/texera/commit/ab2a7ed20e61a1bcbb783b2ae398a72b5ac54f3c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 1 commits behind head on main.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##               main    #7682      +/-   ##
   ============================================
   + Coverage     90.24%   90.27%   +0.02%     
     Complexity     4415     4415              
   ============================================
     Files          1175     1175              
     Lines         47131    47131              
     Branches       5285     5285              
   ============================================
   + Hits          42533    42546      +13     
   + Misses         2834     2819      -15     
   - Partials       1764     1766       +2     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/texera/pull/7682/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/7682/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 [4b526eb](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?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/7682/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `98.62% <ø> (ø)` | | Carriedforward from [4b526eb](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?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/7682/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `86.79% <ø> (ø)` | | Carriedforward from [4b526eb](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?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/7682/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `72.46% <ø> (ø)` | | Carriedforward from [4b526eb](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?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/7682/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `77.55% <ø> (ø)` | | Carriedforward from [4b526eb](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?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/7682/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `68.90% <ø> (ø)` | | Carriedforward from [4b526eb](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?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/7682/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `91.69% <ø> (+0.06%)` | :arrow_up: | |
   | [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/7682/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `79.31% <ø> (ø)` | | Carriedforward from [4b526eb](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?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/7682/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `97.57% <ø> (ø)` | | Carriedforward from [4b526eb](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?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/7682/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `57.89% <ø> (ø)` | | Carriedforward from [4b526eb](https://app.codecov.io/gh/apache/texera/commit/4b526eb26afcce34467d50b6ff597f4f06642dde?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/7682?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): cover DatasetDetail upload failures and the remaining template controls [texera]

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


##########
frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/dataset-detail.component.spec.ts:
##########
@@ -2050,5 +2109,99 @@ describe("DatasetDetailComponent behavior", () => {
       switches[1].triggerEventHandler("ngModelChange", false);
       expect(datasetServiceStub.updateDatasetDownloadable).toHaveBeenCalledWith(5);
     });
+
+    // ─── contributor management ─────────────────────────────────────────────
+    const contributors = [
+      { name: "Ada", email: "ada@x.io", affiliation: "" } as Contributor,
+      { name: "Grace", email: "grace@x.io", affiliation: "" } as Contributor,
+    ];
+
+    it("renders a row per contributor with the actions trigger", () => {
+      renderWith({ did: 5, datasetContributors: [...contributors], userDatasetAccessLevel: "WRITE" });
+
+      const rendered = fixture.nativeElement.textContent ?? "";
+      expect(rendered).toContain("Ada");
+      expect(rendered).toContain("Grace");
+      // each row carries the dropdown trigger that hosts Edit/Delete
+      const triggers = fixture.debugElement
+        .queryAll(By.css("button[nz-dropdown]"))
+        .filter(btn => btn.nativeElement.querySelector("i.anticon-more"));
+      expect(triggers.length).toBe(contributors.length);
+    });
+
+    // Edit/Delete live inside an nz-dropdown-menu, which only mounts into a CDK overlay on a
+    // real user open — jsdom does not drive that. Assert the handlers those menu items bind to
+    // instead; the rendered trigger is covered above.
+    it("edits the chosen contributor through the menu's binding target", () => {
+      const updated = { ...contributors[0], affiliation: "Lab" };
+      modalServiceStub.create.mockReturnValue({ afterClose: of(updated) });
+      renderWith({ did: 5, datasetContributors: [...contributors], userDatasetAccessLevel: "WRITE" });
+
+      component.onEditContributor(contributors[0]);
+
+      expect(component.datasetContributors[0]).toEqual(updated);
+    });
+
+    it("deletes the chosen contributor through the popconfirm's binding target", () => {
+      renderWith({ did: 5, datasetContributors: [...contributors], userDatasetAccessLevel: "WRITE" });
+
+      component.onDeleteContributor(contributors[0]);
+
+      expect(component.datasetContributors.map(c => c.name)).toEqual(["Grace"]);
+    });
+
+    // ─── view controls ──────────────────────────────────────────────────────
+
+    it("downloads the current file from the toolbar", () => {
+      // the toolbar controls are behind *ngIf="selectedVersion"
+      renderWith({ did: 5, selectedVersion: { dvid: 1, name: "v1" } as DatasetVersion });
+      openTab("Versions & Files");
+      const onDownload = vi.spyOn(component, "onClickDownloadCurrentFile").mockImplementation(() => {});
+
+      const downloadBtn = fixture.debugElement
+        .queryAll(By.css("button"))
+        .find(btn => btn.nativeElement.querySelector("i.anticon-download"));
+      expect(downloadBtn).toBeTruthy();
+      downloadBtn!.triggerEventHandler("click", null);
+
+      expect(onDownload).toHaveBeenCalled();
+    });
+
+    it("toggles the scaled view from the toolbar", () => {
+      renderWith({ did: 5, isMaximized: false, selectedVersion: { dvid: 1, name: "v1" } as DatasetVersion });
+      openTab("Versions & Files");
+
+      const scaleBtn = fixture.debugElement
+        .queryAll(By.css("button"))
+        .find(btn => btn.nativeElement.querySelector("i.anticon-expand, i.anticon-compress"));
+      expect(scaleBtn).toBeTruthy();
+      scaleBtn!.triggerEventHandler("click", null);
+      fixture.detectChanges();
+
+      expect(component.isMaximized).toBe(true);
+    });
+
+    // ─── sider resize ───────────────────────────────────────────────────────
+
+    it("applies the dragged sider width on the next animation frame", async () => {
+      renderWith({ did: 5 });
+
+      component.onSideResize({ width: 321 } as NzResizeEvent);
+      // the handler defers to requestAnimationFrame; let that frame run
+      await new Promise(resolve => requestAnimationFrame(() => resolve(null)));
+
+      expect(component.siderWidth).toBe(321);
+    });
+
+    it("cancels a pending resize frame before scheduling the next one", () => {
+      renderWith({ did: 5 });
+      const cancel = vi.spyOn(globalThis, "cancelAnimationFrame");
+
+      component.onSideResize({ width: 100 } as NzResizeEvent);
+      component.onSideResize({ width: 200 } as NzResizeEvent);
+
+      expect(cancel).toHaveBeenCalled();
+      cancel.mockRestore();
+    });

Review Comment:
   Right — the component starts with `id = -1`, so the first `onSideResize` already called `cancelAnimationFrame` and the assertion couldn't fail. Now `requestAnimationFrame` is stubbed to hand out id `100`, the spy is cleared after the first call, and the second call is asserted to cancel `100`. Verified it now fails if the component stops tracking the frame id (the old assertion still passed in that case).



-- 
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): cover DatasetDetail upload failures and the remaining template controls [texera]

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

   <!-- 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:** `@aglinxinyuan`
     You can notify them by mentioning `@aglinxinyuan` 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


Re: [PR] test(frontend): cover DatasetDetail upload failures and the remaining template controls [texera]

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


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