Skip to content

test(frontend): add unit tests for WorkflowSnapshotService#6466

Open
Ma77Ball wants to merge 2 commits into
apache:mainfrom
Ma77Ball:test/workflow-snapshot-service-spec
Open

test(frontend): add unit tests for WorkflowSnapshotService#6466
Ma77Ball wants to merge 2 commits into
apache:mainfrom
Ma77Ball:test/workflow-snapshot-service-spec

Conversation

@Ma77Ball

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

  • Adds workflow-snapshot.service.spec.ts covering WorkflowSnapshotService; no production code changed.
  • Verifies canvas capture via a mocked html2canvas (ratio math and document.body fallback).
  • Verifies the multipart upload (FormData wid handling, including undefined) and the retrieve endpoint.

Any related issues, documentation, discussions?

Closes: #6454

How was this PR tested?

  • Run cd frontend && npx nx test gui --include="**/workflow-snapshot.service.spec.ts", expect 6 passed.
  • Full frontend suite runs in CI via yarn test:ci, selected by the auto-applied frontend label.

Was this PR authored or co-authored using generative AI tooling?

Co-authored with Claude Opus 4.8 in compliance with ASF

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@codecov-commenter

codecov-commenter commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.20%. Comparing base (c7473a1) to head (370a4c3).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6466      +/-   ##
============================================
- Coverage     70.20%   70.20%   -0.01%     
  Complexity     3390     3390              
============================================
  Files          1142     1142              
  Lines         44844    44844              
  Branches       4949     4949              
============================================
- Hits          31484    31481       -3     
- Misses        11725    11726       +1     
- Partials       1635     1637       +2     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 6f90d15
agent-service 76.76% <ø> (ø) Carriedforward from 6f90d15
amber 66.68% <ø> (ø) Carriedforward from 6f90d15
computing-unit-managing-service 9.97% <ø> (ø) Carriedforward from 6f90d15
config-service 52.30% <ø> (ø) Carriedforward from 6f90d15
file-service 65.63% <ø> (ø) Carriedforward from 6f90d15
frontend 68.96% <ø> (-0.01%) ⬇️
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 6f90d15
pyamber 91.19% <ø> (ø) Carriedforward from 6f90d15
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 6f90d15

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment on lines +28 to +30
// createSnapShotCanvas() delegates to html2canvas, whose module-level mock is not
// reliable here (other specs import it unmocked and the builder shares one module
// registry), so it is exercised in the e2e/browser suite rather than pinned here.
Comment on lines +52 to +72
describe("uploadWorkflowSnapshot", () => {
it("PUTs a multipart form with the blob and stringified wid", () => {
const blob = new Blob(["img"], { type: "image/png" });
service.uploadWorkflowSnapshot(blob, 12).subscribe();

const req = httpMock.expectOne(WORKFLOW_SNAPSHOT_UPLOAD_URL);
expect(req.request.method).toEqual("PUT");
const body = req.request.body as FormData;
expect(body.get("wid")).toEqual("12");
expect(body.get("SnapshotBlob")).toBeInstanceOf(Blob);
req.flush({});
});

it("sends an empty wid string when wid is undefined", () => {
service.uploadWorkflowSnapshot(new Blob([]), undefined).subscribe();

const req = httpMock.expectOne(WORKFLOW_SNAPSHOT_UPLOAD_URL);
expect((req.request.body as FormData).get("wid")).toEqual("");
req.flush({});
});
});
@Yicong-Huang

Copy link
Copy Markdown
Contributor

is this service even used? it might be dead code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add frontend unit tests for WorkflowSnapshotService

4 participants