Test/3481/add conditional tests#3579
Conversation
The CompleteAllTaskTypesTest didn't cover conditional logic. Added a conditional question to the test survey and added tests for it in order to prevent regressions Closes google#3481
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @hassan-nsubuga, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the end-to-end test suite by introducing comprehensive testing for conditional logic within survey tasks. It specifically adds a conditional multiple-choice question to the test survey and updates the test driver to accurately simulate user interaction and validate the behavior of dynamic survey flows, thereby preventing regressions related to conditional question display and navigation. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds important end-to-end tests for conditional questions, which is a valuable addition to prevent regressions. The changes correctly propagate the necessary information through the test framework. However, I've identified a significant maintainability issue in how the test logic is implemented within the AndroidTestDriver. My main feedback is to refactor this logic into the DataCollectionRobot to maintain a clean separation of concerns, keeping the driver layer generic and reusable. I've also included a minor naming suggestion to improve code clarity.
e2eTest/src/main/java/org/groundplatform/android/e2etest/drivers/AndroidTestDriver.kt
Outdated
Show resolved
Hide resolved
| val taskType: Task.Type, | ||
| val isRequired: Boolean = false, | ||
| val selectIndexes: List<Int>? = null, | ||
| val isACondition: Boolean = false, |
There was a problem hiding this comment.
The property name isACondition is a bit unconventional. For better clarity and adherence to Kotlin naming conventions for boolean properties, consider renaming it to isConditional. This would make the code more readable across the files where it's used.
| val isACondition: Boolean = false, | |
| val isConditional: Boolean = false, |
…ataCollectionRobot and add a reusable method to AndroidTestDriver
| } else { | ||
| selectIndexes.forEach { | ||
| testDriver.selectFromList(TestDriver.Target.TestTag(SELECT_MULTIPLE_CHECKBOX_TEST_TAG), it) | ||
| private fun multipleChoiceTask(selectIndexes: List<Int>, isConditional: Boolean = false) { |
There was a problem hiding this comment.
to test the conditional questions, we don’t actually use the selectIndexes parameter, the logic follows a different path. Because of that, the current function signature can be a bit misleading. I'd suggest to add class that represents the kind of multiple choice question being handled, and pass that as a parameter instead. Something like::
sealed class MultipleChoiceType {
data class Regular(val selectIndexes: List<Int>): MultipleChoiceType()
data object Conditional: MultipleChoiceType()
}
then the function would have a MultipleChoiceType in the arguments instead of selectIndexes + isConditional
| if (target is TestDriver.Target.TestTag && target.tag == SELECT_MULTIPLE_RADIO_TEST_TAG) { | ||
|
|
||
| testDriver.assertVisible(ARABICA_TEXT) | ||
| testDriver.click(TestDriver.Target.Text(COFFEE_TEXT)) |
There was a problem hiding this comment.
the constants used in the test could have more descriptive names to better understand why the sequence of actions goes the way it does.
For example, for the text that needs to be selected to trigger the conditional question, maybe instead of COFFEE_TEXT we could name it CONDITIONAL_TRIGGER_OPTION. Then, for the option that becomes visible within that conditional question, instead of ARABICA_TEXT we can name it EXPECTED_CONDITIONAL_OPTION or similar. Same for other specific names bellow, what do you think?
Fixes #3481
The CompleteAllTaskTypesTest didn't cover conditional logic. Add a conditional question to the test survey and add tests for it in order to prevent regressions
[x] Add conditional question to the test survey
[x] Refactor AndroidTestDriver add conditional test
@... PTAL?