|
4 | 4 | import androidx.test.espresso.NoMatchingViewException; |
5 | 5 | import androidx.test.espresso.ViewAssertion; |
6 | 6 | import androidx.test.espresso.assertion.ViewAssertions; |
7 | | -import androidx.test.espresso.contrib.RecyclerViewActions; |
8 | 7 | import androidx.test.espresso.matcher.ViewMatchers; |
9 | 8 | import androidx.test.core.app.ActivityScenario; |
10 | 9 | import androidx.test.ext.junit.runners.AndroidJUnit4; |
|
17 | 16 | import org.junit.runner.RunWith; |
18 | 17 |
|
19 | 18 | import static androidx.test.espresso.Espresso.onView; |
20 | | -import static androidx.test.espresso.action.ViewActions.*; |
21 | 19 | import static androidx.test.espresso.matcher.ViewMatchers.*; |
22 | 20 | import static org.hamcrest.Matchers.allOf; |
23 | 21 |
|
@@ -74,38 +72,11 @@ private void performTestLogic(String title) throws InterruptedException { |
74 | 72 | // Wait for RecyclerView to appear and be populated (with timeout) |
75 | 73 | waitForRecyclerViewToLoad(7_000); |
76 | 74 |
|
77 | | - // Scroll to the cell containing the specific title (document should be seeded from GHA) |
78 | | - Log.i("DittoTest", "Looking for pre-seeded task: " + title); |
79 | | - |
80 | | - // Try to verify the document exists (handles duplicates by checking first occurrence) |
81 | | - try { |
82 | | - onView(allOf(withId(R.id.task_text), withText(title))) |
83 | | - .check(ViewAssertions.matches(isDisplayed())); |
84 | | - Log.i("DittoTest", "✅ Found pre-seeded task without scrolling: " + title); |
85 | | - } catch (Exception e) { |
86 | | - // If not immediately visible, try scrolling to find it |
87 | | - Log.i("DittoTest", "Task not immediately visible, scrolling to find: " + title); |
88 | | - try { |
89 | | - onView(withId(R.id.task_list)) |
90 | | - .perform(RecyclerViewActions.scrollTo( |
91 | | - hasDescendant(allOf(withId(R.id.task_text), withText(title))) |
92 | | - )); |
93 | | - Log.i("DittoTest", "✅ Found and scrolled to pre-seeded task: " + title); |
94 | | - |
95 | | - // Final assertion after scrolling |
96 | | - onView(allOf(withId(R.id.task_text), withText(title))) |
97 | | - .check(ViewAssertions.matches(isDisplayed())); |
98 | | - } catch (RuntimeException scrollError) { |
99 | | - if (scrollError.getMessage() != null && scrollError.getMessage().contains("Found more than one sub-view matching")) { |
100 | | - Log.i("DittoTest", "Multiple matches found - checking first occurrence is displayed"); |
101 | | - // When there are duplicates, just verify at least one is displayed (good enough for the test) |
102 | | - onView(allOf(withId(R.id.task_text), withText(title))) |
103 | | - .check(ViewAssertions.matches(isDisplayed())); |
104 | | - } else { |
105 | | - throw scrollError; // Re-throw if it's a different error |
106 | | - } |
107 | | - } |
108 | | - } |
| 75 | + // Verify the seeded document is visible at the top (no scrolling needed) |
| 76 | + Log.i("DittoTest", "Looking for pre-seeded task at top: " + title); |
| 77 | + onView(allOf(withId(R.id.task_text), withText(title))) |
| 78 | + .check(ViewAssertions.matches(isDisplayed())); |
| 79 | + Log.i("DittoTest", "✅ Found pre-seeded task at top: " + title); |
109 | 80 |
|
110 | 81 | // Keep screen visible for 3 seconds for BrowserStack video verification |
111 | 82 | Thread.sleep(3000); |
|
0 commit comments