Fix #5895: Support feature flag toggling in StateFragmentTest#6118
Fix #5895: Support feature flag toggling in StateFragmentTest#6118harshsomankar123-tech wants to merge 7 commits intooppia:developfrom
Conversation
APK & AAB differences analysisNote that this is a summarized snapshot. See the CI artifacts for detailed differences. DevExpand to see flavor specificsUniversal APKAPK file size: 19 MiB (old), 19 MiB (new), 288 bytes (Removed) APK download size (estimated): 18 MiB (old), 18 MiB (new), 912 bytes (Added) Method count: 265336 (old), 265327 (new), 9 (Removed) Features: 1 (old), 1 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 7117 (old), 7117 (new), 0 (No change)
Lesson assets: 113 (old), 113 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 19 MiB (old), 19 MiB (new), 288 bytes (Removed) Configuration hdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 49 KiB (old), 49 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 46 KiB (old), 46 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 86 KiB (old), 86 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 57 KiB (old), 57 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 63 KiB (old), 63 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 64 KiB (old), 64 KiB (new), 0 bytes (No change) AlphaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 304 bytes (Removed) APK download size (estimated): 10 MiB (old), 10 MiB (new), 468 bytes (Removed) Method count: 118604 (old), 118594 (new), 10 (Removed) Features: 1 (old), 1 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 6051 (old), 6051 (new), 0 (No change)
Lesson assets: 114 (old), 114 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 300 bytes (Removed) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 45 KiB (old), 45 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) BetaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 360 bytes (Removed) APK download size (estimated): 10 MiB (old), 10 MiB (new), 907 bytes (Added) Method count: 118611 (old), 118601 (new), 10 (Removed) Features: 1 (old), 1 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 6051 (old), 6051 (new), 0 (No change)
Lesson assets: 114 (old), 114 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 364 bytes (Removed) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 45 KiB (old), 45 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) GaExpand to see flavor specificsUniversal APKAPK file size: 11 MiB (old), 11 MiB (new), 224 bytes (Removed) APK download size (estimated): 10 MiB (old), 10 MiB (new), 462 bytes (Added) Method count: 118611 (old), 118601 (new), 10 (Removed) Features: 1 (old), 1 (new), 0 (No change) Permissions: 6 (old), 6 (new), 0 (No change) Resources: 6051 (old), 6051 (new), 0 (No change)
Lesson assets: 114 (old), 114 (new), 0 (No change) AAB differencesExpand to see AAB specificsSupported configurations:
Base APKAPK file size: 11 MiB (old), 11 MiB (new), 220 bytes (Removed) Configuration hdpiAPK file size: 43 KiB (old), 43 KiB (new), 0 bytes (No change) Configuration ldpiAPK file size: 45 KiB (old), 45 KiB (new), 0 bytes (No change) Configuration mdpiAPK file size: 38 KiB (old), 38 KiB (new), 0 bytes (No change) Configuration tvdpiAPK file size: 73 KiB (old), 73 KiB (new), 0 bytes (No change) Configuration xhdpiAPK file size: 50 KiB (old), 50 KiB (new), 0 bytes (No change) Configuration xxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) Configuration xxxhdpiAPK file size: 55 KiB (old), 55 KiB (new), 0 bytes (No change) |
app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt
Show resolved
Hide resolved
|
Unassigning @harshsomankar123-tech since a re-review was requested. @harshsomankar123-tech, please make sure you have addressed all review comments. Thanks! |
|
Hi @harshsomankar123-tech, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
|
Hi @harshsomankar123-tech, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
|
@BenHenning PTAL |
|
Since @adhiamboperes has already been reviewing this, deassigning myself. Also @harshsomankar123-tech make sure to fix failing CI checks otherwise that will end up blocking review, anyway, since we need to review follow-up fixes which means another back-and-forth. |
|
Hi @harshsomankar123-tech, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 7 days, it will be automatically closed so that others can take up the issue. |
Coverage ReportResultsNumber of files assessed: 46 Passing coverageFiles with passing code coverage
Exempted coverageFiles exempted from coverage
|
|
@adhiamboperes PTAL |
|
@harshsomankar123-tech this PR is being marked as draft because the PR description must contain 'Fixes #' or 'Fixes part of #' for each issue the PR is changing, and each one on its own line with no other text. |
adhiamboperes
left a comment
There was a problem hiding this comment.
Thanks @harshsomankar123-tech!
I have left a suggestion on how I thought the test should be written, but there could be failures. Please try it and share any error messages that you get.
| fun testFlashback_featureFlagOff_thenFeatureFlagOn() { | ||
| // Simulate previous app instance with feature flag disabled. | ||
| TestPlatformParameterModule.forceEnableFlashbackSupport(false) | ||
| executeInPreviousAppInstance { _ -> | ||
| // No additional state needs to be arranged since the flag is already disabled. | ||
| } | ||
|
|
||
| // In the current app instance, keep feature flag off and verify button is not shown. | ||
| setUpTestWithFlashbackFeatureOff() | ||
| launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { | ||
| startPlayingExploration() | ||
|
|
||
| navigateToPrototypeRatioInputState() | ||
|
|
||
| // Submit wrong answer. | ||
| typeRatioExpression("4:8") | ||
| clickSubmitAnswerButton() | ||
|
|
||
| // Verify flashback button is NOT shown (flag is off). | ||
| onView(withId(R.id.flashback_button)).check(doesNotExist()) | ||
| } | ||
| } |
There was a problem hiding this comment.
This test contains a number of mistakes.
- The executeInPreviousAppInstance is not set up to do anything.
- Both previous and current instances are testing for the flag off condition, when the test name says
featureFlagOff_thenFeatureFlagOn
| fun testFlashback_featureFlagOff_thenFeatureFlagOn() { | |
| // Simulate previous app instance with feature flag disabled. | |
| TestPlatformParameterModule.forceEnableFlashbackSupport(false) | |
| executeInPreviousAppInstance { _ -> | |
| // No additional state needs to be arranged since the flag is already disabled. | |
| } | |
| // In the current app instance, keep feature flag off and verify button is not shown. | |
| setUpTestWithFlashbackFeatureOff() | |
| launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { | |
| startPlayingExploration() | |
| navigateToPrototypeRatioInputState() | |
| // Submit wrong answer. | |
| typeRatioExpression("4:8") | |
| clickSubmitAnswerButton() | |
| // Verify flashback button is NOT shown (flag is off). | |
| onView(withId(R.id.flashback_button)).check(doesNotExist()) | |
| } | |
| } | |
| fun testFlashback_featureFlagOff_thenFeatureFlagOn() { | |
| executeInPreviousAppInstance { _ -> | |
| TestPlatformParameterModule.forceEnableFlashbackSupport(false) | |
| startPlayingExploration() | |
| navigateToPrototypeRatioInputState() | |
| // Submit wrong answer. | |
| typeRatioExpression("4:8") | |
| clickSubmitAnswerButton() | |
| // Verify flashback button is NOT shown. | |
| onView(withId(R.id.flashback_button)).check(doesNotExist()) | |
| } | |
| // In the current app instance, keep feature flag on and verify button is shown. | |
| setUpTestWithFlashbackFeatureOn() | |
| launchForExploration(TEST_EXPLORATION_ID_2, shouldSavePartialProgress = false).use { | |
| startPlayingExploration() | |
| navigateToPrototypeRatioInputState() | |
| // Submit wrong answer. | |
| typeRatioExpression("4:8") | |
| clickSubmitAnswerButton() | |
| // Verify flashback button is visible. | |
| scrollToViewType(FLASHBACK_BUTTON) | |
| onView(withId(R.id.flashback_button)).check( | |
| matches(withText(R.string.state_flashback_button)) | |
| ) | |
| } | |
| } |
|
Hi @adhiamboperes, thanks for the detailed suggestions! PTAL
|
|
Unassigning @harshsomankar123-tech since a re-review was requested. @harshsomankar123-tech, please make sure you have addressed all review comments. Thanks! |
|
@harshsomankar123-tech, some of the new tests are failing. Have you run them locally on your machine? |
Explanation
Fixes #5895
Support feature flag toggling in StateFragmentTest
This PR implements support for feature flag toggling mid-session within
StateFragmentTest. The changes follow the approach approved in the issue:executeInPreviousAppInstanceintoStateFragmentTest.TestApplicationto overrideattachBaseContext.testFlashback_featureFlagOff_thenFeatureFlagOn) to verify the feature flag change mid-session. This test confirms that the flashback button successfully becomes visible after enabling the flag.Essential Checklist
For UI-specific PRs only
Not applicable. This PR is entirely scoped to test infrastructure and unit/instrumentation tests (
StateFragmentTest). It adds support for feature flag toggling during tests. No production Android UI components, layouts, or user-facing elements are modified. No screenshots, accessibility recordings, or UI-specific manual checks are required.