Skip to content

test(frontend): add unit test coverage for extractErrorMessage#6321

Open
rbelavadi wants to merge 2 commits into
apache:mainfrom
rbelavadi:test/6254-extract-error-message-coverage
Open

test(frontend): add unit test coverage for extractErrorMessage#6321
rbelavadi wants to merge 2 commits into
apache:mainfrom
rbelavadi:test/6254-extract-error-message-coverage

Conversation

@rbelavadi

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds error.spec.ts to cover extractErrorMessage, a previously untested pure utility function in common/util/ that normalizes errors of unknown shape into a display-safe string. Covers all four behavior branches: a native Error instance, an object with a string error key, an object with a nested { error: { message } } shape, and fallback behavior for unrecognized shapes (null, number, empty object, malformed error key).

No production code was changed.

Any related issues, documentation, discussions?

Closes #6254

How was this PR tested?

Added 7 new unit tests in error.spec.ts covering all branches described in the issue. Ran locally via npx ng test --include='**/error.spec.ts'; all 7 pass.

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

No.

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 10, 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.

@rbelavadi

Copy link
Copy Markdown
Contributor Author

/request-review @xuang7

@github-actions github-actions Bot requested a review from xuang7 July 10, 2026 21:21
@codecov-commenter

codecov-commenter commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.00%. Comparing base (45c82a5) to head (ff1a1c5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6321      +/-   ##
============================================
- Coverage     61.02%   61.00%   -0.02%     
  Complexity     3375     3375              
============================================
  Files          1140     1140              
  Lines         44923    44923              
  Branches       4942     4942              
============================================
- Hits          27413    27407       -6     
- Misses        16001    16008       +7     
+ Partials       1509     1508       -1     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 45c82a5
agent-service 44.59% <ø> (ø) Carriedforward from 45c82a5
amber 66.40% <ø> (ø) Carriedforward from 45c82a5
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 45c82a5
config-service 52.30% <ø> (ø) Carriedforward from 45c82a5
file-service 63.97% <ø> (ø) Carriedforward from 45c82a5
frontend 53.30% <ø> (-0.02%) ⬇️
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 45c82a5
pyamber 91.18% <ø> (ø) Carriedforward from 45c82a5
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 45c82a5

*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

This PR adds frontend unit test coverage for extractErrorMessage (frontend/src/app/common/util/error.ts), a shared UI utility that normalizes unknown error shapes into a user-facing string.

Changes:

  • Added frontend/src/app/common/util/error.spec.ts with 7 unit tests covering the currently documented branches (native Error, { error: string }, { error: { message } }, and several fallback inputs).

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

Comment on lines +35 to +39
it("should return the nested message when error is an object with a message", () => {
const testError = { error: { message: "nested" } };
const result = extractErrorMessage(testError);
expect(result).toBe(testError.error.message);
});

@xuang7 xuang7 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.

LGTM overall. Please also add a { error: null } case. Worth a backendErr !== null guard in error.ts too so it falls back instead of throwing.

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 unit test coverage for extractErrorMessage

4 participants