Skip to content

Conversation

@ShivaGupta-14
Copy link
Contributor

@ShivaGupta-14 ShivaGupta-14 commented Nov 24, 2025

HomePage Test Coverage & Stability Improvements

Description

This PR significantly improves the reliability and observability of the HomePage by expanding the Jest test suite, fixing unreachable logic, hardening WebSocket behavior, and resolving an SSR-related branch coverage issue.

  • Added 30+ unit tests covering:

    • Task fetching logic: success, error, and loading states
    • WebSocket behavior: successful connection, failures, and malformed messages
    • Toast notifications for all job types
    • Component rendering and prop passing
    • Onboarding tour flow:
      • first-time users
      • already-seen users
      • skip button behavior
      • timeout cleanup
      • multiple-render guard
  • Improved overall test coverage to ~90%+ (statements, branches, and functions)

  • Fix unreachable WebSocket success-branch:

    • Previously the code checked data.status === 'success' twice
    • The outer condition made the inner else if (data.status === 'success') unreachable
    • Refactored the logic so all job-type toast notifications execute correctly within the main success block
  • Fixed HomePage SSR bug:

    • Replaced direct typeof window === 'undefined' checks with an SSR-safe ignored helper
    • Prevents Istanbul false negatives and ensures stable branch logic across environments
  • Added clearer test organization using nested describe blocks

  • Cleaned up mocks and standardized formatting for better long-term maintainability

Fixes: #191

Checklist

  • Ran npx prettier --write . (for formatting)
  • Ran gofmt -w . (for Go backend)
  • Ran npm test (for JS/TS testing)
  • Added unit tests, if applicable
  • Verified all tests pass
  • Updated documentation, if needed

Additional Notes

Screenshots

  • Before:

    Screenshot 2025-11-24 at 10 39 13 PM
  • After:

    Screenshot 2025-11-24 at 10 40 44 PM

…cket branch

- Implement 25+ unit tests covering:
  • Task fetching logic (success, error, loading)
  • WebSocket behaviors (success, failure, malformed JSON, unknown job)
  • Toast notifications for all job types
  • Component rendering and prop passing
  • Onboarding tour flow:
    – first-time users
    – already seen
    – skip button behavior
    – timeout cleanup
    – multiple render guard

- Improve overall test coverage to ~90%+ (statements, branches, funcs)

- Fix unreachable WebSocket success-branch:
  • Code previously checked `data.status === 'success'` twice
  • The outer `if` made the inner `else if (data.status === 'success')` unreachable
  • Refactored logic so job-based toast branches always execute under the main success block

- Fix SSR guard:
  • Replaced direct `typeof window === 'undefined'` with an Istanbul-ignored guard
  • Prevents false negatives in coverage reports

- Organize tests using nested `describe` blocks
- Clean up mocks, remove commented code, and standardize formatting
@its-me-abhishek its-me-abhishek merged commit 312d413 into CCExtractor:main Nov 25, 2025
4 checks passed
@ShivaGupta-14 ShivaGupta-14 deleted the feat/191-homepage-test-improvements branch November 25, 2025 20:56
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.

Bump Test Coverage for HomePage

2 participants