-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #3607: ExplorationPlayer End to End tests #3608
Changes from 69 commits
b720222
f90cbfc
930abe0
bb6f5bb
46a1b56
44f4003
72620a2
7a384c3
8a641d7
c58b6f6
09c419e
004e3a1
7124642
7a1221d
0aec4a5
6e09966
8ca2bb9
4486882
f64d32c
dc66ba2
c233b71
2044979
7ac1ac5
3bb5348
1c818dd
2e0440e
e5a6128
425ebfa
067537f
b9233c6
37b10e2
3c1e79f
44363c1
e95d29f
c608f7c
66f6b51
6514ba9
e81706b
a4266e4
6f2836c
870d0a2
3660243
d4aa4d4
41ea23f
b15451b
73c650e
0d50914
e2db957
f8f3ca9
16b51e5
02af57a
e39903f
838c713
08ffe75
e2ba215
989342e
5610651
3f9e2c7
75c60cd
a37bcbb
33c4189
d40cd4b
55bc4d9
58caec1
8d16408
c7bd1dd
f01a655
4811a07
b9e9fbe
196f8db
bf1e0eb
63ed680
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ import androidx.test.platform.app.InstrumentationRegistry | |
import androidx.test.uiautomator.UiDevice | ||
import com.google.common.truth.Truth.assertThat | ||
import org.junit.Before | ||
import org.junit.Ignore | ||
import org.junit.Test | ||
import org.oppia.android.instrumentation.testing.EndToEndTestHelper.findObjectByDesc | ||
import org.oppia.android.instrumentation.testing.EndToEndTestHelper.findObjectByRes | ||
import org.oppia.android.instrumentation.testing.EndToEndTestHelper.findObjectByText | ||
import org.oppia.android.instrumentation.testing.EndToEndTestHelper.scrollRecyclerViewTextIntoView | ||
|
@@ -23,22 +25,161 @@ class ExplorationPlayerTest { | |
} | ||
|
||
@Test | ||
fun testExploration_prototypeExploration_toolbarTitle_isDisplayedSuccessfully() { | ||
fun testPlayExploration_prototypeExploration_playedFullyThrough_finishesSuccessfully() { | ||
navigateToPrototypeExploration() | ||
assertThat(device.findObjectByRes("exploration_toolbar_title")).isNotNull() | ||
|
||
// Play through all interactions. | ||
playContinueInteraction() | ||
playFractionInputInteraction() | ||
playMultipleChoiceIntearction1() | ||
playMultipleChoiceIntearction2() | ||
playItemSelectionInteraction() | ||
playNumericInputInteraction() | ||
playRatioInputInteraction() | ||
playTextInputInteraction() | ||
playDragAndDropInteraction() | ||
playDragDropMergeInteraction() | ||
playEndExplorationInteraction() | ||
|
||
// Assert Topic Completed. | ||
scrollRecyclerViewTextIntoView("Chapter 1: Prototype Exploration") | ||
val chapterCompletedTick = device.findObjectByText( | ||
"Chapter 1: Prototype Exploration" | ||
)!!.parent.findObjectByRes("chapter_completed_tick") | ||
assertThat(chapterCompletedTick).isNotNull() | ||
} | ||
|
||
// TODO(#3697): Update e2e tests when backend support is introduced. | ||
@Test | ||
@Ignore("Need backend connection support to test the ImageRegionSelectionInteraction") | ||
fun testPlayExploration_imageRegionInteractionExp_playedFullyThrough_finishesSuccessfully() { | ||
navigateToImageRegionSelectionInteraction() | ||
|
||
// Image Region Selection Interaction. | ||
val imageSelectionView = device.findObjectByRes("interaction_container_frame_layout") | ||
device.waitForRes("image_click_interaction_image_view") | ||
device.findObjectByDesc("Saturn")!!.click() | ||
device.findObjectByText("SUBMIT")!!.click() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here I'm using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest returning only non-nullable types from your helper class and utilize checkNotNull with clearer error messages if an object isn't found. That'll give you the quick-failure you're looking for with clearer context, and doesn't even give the choice to test authors to potentially avoid the null-check (since we do want things to be really crisp). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
device.findObjectByText("CONTINUE")!!.click() | ||
|
||
// End Exploration. | ||
playEndExplorationInteraction() | ||
|
||
// Assert Topic Completed. | ||
scrollRecyclerViewTextIntoView("Chapter 2: Image Region Selection Exploration") | ||
val chapterCompletedTick = device.findObjectByText( | ||
"Chapter 2: Image Region Selection Exploration" | ||
)!!.parent.findObjectByRes("chapter_completed_tick") | ||
assertThat(chapterCompletedTick).isNotNull() | ||
} | ||
|
||
/** Navigates and opens the Prototype Exploration using the admin profile. */ | ||
private fun navigateToPrototypeExploration() { | ||
device.findObjectByRes("skip_text_view")?.click() | ||
device.findObjectByRes("get_started_button")?.click() | ||
device.findObjectByRes("skip_text_view")!!.click() | ||
device.findObjectByRes("get_started_button")!!.click() | ||
device.waitForRes("profile_select_text") | ||
device.findObjectByText("Admin")!!.click() | ||
scrollRecyclerViewTextIntoView("First Test Topic") | ||
device.findObjectByText("First Test Topic")!!.click() | ||
device.findObjectByText("LESSONS")!!.click() | ||
device.findObjectByText("First Story")!!.click() | ||
scrollRecyclerViewTextIntoView("Chapter 1: Prototype Exploration") | ||
device.findObjectByText("Chapter 1: Prototype Exploration")!!.click() | ||
} | ||
|
||
private fun completePrototypeExploration() { | ||
playContinueInteraction() | ||
playFractionInputInteraction() | ||
playMultipleChoiceIntearction1() | ||
playMultipleChoiceIntearction2() | ||
playItemSelectionInteraction() | ||
playNumericInputInteraction() | ||
playRatioInputInteraction() | ||
playTextInputInteraction() | ||
playDragAndDropInteraction() | ||
playDragDropMergeInteraction() | ||
playEndExplorationInteraction() | ||
} | ||
|
||
private fun playContinueInteraction() { | ||
device.findObjectByText("CONTINUE")!!.click() | ||
} | ||
|
||
private fun playFractionInputInteraction() { | ||
device.findObjectByRes("fraction_input_interaction_view")!!.text = "1/2" | ||
device.findObjectByText("SUBMIT")!!.click() | ||
playContinueInteraction() | ||
} | ||
|
||
private fun playMultipleChoiceIntearction1() { | ||
device.findObjectByText("Eagle")!!.click() | ||
playContinueInteraction() | ||
} | ||
|
||
private fun playMultipleChoiceIntearction2() { | ||
device.findObjectByText("Green")!!.click() | ||
playContinueInteraction() | ||
} | ||
|
||
private fun playItemSelectionInteraction() { | ||
device.findObjectByText("Red")!!.click() | ||
device.findObjectByText("Green")!!.click() | ||
device.findObjectByText("Blue")!!.click() | ||
device.findObjectByText("SUBMIT")!!.click() | ||
playContinueInteraction() | ||
} | ||
|
||
private fun playNumericInputInteraction() { | ||
device.findObjectByRes("numeric_input_interaction_view")!!.text = "121" | ||
device.findObjectByText("SUBMIT")!!.click() | ||
playContinueInteraction() | ||
} | ||
|
||
private fun playRatioInputInteraction() { | ||
device.findObjectByRes("ratio_input_interaction_view")!!.text = "4:5" | ||
device.findObjectByText("SUBMIT")!!.click() | ||
playContinueInteraction() | ||
} | ||
|
||
private fun playTextInputInteraction() { | ||
device.findObjectByRes("text_input_interaction_view")!!.text = "Finnish" | ||
device.findObjectByText("SUBMIT")!!.click() | ||
playContinueInteraction() | ||
} | ||
|
||
private fun playDragAndDropInteraction() { | ||
device.findObjectByDesc("Move item down to 2")!!.click() | ||
device.findObjectByDesc("Move item down to 3")!!.click() | ||
device.findObjectByDesc("Move item down to 4")!!.click() | ||
device.findObjectByText("SUBMIT")!!.click() | ||
playContinueInteraction() | ||
} | ||
|
||
private fun playDragDropMergeInteraction() { | ||
device.findObjectByDesc("Link to item 2")!!.click() | ||
device.findObjectByDesc("Move item down to 3")!!.click() | ||
device.findObjectByText("SUBMIT")!!.click() | ||
playContinueInteraction() | ||
} | ||
|
||
private fun playEndExplorationInteraction() { | ||
device.findObjectByText("RETURN TO TOPIC")!!.click() | ||
} | ||
|
||
/** Navigates and opens the Image Region Selection Exploration using the admin profile. */ | ||
private fun navigateToImageRegionSelectionInteraction() { | ||
device.findObjectByRes("skip_text_view")!!.click() | ||
device.findObjectByRes("get_started_button")!!.click() | ||
device.waitForRes("profile_select_text") | ||
device.findObjectByText("Admin")?.click() | ||
device.findObjectByText("Admin")!!.click() | ||
scrollRecyclerViewTextIntoView("First Test Topic") | ||
device.findObjectByText("First Test Topic")?.click() | ||
device.findObjectByText("LESSONS")?.click() | ||
device.findObjectByText("First Story")?.click() | ||
device.findObjectByText("First Test Topic")!!.click() | ||
device.findObjectByText("LESSONS")!!.click() | ||
device.findObjectByText("First Story")!!.click() | ||
scrollRecyclerViewTextIntoView("Chapter 1: Prototype Exploration") | ||
device.findObjectByText("Chapter 1: Prototype Exploration")?.click() | ||
device.findObjectByText("Chapter 1: Prototype Exploration")!!.click() | ||
completePrototypeExploration() | ||
scrollRecyclerViewTextIntoView("Chapter 2: Image Region Selection Exploration") | ||
device.findObjectByText("Chapter 2: Image Region Selection Exploration")!!.click() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aggarwalpulkit596 PTAL
This enables content description for each image region in ImageRegionSelectionInteraction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't correct. The label will give away the answer, so we introduced another property for content descriptions in image region.
However, looking at https://github.com/oppia/oppia/blob/develop/extensions/interactions/ImageClickInput/ImageClickInput.py it seems we never did add this. Per oppia/oppia#9924 I guess we didn't finish this which introduces a problem. We unfortunately won't be able to use this method.
Can you file an issue to add support for oppia/oppia#9924 once it's ready & add that as a TODO here to fix the reference? We probably aren't going to be able to do better than the direct indexing without content description support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
#3712