Skip to content

✨ Quality: Improve test coverage - useAIPrompt - #88

Merged
galiprandi merged 1 commit into
mainfrom
quality/useAIPrompt-coverage-improvement-3194697612275854990
Jun 11, 2026
Merged

✨ Quality: Improve test coverage - useAIPrompt#88
galiprandi merged 1 commit into
mainfrom
quality/useAIPrompt-coverage-improvement-3194697612275854990

Conversation

@galiprandi

Copy link
Copy Markdown
Owner

💡 What: This improvement adds 13 new test cases to lib/hooks/useAIPrompt.test.ts, targeting previously uncovered branches in the useAIPrompt hook.

🎯 Why: The useAIPrompt hook had several untested logic paths, particularly around multimodal content type inference and defensive checks for browser-specific AI APIs.

📊 Impact:

  • Statement coverage for useAIPrompt.ts increased from 77.86% to 99.23%.
  • Branch coverage increased from 52.21% to 92.03%.
  • Ensures the hook robustly handles various input types (AudioBuffer, visual elements), correctly cleans up internal state on unmount, and gracefully handles model initialization failures.

✅ Verification:

  • Ran pnpm test lib/hooks/useAIPrompt.test.ts (all 26 tests passed).
  • Ran pnpm test:coverage to verify the improvement.
  • Ran pnpm lint to ensure no regression in code quality.

PR created automatically by Jules for task 3194697612275854990 started by @galiprandi

Added comprehensive unit tests to lib/hooks/useAIPrompt.test.ts to cover
missing branches in lib/hooks/useAIPrompt.ts.

- Added tests for inferContentType covering all visual and audio types.
- Added tests for createSession error branches (constructor checks, missing API).
- Added tests for prompt and append error handling (non-Error objects, AbortError).
- Added tests for warmup failure and component unmount cleanup.
- Improved line coverage to >99% and branch coverage to >92%.
- Addressed lint errors in the test file.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@galiprandi
galiprandi merged commit 6fc1dd6 into main Jun 11, 2026
4 checks passed
@galiprandi
galiprandi deleted the quality/useAIPrompt-coverage-improvement-3194697612275854990 branch June 15, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant