Skip to content

test(frontend): add spec for BlobErrorHttpInterceptor#5461

Open
mengw15 wants to merge 7 commits into
apache:mainfrom
mengw15:test-5455-blob-interceptor-spec
Open

test(frontend): add spec for BlobErrorHttpInterceptor#5461
mengw15 wants to merge 7 commits into
apache:mainfrom
mengw15:test-5455-blob-interceptor-spec

Conversation

@mengw15

@mengw15 mengw15 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds a unit spec for BlobErrorHttpInterceptor, which previously had none. Covers every branch of intercept():

  • success → passed through unchanged
  • re-thrown unchanged for: a non-HttpErrorResponse error, an HttpErrorResponse whose error is not a Blob, and a Blob error whose type is not application/json
  • an application/json Blob error → parsed into a structured HttpErrorResponse with the original status / statusText / url preserved
  • malformed JSON in the blob, or a FileReader failure → falls back to the original error

The interceptor is driven directly with a stub HttpHandler rather than through HttpClient/HTTP_INTERCEPTORS. Two branches — a non-HttpErrorResponse error and a FileReader failure — cannot be produced through HttpClient (it always wraps errors as HttpErrorResponse, and a readable Blob never triggers FileReader.onerror), so direct invocation is the only way to cover them. Follows frontend/TESTING.md (Vitest).

Any related issues, documentation, discussions?

Closes #5455.

How was this PR tested?

yarn test --include='**/blob-error-http-interceptor.service.spec.ts' → 7 passed. prettier --check clean.

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

Generated-by: Claude Code (claude-opus-4-7)

Cover every branch of intercept(): pass-through on success; re-throw
unchanged for a non-HttpErrorResponse error, a non-Blob error, and a
non-json Blob; parse an application/json Blob error into a structured
HttpErrorResponse with the original status/statusText/url preserved;
and fall back to the original error on malformed JSON or a FileReader
failure.

The interceptor is driven directly with a stub HttpHandler rather than
through HttpClient, because the non-HttpErrorResponse and FileReader-
failure branches cannot be produced through HttpClient.

Closes apache#5455.
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jun 7, 2026
@codecov-commenter

codecov-commenter commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.94%. Comparing base (8803d08) to head (ca1d33c).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5461      +/-   ##
============================================
- Coverage     54.11%   53.94%   -0.18%     
+ Complexity     2819     2787      -32     
============================================
  Files          1103     1101       -2     
  Lines         42650    42590      -60     
  Branches       4588     4587       -1     
============================================
- Hits          23079    22974     -105     
- Misses        18226    18279      +53     
+ Partials       1345     1337       -8     
Flag Coverage Δ *Carryforward flag
access-control-service 70.44% <ø> (ø) Carriedforward from 2e0dd7c
agent-service 34.36% <ø> (ø) Carriedforward from 2e0dd7c
amber 55.28% <ø> (-0.36%) ⬇️ Carriedforward from 2e0dd7c
computing-unit-managing-service 1.65% <ø> (ø) Carriedforward from 2e0dd7c
config-service 57.35% <ø> (ø) Carriedforward from 2e0dd7c
file-service 57.36% <ø> (-1.24%) ⬇️ Carriedforward from 2e0dd7c
frontend 48.13% <ø> (+0.01%) ⬆️
pyamber 90.15% <ø> (-0.05%) ⬇️ Carriedforward from 2e0dd7c
python 90.76% <ø> (ø) Carriedforward from 2e0dd7c
workflow-compiling-service 58.69% <ø> (ø) Carriedforward from 2e0dd7c

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

Pull request overview

Adds a Vitest unit spec for the Angular BlobErrorHttpInterceptor to validate how it handles responseType: "blob" error responses (especially JSON-in-Blob parsing and fallback behavior).

Changes:

  • Introduces blob-error-http-interceptor.service.spec.ts covering success passthrough and multiple error rethrow/parse branches.
  • Uses a stub HttpHandler and direct intercept() invocation to reach branches not realistically producible via HttpClient (non-HttpErrorResponse, FileReader failure).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/src/app/common/service/blob-error-http-interceptor.service.spec.ts Outdated
Comment thread frontend/src/app/common/service/blob-error-http-interceptor.service.spec.ts Outdated
mengw15 and others added 2 commits June 20, 2026 17:08
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Meng Wang <mengw15@uci.edu>
The existing JSON-Blob test used a non-null url, leaving the
`err.url !== null ? err.url : undefined` false branch uncovered. Add a
case where the original HttpErrorResponse has no url so the resulting
error's url is null.

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 3 comments.

Comment thread frontend/src/app/common/service/blob-error-http-interceptor.service.spec.ts Outdated
Comment thread frontend/src/app/common/service/blob-error-http-interceptor.service.spec.ts Outdated
Comment thread frontend/src/app/common/service/blob-error-http-interceptor.service.spec.ts Outdated
mengw15 and others added 3 commits June 20, 2026 17:30
…erceptor spec

Address review feedback: rename the two structured-error tests to match
what they assert, verify the interceptor returns a *new* HttpErrorResponse
(not the original), and assert the original headers are preserved on the
parsed error.
@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.

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 spec for blob-error-http-interceptor.service.ts

3 participants