Skip to content

CodeRabbit Generated Unit Tests: Add analytics unit tests for app lifecycle, onboarding, and settings#234

Merged
BillChirico merged 1 commit into
mainfrom
coderabbitai/utg/892b031
Dec 29, 2025
Merged

CodeRabbit Generated Unit Tests: Add analytics unit tests for app lifecycle, onboarding, and settings#234
BillChirico merged 1 commit into
mainfrom
coderabbitai/utg/892b031

Conversation

@coderabbitai

@coderabbitai coderabbitai Bot commented Dec 29, 2025

Copy link
Copy Markdown
Contributor

Unit test generation was requested by @BillChirico.

The following files were modified:

  • __tests__/app/layout.test.tsx
  • __tests__/app/onboarding.test.tsx
  • __tests__/components/settings/SettingsContent.analytics.test.tsx
  • __tests__/components/sheets/EditSavingsSheet.test.tsx
  • __tests__/types/analytics.test.ts

Important

Add unit tests for analytics tracking across app lifecycle, onboarding, settings, and savings sheet components.

  • Analytics Tracking Tests:
    • layout.test.tsx: Adds tests for app lifecycle events like APP_OPENED, APP_SESSION_STARTED, DAILY_CHECK_IN, APP_BACKGROUNDED, and APP_SESSION_STARTED on app state changes.
    • onboarding.test.tsx: Adds tests for onboarding events such as ONBOARDING_STARTED, ONBOARDING_SCREEN_VIEWED, ONBOARDING_FIELD_COMPLETED, ONBOARDING_SOBRIETY_DATE_SET, ONBOARDING_COMPLETED, and ONBOARDING_ABANDONED.
    • SettingsContent.analytics.test.tsx: Adds tests for settings changes including theme changes and dashboard preferences, and dev tools analytics events.
    • EditSavingsSheet.test.tsx: Adds tests for savings updates, including SAVINGS_UPDATED event tracking when savings are saved or cleared.
  • Types and Constants:
    • analytics.test.ts: Verifies the integrity and naming conventions of AnalyticsEvents constants, ensuring no duplicates and correct naming patterns.

This description was created by Ellipsis for 97d221c. You can customize this summary. It will automatically update as commits are pushed.

@vercel

vercel Bot commented Dec 29, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sobers Ready Ready Preview, Comment Dec 29, 2025 11:31pm

@coderabbitai

coderabbitai Bot commented Dec 29, 2025

Copy link
Copy Markdown
Contributor Author

Important

Review skipped

CodeRabbit bot authored PR detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@supabase

supabase Bot commented Dec 29, 2025

Copy link
Copy Markdown

This pull request has been ignored for the connected project vzwdsjphpabtxhmffous because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

});

it('tracks ONBOARDING_SOBRIETY_DATE_SET with days sober bucket', () => {
const { trackEvent, calculateDaysSoberBucket } = require('@/lib/analytics');
);
});

const firstCallCount = trackEvent.mock.calls.filter(
@BillChirico BillChirico merged commit b3ddc9e into main Dec 29, 2025
15 of 17 checks passed
@BillChirico BillChirico deleted the coderabbitai/utg/892b031 branch December 29, 2025 23:15
@claude

claude Bot commented Dec 29, 2025

Copy link
Copy Markdown
Contributor

Claude finished @coderabbitai[bot]'s task in 2m 7s —— View jobclaude/pr-234-20251229-2316Create PR ➔


Review of PR #234: Analytics Unit Tests

  • Gather context and understand the changes
  • Review code quality and test patterns
  • Address review comments (unused variables)
  • Provide comprehensive feedback

Summary

This PR adds comprehensive unit tests for analytics tracking across the app. The tests cover:

  • App lifecycle analytics (layout.test.tsx): APP_OPENED, APP_SESSION_STARTED, DAILY_CHECK_IN, APP_BACKGROUNDED
  • Onboarding analytics (onboarding.test.tsx): Tracking for started, screen viewed, field completed, sobriety date set, completed, and abandoned events
  • Settings analytics (SettingsContent.analytics.test.tsx): Theme changes, dashboard preferences, dev tools events
  • Savings sheet analytics (EditSavingsSheet.test.tsx): SAVINGS_UPDATED event tracking
  • Analytics types (analytics.test.ts): Integrity verification for AnalyticsEvents constants

Issues Fixed ✅

I've fixed the two unused variable issues identified by the code quality review:

  1. Line 1071: Removed unused calculateDaysSoberBucket destructure - the test only uses trackEvent
  2. Lines 1288-1290: Removed unused firstCallCount variable - it was calculated but never used

Commit: b6fbb89 - fix(tests): remove unused variables in onboarding tests

Code Quality Assessment

Strengths:

  • Good test coverage for analytics events with clear test descriptions
  • Proper use of jest.clearAllMocks() between tests
  • Tests verify both event names and expected properties
  • Analytics constants integrity tests ensure no duplicates and proper naming conventions

Issues Requiring Attention:

1. Structural Issues (Major)

The new analytics test suites are defined outside the main describe blocks, causing them to be orphaned:

  • __tests__/app/layout.test.tsx: The 'app lifecycle analytics tracking' describe block starts at line 350 after the closing brace of RootLayout describe at line 348
  • __tests__/app/onboarding.test.tsx: The 'Analytics Tracking' describe block starts at line 962 after the closing brace of OnboardingScreen describe at line 960
  • __tests__/components/sheets/EditSavingsSheet.test.tsx: The 'Analytics Tracking' describe block starts at line 599 after the closing brace of EditSavingsSheet describe at line 597
  • __tests__/types/analytics.test.ts: Similar issue with blocks starting at lines 140 and 254

These tests will still run, but they're not properly nested which affects test organization and IDE navigation.

2. Missing/Undefined Mocks (Major)

Several tests reference mocks that are not defined in the file:

  • onboarding.test.tsx:

    • MockedAuthProvider and MockedThemeProvider (lines 973-978) - not defined
    • mockDateTimePicker (line 1058) - not defined
    • mockSupabase (lines 1180, 1308) - not defined
  • EditSavingsSheet.test.tsx:

    • mockOnSave (lines 609, 654, etc.) - not defined
    • mockConfirm (lines 701, 704) - not defined (should be mockShowConfirm)
    • act (lines 613, 657, etc.) - not imported

These missing mocks will cause test failures.

3. Inconsistent TestIDs (Minor)

  • EditSavingsSheet.test.tsx analytics tests use different testIDs than the existing tests:
    • 'savings-amount-input' vs 'edit-savings-amount-input'
    • 'frequency-monthly' vs 'edit-frequency-monthly'
    • 'save-savings-button' vs 'edit-savings-save-button'
    • 'clear-savings-button' vs 'edit-savings-clear-button'

Recommendations

  1. Move describe blocks inside parent describe blocks to fix the structural issues
  2. Add missing mock definitions or use the existing mocks in the file
  3. Align testIDs with the existing conventions in the test file
  4. Add missing imports (act from @testing-library/react-native)

Verdict

The PR introduces valuable analytics test coverage, but the tests have structural issues that will likely cause failures. The unused variable fixes I've applied address the linter warnings, but the more significant issues (orphaned describe blocks, missing mocks) need to be addressed by regenerating the tests properly.


@vibe-kanban-cloud

Copy link
Copy Markdown

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

@claude claude Bot added the testing Testing related changes label Dec 29, 2025
BillChirico added a commit that referenced this pull request Dec 30, 2025
Skip analytics tracking test suites that have unresolved mock
configuration issues:
- __tests__/app/onboarding.test.tsx (mockSupabase undefined)
- __tests__/app/layout.test.tsx (AppState mock not configured)
- __tests__/components/settings/SettingsContent.analytics.test.tsx
- __tests__/components/sheets/EditSavingsSheet.test.tsx

These tests were added in PR #234 but have broken mock setups.
Added TODO comments to track the fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant