Skip to content

fix(ci): repair PlaybackApiTest and drop source-grep pseudo-tests - #102

Merged
Quick104 merged 1 commit into
mainfrom
t3code/fix-failing-unit-tests
Jul 25, 2026
Merged

Quick104 merged 1 commit into
mainfrom
t3code/fix-failing-unit-tests

Conversation

@Quick104

@Quick104 Quick104 commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Why CI was red

CI has failed on every run since 27de43a (2026-07-24). That commit added direct_stream_resume_v1 to the client feature list sent on POST /api/v1/playback/start, but PlaybackApiTest asserted against a hardcoded copy of the previous six-item list:

expected: [..., device_quirks_v1, seek_reanchor_v1]
but was:  [..., device_quirks_v1, seek_reanchor_v1, direct_stream_resume_v1]

The production code was correct — the test was stale. Fixed by extracting PLAYBACK_START_CLIENT_FEATURES_V3 so the request model and the test share one definition; adding a feature can no longer break the assertion.

Removing source-grep pseudo-tests

97 test files read production .kt files as plain text and asserted on substrings:

private val source = File("src/androidMain/.../TvHomeScreen.kt").readText()

@Test fun homeUsesSharedSkylineFeed() {
    assertTrue(source.contains("TvSkylineSectionFeed("))
    assertTrue(source.contains("cardActions = { section, item ->"))
}

None imported a production symbol, so none executed a line of app code. They passed when a matching string sat in a comment or a dead branch, failed on harmless renames and reformats, and drove 121 commits of churn in three months. That's 2,182 .contains() assertions against source text.

Two files that mixed these greps with genuinely behavioural tests were rewritten to keep only the real ones.

Kept deliberately: the 4 tree-walk lint checks (e.g. the TV 14sp typography floor sweep) and the manifest/asset policy tests, which read XML rather than Kotlin.

CI now runs debug tests only

./gradlew test was building and running both the debug and release unit-test variants — identical sources, no extra signal, double the time.

Verification

./gradlew testDebugUnitTest → 2,097 tests, 0 failures, BUILD SUCCESSFUL (20.6s execution).

Test execution was never the bottleneck; the 5–6 min CI time was almost entirely Kotlin/Compose compilation of test sources, which this cuts by ~7k lines on top of halving the variant work.

Reviewer notes

  • Coverage impact is nil for the deleted files — worth spot-checking a few deletions to confirm they were text-matching only.
  • 20 files still contain grep tests mixed into real ones (worst ratios: ReaderScreenStructureTest 7:2, VideoTrackSelectionCoordinatorTest 5:1). I left these alone rather than risk deleting real tests via automated splitting — a follow-up if you want it.
  • If you ever want R8/ProGuard-specific unit coverage, that now needs an explicit separate job. Nothing in the current suite tests it.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Android CI now runs debug unit tests explicitly for faster, more predictable validation.
    • Replaced numerous source-inspection tests with focused behavioral coverage, including reader routing and playback protocol request validation.
  • Refactor
    • Standardized playback client feature declarations so request behavior remains consistent across the app.

CI has been red since 27de43a. That commit added direct_stream_resume_v1
to the client feature list sent on POST /api/v1/playback/start, but
PlaybackApiTest asserted against a hardcoded copy of the previous
six-item list. The production code was correct; the test was stale.

Extract the list into PLAYBACK_START_CLIENT_FEATURES_V3 so the request
model and the test share one definition, and adding a feature can no
longer break the assertion.

Also remove 97 test files that read production .kt files as plain text
and asserted on substrings:

    private val source = File("src/androidMain/.../TvHomeScreen.kt").readText()
    @test fun x() { assertTrue(source.contains("TvSkylineSectionFeed(")) }

None of them imported a production symbol, so none executed app code.
They passed when a matching string sat in a comment or a dead branch,
failed on renames and reformats, and accounted for 121 commits of churn
over the last three months. Two files that mixed these greps with real
behavioural tests were rewritten to keep only the real ones.

Kept: the tree-walk lint checks (e.g. the TV 14sp typography floor) and
the manifest/asset policy tests, which read XML rather than Kotlin.

Finally, run only testDebugUnitTest in CI. The release variant compiled
and ran identical sources for no extra signal.

Verified: 2097 tests, 0 failures, 20.6s execution.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 082087b7-9c5a-41f4-a340-7b1f33f848ea

📥 Commits

Reviewing files that changed from the base of the PR and between aa79bb5 and 300d929.

📒 Files selected for processing (103)
  • .github/workflows/android-build.yml
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/downloads/DownloadEnqueuerSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/AudioCapabilityManagerSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/AudiobookPlayerStartPositionTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/AuthInterceptorLoggingSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/Media3OnlyRuntimeSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/PlaybackAnalyticsListenerSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/PlaybackCapabilityDetectorSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/PlaybackSessionManagerLoggingTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/SiloPlaybackServiceSubtitleSyncSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/SiloPlayerFactoryRetryPolicySourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/SiloPlayerFactorySubtitleParserTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/TrackSelectionPresetsSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/VideoPlayerMediaMounterSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/backend/Media3VideoPlaybackBackendSourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/backend/VideoPlaybackBackendFactorySourceTest.kt
  • android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/player/backend/VideoPlaybackBackendInterfaceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/cast/SiloCastPhoneSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/di/AndroidVideoBackendDiSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/navigation/ClientSurfaceVisibilitySourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/navigation/MobileAppleParitySourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/navigation/MobileSharedElementSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/performance/MobileDetailOpenPerformanceSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/performance/MobileListPerformanceSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/MobileOfflineBannerSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/audiobook/AudiobookPlayerParitySourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/audiobook/AudiobookPlayerScreenExitTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/collections/CollectionsBrowseOnlySourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/detail/CastCrewSectionSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/detail/DownloadQualityPickerSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/detail/MobileReadingAudioDetailParitySourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/downloads/DownloadsMonitoringSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/people/PersonDetailSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/MobileSubtitleAutoSelectionSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerFastForwardHoldSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerOverlaySourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerScreenStartPositionTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerStatsHudSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerUpNextSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerViewModelSharedCoordinatorTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/player/PlayerViewModelStartPositionTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/profiles/ProfileQualitySourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/reader/ReaderEngineHostSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/reader/ReaderEngineHostTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/reader/ReaderShellParitySourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/servers/ServerListScreenSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/settings/DownloadsSettingsParitySourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/screens/settings/PlaybackQualitySettingsSourceTest.kt
  • androidApp/src/androidUnitTest/kotlin/org/siloserver/silo/android/ui/shared/MobileSharedFollowupsSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/MainTvActivityStartupSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/cast/TvSiloCastReceiverSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/data/preferences/TvPlaybackQualitySourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/di/AndroidTvVideoBackendDiSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/components/TvAuroraBackdropSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/components/TvAuroraChromeSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/components/TvAuroraPrimaryButtonFocusTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/components/TvCardOverlayScaleSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/components/TvMediaRowArtworkSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/components/TvSkylineSectionFeedSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/components/TvTextInputDialogSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/navigation/TvClientSurfaceVisibilitySourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/navigation/TvPersonNavigationSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/performance/TvDetailOpenPerformanceSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/performance/TvListPerformanceSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/audiobook/TvAudiobookPlayerParitySourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/audiobook/TvAudiobookPlayerScreenExitTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/audiobook/TvAudiobookSleepPanelSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/auth/TvAuthFocusSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/auth/TvAuthSingleFlightSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/auth/TvLoginViewModelSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/auth/TvServerSetupReadabilityTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/calendar/TvCalendarSizingSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/collections/TvCollectionsBrowseOnlySourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/detail/TvAudiobookDetailHeroParitySourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/detail/TvDetailPlaybackSelectionSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/home/TvHomeScreenSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/library/TvLibraryDetailSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/people/TvPersonDetailSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerBackendCapabilitiesSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerControlsUsabilityTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerScreenStartPositionTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerViewModelPlaybackPositionTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/player/TvPlayerViewModelSharedCoordinatorTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileFormSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileQualitySourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileSelectionScreenSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/profiles/TvProfileSelectionViewModelSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/requests/TvRequestsUsabilityTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/search/TvSearchLayoutReadabilityTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/servers/TvServerListFocusSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/settings/TvSettingsUsabilityTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/shell/TvCascadeInteractionSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/shell/TvOfflineBannerSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/shell/TvProfileActionsPanelReadabilityTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/shell/TvProfileAvatarParityTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/shell/TvShellFocusSourceTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/theme/TvDialogScalingTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/theme/TvScreenSurfaceScalingTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/theme/TvSkylineTokenParityTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/theme/TvThemeScalingTest.kt
  • androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/util/TvMediaTypeFiltersSourceTest.kt
  • shared/src/commonMain/kotlin/org/siloserver/silo/model/playback/PlaybackProtocolV3.kt
  • shared/src/commonTest/kotlin/org/siloserver/silo/network/api/PlaybackApiTest.kt

📝 Walkthrough

Walkthrough

Android CI now runs debug unit tests, many source-inspection tests are removed, reader routing receives behavioral coverage, and the V3 playback client-feature list is centralized for production defaults and API assertions.

Changes

Test suite updates

Layer / File(s) Summary
CI scope and source-test removal
.github/workflows/android-build.yml, androidApp/src/androidUnitTest/..., androidTvApp/src/androidUnitTest/...
The workflow runs testDebugUnitTest, while broad source-text test coverage across Android phone and TV modules is removed.
Reader routing behavior test
androidApp/src/androidUnitTest/.../reader/ReaderEngineHostTest.kt
Adds behavioral assertions for external reading panel visibility across read modes and reader capabilities.

Playback feature contract

Layer / File(s) Summary
Canonical playback feature list
shared/src/commonMain/.../PlaybackProtocolV3.kt, shared/src/commonTest/.../PlaybackApiTest.kt
Defines PLAYBACK_START_CLIENT_FEATURES_V3 and reuses it for V3 request defaults and API test expectations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/fix-failing-unit-tests

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

@Quick104
Quick104 merged commit e99b55f into main Jul 25, 2026
1 of 2 checks passed
@Quick104
Quick104 deleted the t3code/fix-failing-unit-tests branch July 25, 2026 19:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 300d9296cf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 81 to 83
assertEquals(
listOf(
"playback_plan_v3",
"media3_only",
"detailed_decode_capabilities",
"client_video_transformations_v1",
"device_quirks_v1",
"seek_reanchor_v1",
),
PLAYBACK_START_CLIENT_FEATURES_V3,
body["client_features"]!!.jsonArray.map { it.jsonPrimitive.content },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the playback feature expectation independent

The expected value now comes from the same constant that supplies PlaybackStartRequestV3.clientFeatures, so this assertion is tautological. If a later edit accidentally removes or renames direct_stream_resume_v1 (or another required negotiation token), the outgoing wire contract changes and this test still passes; keep the production constant, but assert an independently specified list of protocol tokens here.

Useful? React with 👍 / 👎.

Comment on lines -13 to -15
assertFalse(source.contains("SET_ENGINE"))
assertFalse(source.contains("switchEngine"))
assertFalse(source.contains("createMpvPlayer"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Run the Media3-only checker after deleting this gate

When a later change reintroduces an MPV engine command or backend, deleting this test removes the only CI gate that previously rejected it. I checked the android-build.yml workflow and repo-wide references to scripts/check-no-mpv-runtime.sh; the workflow only runs Gradle tests and the checker is referenced from documentation, not automation. Replace this pseudo-test with a workflow step invoking that purpose-built checker so the documented Media3-only runtime invariant remains enforced.

Useful? React with 👍 / 👎.

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