Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@shrimpnaur
Copy link

@shrimpnaur shrimpnaur commented Aug 29, 2025

This PR addresses part of #5818 by adding comprehensive tests for EditTextInputAction to verify correct append and replace text behavior in Robolectric environments.

What This PR Does

  • Adds EditTextInputActionTest.kt with comprehensive test coverage for EditTextInputAction
  • Tests appendText() correctly appends to existing text (e.g., "123" + "45" = "12345")
  • Tests replaceText() correctly replaces existing text (e.g., "123" → "45")
  • Covers edge cases like empty text, special characters, and mixed operations
  • Ensures the fix from PR Fixes a part of #2133: Prevent vanishing of input on configuration change. #5617 works correctly and prevents future regressions

Testing

  • All tests verify the behavior works correctly in Robolectric environments where the original bug occurred
  • Tests cover both isAppend=true and isAppend=false code paths in the updateText() method
  • Includes tests for sequential operations and edge cases

The core bug fix was already implemented in PR #5617. This PR adds the missing test coverage as specified in issue #5818.

Fixes part of #5818

Essential Checklist

  • The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • Any changes to scripts/assets files have their rationale included in the PR explanation.
  • The PR follows the style guide.
  • The PR does not contain any unnecessary code changes from Android Studio (reference).
  • The PR is made from a branch that's not called "develop" and is up-to-date with "develop".
  • The PR is assigned to the appropriate reviewers (reference).

@shrimpnaur shrimpnaur requested review from a team as code owners August 29, 2025 15:11
@shrimpnaur shrimpnaur requested a review from BenHenning August 29, 2025 15:11
@shrimpnaur
Copy link
Author

PTAL @theayushyadav11

Copy link
Collaborator

@theayushyadav11 theayushyadav11 left a comment

Choose a reason for hiding this comment

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

Thanks @shrimpnaur, this is nicely done. Just a few nits regarding test namings (guide) and arrangement.

@theayushyadav11
Copy link
Collaborator

Hi @shrimpnaur, just a small request, please avoid resolving comments that were not opened by you. Instead, you can respond with "Done," "Updated," or share any thoughts you have. The reviewer will take care of resolving the comments.
Thanks

@shrimpnaur
Copy link
Author

Understood and resolved the comments. PTAL @theayushyadav11

@oppiabot
Copy link

oppiabot bot commented Sep 2, 2025

Unassigning @shrimpnaur since a re-review was requested. @shrimpnaur, please make sure you have addressed all review comments. Thanks!

@shrimpnaur
Copy link
Author

@theayushyadav11 Hey there, just wanted to check up on this. Does everything work as intended?

@adhiamboperes
Copy link
Collaborator

Hi @shrimpnaur, apologies for the delay. We will give you a full review tomorrow.

@theayushyadav11
Copy link
Collaborator

Thanks @shrimpnaur for addressing the comments. This LGTM.
I have updated the branch to adhere to latest develop branch.
@adhiamboperes PTAL for the final pass.

@oppiabot
Copy link

oppiabot bot commented Sep 6, 2025

Unassigning @theayushyadav11 since they have already approved the PR.

@oppiabot
Copy link

oppiabot bot commented Sep 6, 2025

Assigning @BenHenning for code owner reviews. Thanks!

@github-actions
Copy link

github-actions bot commented Sep 6, 2025

Coverage Report

Results

Number of files assessed: 1
Overall Coverage: 0.00%
Coverage Analysis: PASS

Exempted coverage

Files exempted from coverage
File Exemption Reason
EditTextInputAction.kttesting/src/main/java/org/oppia/android/testing/espresso/EditTextInputAction.kt
This file is exempted from having a test file; skipping coverage check.

Refer test_file_exemptions.textproto for the comprehensive list of file exemptions and their required coverage percentages.

To learn more, visit the Oppia Android Code Coverage wiki page

Copy link
Collaborator

@adhiamboperes adhiamboperes left a comment

Choose a reason for hiding this comment

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

Thanks @shrimpnaur for this PR. I am handing this over to @BenHenning to help with the technical decisions.

* in Robolectric environments.
*/
@RunWith(AndroidJUnit4::class)
@Config(application = EditTextInputActionTest.TestApplication::class)
Copy link
Collaborator

Choose a reason for hiding this comment

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

These tests are good if the goal is lightweight unit tests, but the common pattern in the repo is to use instrumented unit tests/ semi integration tests like in TextInputActionTest.kt.

I would like @BenHenning to weigh in here, whether we should go with this approach.

Copy link
Member

Choose a reason for hiding this comment

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

I agree. The variety of tests is really good, but we ought to ensure that the action actually integrates with Espresso correctly (which means using it as an Espresso action rather than directly calling it). TextInputActionTest is a really good basis for reference on how to do that since it's also validating a custom Espresso action.

@shrimpnaur
Copy link
Author

@BenHenning @adhiamboperes

Thank you for the feedback. I understand that these are architectural decisions that need your input.

Could you please let me know if I should wait for the technical decisions before making any changes?
and also if there is there anything I can help clarify about my current implementation while you're reviewing the approach?

I'm happy to adjust the implementation once the preferred approach is determined.

@adhiamboperes
Copy link
Collaborator

Hi @shrimpnaur, I understand that you are blocked on this PR. It would be great to work on a new issue in the meantime, to parallelize your efforts. We have updated our list of starter issues, so I hope you find some interesting stuff to work on!

@shrimpnaur
Copy link
Author

@adhiamboperes Yeah sure. 👍

@oppiabot
Copy link

oppiabot bot commented Sep 22, 2025

Hi @shrimpnaur, 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.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Sep 22, 2025
Copy link
Member

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

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

Thanks @shrimpnaur! Apologies for the delay--I was sick and it took a number of days to catch up on things. I've followed up to @adhiamboperes's comments--PTAL.

* in Robolectric environments.
*/
@RunWith(AndroidJUnit4::class)
@Config(application = EditTextInputActionTest.TestApplication::class)
Copy link
Member

Choose a reason for hiding this comment

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

I agree. The variety of tests is really good, but we ought to ensure that the action actually integrates with Espresso correctly (which means using it as an Espresso action rather than directly calling it). TextInputActionTest is a really good basis for reference on how to do that since it's also validating a custom Espresso action.

@oppiabot oppiabot bot removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Sep 24, 2025
@BenHenning BenHenning assigned shrimpnaur and unassigned BenHenning Sep 24, 2025
@shrimpnaur
Copy link
Author

Hi @BenHenning ,
Thanks for the clarification! I’ll leave the BUILD.bazel file as is and update the my test by following the pattern in TextInputActionTest.kt so that there is proper integration with Espresso.

I'll make these changes and update the PR shortly.
Thanks for the guidance!

@oppiabot
Copy link

oppiabot bot commented Oct 5, 2025

Hi @shrimpnaur, 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.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Oct 5, 2025
@adhiamboperes
Copy link
Collaborator

Hi @shrimpnaur, do you need support on this PR?

@oppiabot oppiabot bot removed the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Oct 8, 2025
@shrimpnaur
Copy link
Author

Hey @adhiamboperes
I'm working on updating the tests, but I need guidance on which test activity to use. Should I:

  1. Use an existing test activity like InputInteractionViewTestActivity?
  2. Create a new dedicated test activity for EditTextInputAction?

Could you point me to the best approach for this?

Thanks!

@adhiamboperes
Copy link
Collaborator

Hi @shrimpnaur, please create a new test activity as it is fairly simple. Also make sure you add the activity to the test_file_exemptions file, as well as to the testing module's AndroidManifest and the CODEOWNERS file, following the example of TextInputActionTestActivity.

@oppiabot
Copy link

oppiabot bot commented Oct 17, 2025

Hi @shrimpnaur, 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.
If you are still working on this PR, please make a follow-up commit within 3 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale Corresponds to items that haven't seen a recent update and may be automatically closed. label Oct 17, 2025
@oppiabot oppiabot bot closed this Oct 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Corresponds to items that haven't seen a recent update and may be automatically closed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants