Skip to content

Test/3481/add conditional tests#3579

Open
hassan-nsubuga wants to merge 5 commits intogoogle:masterfrom
hassan-nsubuga:test/3481/add-conditional-tests
Open

Test/3481/add conditional tests#3579
hassan-nsubuga wants to merge 5 commits intogoogle:masterfrom
hassan-nsubuga:test/3481/add-conditional-tests

Conversation

@hassan-nsubuga
Copy link
Collaborator

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?

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
@google-cla
Copy link

google-cla bot commented Feb 23, 2026

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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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

  • Conditional Test Task Introduction: A new isACondition flag was introduced in the TestTask data class and TestConfig was updated to include a conditional multiple-choice task, enabling the definition of survey questions with conditional logic.
  • AndroidTestDriver Refactoring for Conditional Logic: The AndroidTestDriver's selectFromList method was significantly refactored to specifically handle conditional logic within multiple-choice tasks, including UI assertions for element presence/absence and simulated navigation (Next/Previous buttons).
  • Test Driver Interface and Robot Updates: The TestDriver interface was updated to propagate the isACondition flag, and the DataCollectionRobot was modified to pass this flag to the test driver, ensuring that conditional test scenarios can be correctly executed.
  • New Constants for Test Scenarios: Several new string constants were added to TestConfig to support the new conditional test scenarios, such as 'Arabica', 'Coffee', 'Next', 'Previous', and 'Cover Cropping'.

🧠 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
  • e2eTest/src/main/java/org/groundplatform/android/e2etest/TestConfig.kt
    • Modified an existing TestTask to be a conditional multiple-choice task by setting isACondition to true.
    • Added new string constants (ARABICA_TEXT, COFFEE_TEXT, NEXT_BUTTON_TEXT, PREVIOUS_BUTTON_TEXT, COVER_CROPPING_TEXT) for use in conditional test scenarios.
  • e2eTest/src/main/java/org/groundplatform/android/e2etest/TestTask.kt
    • Added a new boolean property isACondition to the TestTask data class, defaulting to false.
  • e2eTest/src/main/java/org/groundplatform/android/e2etest/drivers/AndroidTestDriver.kt
    • Imported onNodeWithText for UI testing assertions.
    • Imported new string constants from TestConfig and SELECT_MULTIPLE_RADIO_TEST_TAG.
    • Refactored the selectFromList method to include specific logic for handling conditional multiple-choice tasks, involving assertions for text presence/absence and clicks on navigation buttons.
  • e2eTest/src/main/java/org/groundplatform/android/e2etest/drivers/TestDriver.kt
    • Updated the selectFromList function signature to include an isACondition parameter with a default value of false.
  • e2eTest/src/main/java/org/groundplatform/android/e2etest/robots/DataCollectionRobot.kt
    • Modified the multipleChoiceTask function to accept a conditional boolean parameter and pass it to the testDriver.selectFromList method.
Activity
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

val taskType: Task.Type,
val isRequired: Boolean = false,
val selectIndexes: List<Int>? = null,
val isACondition: Boolean = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
val isACondition: Boolean = false,
val isConditional: Boolean = false,

} else {
selectIndexes.forEach {
testDriver.selectFromList(TestDriver.Target.TestTag(SELECT_MULTIPLE_CHECKBOX_TEST_TAG), it)
private fun multipleChoiceTask(selectIndexes: List<Int>, isConditional: Boolean = false) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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))
Copy link
Collaborator

Choose a reason for hiding this comment

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

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?

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.

[Code health] Add conditionals to e2e test

3 participants