Skip to content

Fix tests for Flutter 3.38 compatibility and add model tests#120

Merged
phanan merged 1 commit into
masterfrom
fix/update-tests-and-dependencies
Mar 22, 2026
Merged

Fix tests for Flutter 3.38 compatibility and add model tests#120
phanan merged 1 commit into
masterfrom
fix/update-tests-and-dependencies

Conversation

@phanan
Copy link
Copy Markdown
Member

@phanan phanan commented Mar 22, 2026

Summary

  • Remove golden_toolkit dependency (incompatible with Flutter 3.38) and replace with standard flutter_test APIs
  • Remove tests for deleted widgets/providers (AudioProvider, AssetsAudioPlayer, FullWidthPrimaryIconButton)
  • Fix existing tests for renamed APIs (router params, DownloadProvider changes, OopsBox.showLogOutButton)
  • Fix LRC parser bugs: single-digit minutes, multiple timestamps per line, millisecond precision
  • Add comprehensive model unit tests for Song, Artist, Album, Playlist, and Playable
  • Update GitHub Actions workflow to use current action versions (checkout@v4, flutter-action@v2)

Test plan

  • All 76 tests pass locally (flutter test)
  • CI workflow runs successfully on push

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved lyrics synchronization timestamp recognition to support varied time formats.
    • Enhanced fractional second parsing for more accurate lyric timing.
  • Chores

    • Updated CI/CD workflow to use current action versions.
    • Removed unused testing dependency.
    • Refactored test infrastructure and mocks for improved maintainability.

Remove golden_toolkit dependency (incompatible with Flutter 3.38),
replace with standard flutter_test APIs. Remove tests for deleted
widgets/providers (AudioProvider, AssetsAudioPlayer), fix tests for
renamed APIs (router params, DownloadProvider), fix LRC parser bugs
(single-digit minutes, multi-tag lines, millisecond precision), and
add comprehensive model unit tests. Update CI workflow actions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 22, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request removes the golden_toolkit dependency, adds comprehensive unit tests for model classes (Album, Artist, Song, Playlist, Playable), updates LRC parsing logic to handle variable-digit timestamps and millisecond/centisecond fractional seconds, upgrades GitHub Actions workflow versions, modernizes test infrastructure by replacing golden_toolkit with Flutter's native surface sizing, and systematically updates mock files to align with new provider API signatures (switching from Song-specific methods to Playable-generic variants and restructuring PlaylistProvider methods).

Changes

Cohort / File(s) Summary
Infrastructure & Dependencies
.github/workflows/unit.yml, pubspec.yaml, test/flutter_test_config.dart
Updated GitHub Actions to use checkout v4 and Flutter action v2; removed golden_toolkit dependency and its font-loading initialization from test config.
LRC Parser Logic
lib/utils/lrc_parser.dart
Enhanced timestamp regex to recognize 1-2 digit minutes; changed fractional seconds handling to treat 3-digit values as milliseconds (÷1000) vs. others as centiseconds (÷100); improved line-text extraction and empty-text skipping.
Test Infrastructure
test/extensions/widget_tester_extension.dart
Replaced golden_toolkit's pumpWidgetBuilder with Flutter's binding.setSurfaceSize() for surface sizing; added teardown cleanup; maintained MaterialApp and navigation configuration.
Model Unit Tests
test/models/album_test.dart, test/models/artist_test.dart, test/models/playable_test.dart, test/models/playlist_test.dart, test/models/song_test.dart
Added comprehensive new test suites validating fromJson parsing, computed properties, merge behavior, fake generation, and equality/hashing for Album, Artist, Playable, Playlist, and Song models (~550 lines).
Widget Tests - Golden Removal & Updates
test/ui/screens/create_playlist_sheet_test.dart, test/ui/widgets/album_card_test.dart, test/ui/widgets/artist_card_test.dart, test/ui/widgets/message_overlay_test.dart, test/ui/widgets/oops_box_test.dart, test/ui/widgets/playlist_row_test.dart, test/ui/widgets/song_cache_icon_test.dart
Removed golden-file assertions and replaced with direct widget/content presence checks; updated mock setup to use Playable-generic and new provider API signatures; added timer drainage utilities.
Widget Tests - Deleted
test/ui/widgets/footer_player_sheet_test.dart, test/ui/widgets/full_width_primary_icon_button_test.dart, test/ui/widgets/simple_song_list_test.dart, test/ui/widgets/song_card_test.dart, test/ui/widgets/song_list_buttons_test.dart
Removed entire test files previously using golden-file comparisons or relying on removed test infrastructure (~350 lines deleted).
Mock Files - Major Updates
test/ui/screens/create_playlist_sheet_test.mocks.dart, test/ui/widgets/album_card_test.mocks.dart, test/ui/widgets/artist_card_test.mocks.dart, test/ui/widgets/oops_box_test.mocks.dart, test/ui/widgets/playlist_row_test.mocks.dart, test/ui/widgets/song_cache_icon_test.mocks.dart
Updated Mockito from 5.0.12 to 5.4.6; changed PlaylistProvider methods from Song-specific to Playable-generic (addToPlaylist/removeFromPlaylist); updated AuthProvider/AppRouter signatures (e.g., gotoAlbumDetailsScreen now takes albumId instead of album); switched imports to models.dart barrel.
Mock Files - Deleted
test/ui/widgets/footer_player_sheet_test.mocks.dart, test/ui/widgets/simple_song_list_test.mocks.dart, test/ui/widgets/song_card_test.mocks.dart, test/ui/widgets/song_list_buttons_test.mocks.dart
Removed associated mock files for deleted test files (~700 lines of mock implementations deleted).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

The changes span heterogeneous areas: systematic mock updates across 6 files requiring verification of API consistency, addition of ~550 lines of new model tests with repetitive but comprehensive coverage, removal of golden-file test infrastructure, and moderate LRC parsing logic updates. The mock changes follow a pattern but demand careful review to ensure all provider signatures (PlaylistProvider, AuthProvider, AppRouter, DownloadProvider) align across multiple files.

Poem

🐰 Golden files fade, but tests remain true,
Playables dance where Songs once flew,
LRC minutes march, milliseconds sing,
Mock mocks bow to Mockito's ring,
New models tested, old goldens do—
A rabbit's code hops bright and new!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: updating tests for Flutter 3.38 compatibility and adding comprehensive model tests, which are the two primary objectives of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/update-tests-and-dependencies

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

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

@phanan phanan merged commit 53f8463 into master Mar 22, 2026
1 of 2 checks passed
@phanan phanan deleted the fix/update-tests-and-dependencies branch March 22, 2026 19:14
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