test(medium): Fix component test errors and suppress console noise#9444
test(medium): Fix component test errors and suppress console noise#9444
Conversation
- Suppressed 'QuotaExceeded' console.error in usePersistentStorage.test.ts - Suppressed noisy console.log, info, and warn in SpotifyDisplay, useBluetoothHRM, env, and GoogleDocViewer tests - Updated token-delivery API test to correctly mock the logger utility - Verified all tests pass with significantly cleaner console output Co-authored-by: arii <342438+arii@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
👋 Welcome to HRM!Thanks for your contribution. This repository uses Gemini AI for automated triage, code review, and generation. 🤖 Gemini Manual Trigger Quick Reference
For more details and GitHub CLI examples, see the Manual Trigger Guide. |
ℹ️ Gemini Review DisabledAutomatic review is currently disabled via Via Comment: Via GitHub Actions:
Via GitHub CLI: gh workflow run reusable-gemini-review.yml -f pr_number=9444🤖 Manual Trigger Quick Reference
Full reference: Manual Trigger Guide To re-enable: Set repository variable |
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Manual Trigger Quick Reference
|
- Suppressed 'QuotaExceeded' console.error in usePersistentStorage.test.ts - Suppressed noisy console.log, info, and warn in SpotifyDisplay, useBluetoothHRM, env, and GoogleDocViewer tests - Suppressed console noise in API route tests (access-token, devices, playlists) - Updated token-delivery API test to correctly mock the logger utility - Fixed lint error in env.test.ts - Verified all tests pass with significantly cleaner console output Co-authored-by: arii <342438+arii@users.noreply.github.com>
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Manual Trigger Quick Reference
|
🤖 AI Technical AuditCode Review: PR #9444SummaryThis PR addresses test hygiene by suppressing expected console noise in Jest tests. While the intent is correct, the implementation introduces a significant risk of test pollution due to unsafe spy restoration handling. If an assertion fails before
|
🤖 AI Technical AuditCode Review for PR #9444🛡️ Anti-AI-Slop Directives
🚨 Critical Architectural Issues1. Unsafe Spy Restoration (Test Pollution)In almost all updated test files (e.g., Problem: If an Implementation Sample (Fix): // BAD
it('should return 401', async () => {
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
// ... test logic ...
expect(response.status).toBe(401); // If this fails, spy is never restored
spy.mockRestore();
});
// GOOD (Option A: Local Try/Finally)
it('should return 401', async () => {
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
try {
// ... test logic ...
expect(response.status).toBe(401);
} finally {
spy.mockRestore(); // Runs even if expect fails
}
});
// GOOD (Option B: Lifecycle methods - Preferred for repeated usage)
describe('API Route', () => {
let errorSpy: jest.SpyInstance;
beforeEach(() => {
errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
});
afterEach(() => {
errorSpy.mockRestore();
});
// ... tests ...
});2. Mock Path ConsistencyFile: Problem: You changed the mock path from - jest.mock('@/utils/logger.server', () => ({
+ jest.mock('@/utils/logger', () => ({If the source code ( File-by-File Feedback
|
…ests - Suppressed expected console noise (errors, logs, warnings) across multiple test files. - Implemented safe spy restoration using lifecycle hooks (`beforeEach`, `afterEach`) or `try...finally` blocks to prevent test pollution. - Reverted unnecessary test reordering in `env.test.ts` to reduce diff noise. - Updated `token-delivery/route.test.ts` mock path to match source import. - Verified all tests pass with cleaner output and guaranteed teardown. Co-authored-by: arii <342438+arii@users.noreply.github.com>
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Manual Trigger Quick Reference
|
🤖 AI Technical AuditCode Review: PR #9444This PR effectively addresses test log noise by implementing However, there is a potential regression regarding test isolation. In several files,
|
- Implemented safe spy restoration using lifecycle hooks (`beforeEach`/`afterEach`) and `try...finally` blocks to prevent test pollution. - Restored `jest.clearAllMocks()` in several suites to maintain mock call history integrity. - Removed redundant logic and reverted unnecessary diff noise in `env.test.ts`. - Suppressed expected logs in `token-delivery/route.test.ts`. - Verified all tests pass with cleaner output and robust teardown. Co-authored-by: arii <342438+arii@users.noreply.github.com>
🤖 Gemini Review SkippedReview was skipped for the following reason: 🤖 Manual Trigger Quick Reference
|
Description
This change addresses the issue of cluttered test logs by suppressing expected console messages in various unit tests using Jest spies. It specifically fixes the reported 'QuotaExceeded' error noise and other identified log points across hooks, components, and API route tests.
Fixes #9442
Change Type: 🐛 Bug fix (non-breaking change fixing an issue)
Related Issues
Closes #9442
Changes Made
Testing
Original PR Body
This change addresses the issue of cluttered test logs by suppressing expected console messages in various unit tests using Jest spies. It specifically fixes the reported 'QuotaExceeded' error noise and other identified log points across hooks, components, and API route tests.
Fixes #9442
PR created automatically by Jules for task 12837448378175141024 started by @arii