Skip to content

Improve Account component tests #3

@michaelstingl

Description

@michaelstingl

Background

We recently improved error handling in our app by replacing the 'Max Mustermann (Recovery)' fallback user with proper error messages that include the Request ID for easier debugging. While we have good unit tests for the ApiService error handling, the Account component tests need improvement.

Current Issues

The Account component tests currently fail because:

  • Mock implementation is incomplete
  • React Native's async rendering isn't properly handled
  • Context providers for navigation are missing
  • __DEV__ flag handling needs to be addressed

Required Improvements

  1. Better Mocking:

    • Improve mocks for React Native components
    • Properly mock router functionality and navigation
    • Add mock for __DEV__ flag as the component relies on it
  2. Test Environment Adjustments:

    • Provide proper React Navigation/Expo Router context
    • Improve waiting mechanisms for async UI updates
    • Correctly handle state changes
  3. More Granular Test Cases:

    • Write isolated tests for different paths (Loading, Error, Success)
    • Query UI elements more precisely instead of relying on text content
    • Test callback functions (button clicks, refresh, etc.)

Acceptance Criteria

  • All Account component tests pass successfully
  • Tests verify that error messages include Request ID
  • Different UI states (loading, error, success) are tested properly
  • Code coverage for Account component is increased

Related Changes

This is related to the recent error handling improvements where we've replaced the 'Max Mustermann (Recovery)' fallback user with proper error messages that include Request IDs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority-mediumMedium priority issuestech-debtTechnical debt and code qualitytestingRelated to automated tests

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions