Skip to content

fix(test): Repair skipped and broken tests in onboarding and AppleSignInButton #156

@claude

Description

@claude

Summary

Several tests are currently skipped or broken, leaving critical error handling paths untested.

Related to: #154 (Daily Codebase Review - 2025-12-16)

Problem

1. Skipped Test in Onboarding

File: __tests__/app/onboarding.test.tsx:639-641

// TODO: Fix this test - the mock upsert isn't being called for unknown reasons
// after migrating from update() to upsert()
it.skip('shows error alert when profile update fails', async () => {

Issue: After migrating from update() to upsert(), the mock setup stopped working. The test was skipped instead of fixed.

Impact: Error handling for profile update failures is not validated.

2. Broken Analytics Tests in AppleSignInButton

File: __tests__/components/auth/AppleSignInButton.test.tsx:1274,1324

// TODO: Fix these tests - they were added by CodeRabbit but are not working
// The async flow is not completing properly. Need to investigate mock setup.

Affected test suites:

  • "Analytics tracking edge cases" (lines 1276-1318)
  • "Profile update edge cases" (lines 1326+)

Issue: Async flows are not completing properly due to mock setup issues.

Impact: Apple Sign-In analytics tracking and profile update edge cases are not tested.

Root Cause Analysis

Onboarding Test

The migration from .update() to .upsert() changed how Supabase client methods are called. The mock needs to be updated:

// Current mock (not working)
supabase.from('profiles').update().eq().select().single.mockResolvedValueOnce({ ... });

// Likely needed
supabase.from('profiles').upsert().select().single.mockResolvedValueOnce({ ... });

AppleSignInButton Tests

The async completion issue likely stems from:

  1. Promise resolution timing
  2. Mock setup for signInWithIdToken
  3. Analytics call verification timing

Acceptance Criteria

  • Remove .skip from onboarding test and fix mock setup
  • Fix async flow completion in AppleSignInButton tests
  • All tests pass with pnpm test
  • No new test skips introduced

Priority

HIGH - Error handling and authentication edge cases should be tested

Files to Modify

  • __tests__/app/onboarding.test.tsx
  • __tests__/components/auth/AppleSignInButton.test.tsx

Estimated Effort

2-3 hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    authenticationAuthentication related issuestestingTesting related changes

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions