0

I've encountered an issue where my UI test freezes specifically on the performScrollToNode() function when testing a screen that contains a LazyVerticalGrid. The test enters an apparent infinite loop, unable to exit the state stabilization mechanism (similar to an internal while(true){} within the testing framework).

Screen and Architecture Context:

  1. Container: The main content is inside a LazyVerticalGrid (tagged with testTag("product_lazy_grid")).
  2. Architecture: The application uses Compose UI hosted within a Fragment (ComposeScreenFragment), with navigation managed by Cicerone.
  3. The Issue: Attempting to force a scroll to a component at the end of the list (performScrollToNode(hasTestTag("last_page_widget"))) causes the test runner to hang indefinitely.

Steps Taken and Verified (Did Not Resolve the Issue):

  1. Synchronization: The test is run within runTest with explicit calls to testScheduler.runCurrent() and composeTestRule.waitForIdle() before and after navigation and scrolling attempts.
  2. Mocking/DI: I use Koin/MockK to mock the ViewModel and the Cicerone Router, ensuring no external dependencies (e.g., BottomBarActivity) are blocking the UI thread.
  3. Element Existence: The target element (last_page_widget) is guaranteed to be present in the LazyGridScope and is visible in the unmerged semantic tree (onRoot(useUnmergedTree = true)), although it's initially off-screen.

Thank you for any insights and help with diagnosis!

The Core Questions:

  1. What other factors could prevent performScrollToNode() from determining the UI's "idle state," leading to a freeze?
  2. Could internal logic within the LazyVerticalGrid (such as a specific implementation of LazyGridScope.item or fillMaxWidthItem) be interfering with the Compose synchronization mechanism?
  3. What global Kaspresso settings (ComposeTestRule, FlakySafetyParams) or Coroutine Dispatcher configurations might specifically impact freezing inside this function?
  4. How can I diagnose the root cause more deeply (e.g., via Logcat or specific debugging flags) to see why the Compose Test Rule believes the UI is perpetually busy?
1
  • Welcome to stackoverflow! Please add a minimal reproducible example including the tested Composable and the test case, so that we can try to run it ourselves. Commented Oct 1 at 13:33

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.