Skip to content

Flutter tests: mock Firebase, add unit tests#71

Closed
code418 wants to merge 1 commit intomasterfrom
feature/flutter-tests
Closed

Flutter tests: mock Firebase, add unit tests#71
code418 wants to merge 1 commit intomasterfrom
feature/flutter-tests

Conversation

@code418
Copy link
Copy Markdown
Owner

@code418 code418 commented Apr 6, 2026

Summary

  • Rewrites test/widget_test.dart to use fake_cloud_firestore, firebase_auth_mocks, and firebase_core_platform_interface so tests run without real Firebase
  • Adds unit tests for UserRepository and StreakService

Files changed

  • test/widget_test.dart — mocked Firebase setup + unit tests
  • pubspec.yaml — adds dev dependencies: firebase_core_platform_interface ^5.0.0, fake_cloud_firestore ^3.0.0, firebase_auth_mocks ^0.14.0

Merge notes

⚠️ Conflicts with feature/phase4-polish (pubspec.yaml dev dependencies).
Both modify dev_dependencies. Resolution: keep flutter_lints from phase4-polish; add test mocks from this branch.

@code418 code418 force-pushed the feature/flutter-tests branch 2 times, most recently from 5d67b26 to 161bb21 Compare April 7, 2026 21:12
…StreakService

dev_dependencies:
  firebase_core_platform_interface ^5.0.0  — setupFirebaseCoreMocks()
  fake_cloud_firestore ^3.0.0              — in-memory Firestore
  firebase_auth_mocks ^0.14.0              — MockFirebaseAuth / MockUser

test/widget_test.dart rewrites the broken placeholder test with:
- setupFirebaseMocks() in setUpAll so Firebase.initializeApp() succeeds
- Smoke test: Splash/loading widget renders without crash
- UserRepository tests: signUp writes displayName, getDisplayName reads it,
  returns null for unknown uid, isSignedIn false when no user
- StreakService logic tests: first claim sets streak to 1; same-day call
  is idempotent (does not reset streak)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@code418 code418 force-pushed the feature/flutter-tests branch from 161bb21 to c3fe28f Compare April 7, 2026 21:17
@code418
Copy link
Copy Markdown
Owner Author

code418 commented Apr 12, 2026

All changes from this branch have been implemented in subsequent commits on master — this PR is superseded and no longer needed.

@code418 code418 closed this Apr 12, 2026
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