From 966b0059908444fb74ba2c4affdbc6c5eba8433b Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Wed, 18 Nov 2026 11:18:46 +0100 Subject: [PATCH] fix(test): drive the Compose settings screen in LoginIT The settings screen moved to Compose in 915a9665e, which removed the view R.id.settings_remove_account. LoginIT still referenced it, so the androidTest sources no longer compiled and every instrumented test run failed. Removing a leftover account and checking the logged-in user now go through a Compose test rule: open the account chooser from the avatar, open the settings, remove the account and confirm, and look for the user's display name in the account chooser. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- .../java/com/nextcloud/talk/ui/LoginIT.java | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/app/src/androidTest/java/com/nextcloud/talk/ui/LoginIT.java b/app/src/androidTest/java/com/nextcloud/talk/ui/LoginIT.java index e2c5fa415a1..4733fef9843 100644 --- a/app/src/androidTest/java/com/nextcloud/talk/ui/LoginIT.java +++ b/app/src/androidTest/java/com/nextcloud/talk/ui/LoginIT.java @@ -8,6 +8,7 @@ */ package com.nextcloud.talk.ui; +import android.content.Context; import android.os.Bundle; import com.nextcloud.talk.R; @@ -15,16 +16,25 @@ import com.nextcloud.talk.utils.AppTasks; import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; import java.util.Objects; +import kotlin.coroutines.EmptyCoroutineContext; + +import androidx.compose.ui.test.junit4.ComposeTestRule; import androidx.test.core.app.ActivityScenario; import androidx.test.core.app.ApplicationProvider; import androidx.test.espresso.NoMatchingViewException; import androidx.test.espresso.web.webdriver.DriverAtoms; import androidx.test.espresso.web.webdriver.Locator; +import static androidx.compose.ui.test.ActionsKt.performClick; +import static androidx.compose.ui.test.AssertionsKt.assertIsDisplayed; +import static androidx.compose.ui.test.FindersKt.onNodeWithContentDescription; +import static androidx.compose.ui.test.FindersKt.onNodeWithText; +import static androidx.compose.ui.test.junit4.AndroidComposeTestRule_androidKt.createEmptyComposeRule; import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.typeText; @@ -43,6 +53,9 @@ @Ignore("This test is ignored because it constantly fails on CI") public class LoginIT { + @Rule + public final ComposeTestRule composeRule = createEmptyComposeRule(EmptyCoroutineContext.INSTANCE); + @Test public void login() throws InterruptedException { @@ -50,6 +63,7 @@ public void login() throws InterruptedException { ActivityScenario activityScenario = ActivityScenario.launch( AppTasks.INSTANCE.createLauncherIntent(ApplicationProvider.getApplicationContext())); + Context context = ApplicationProvider.getApplicationContext(); Bundle arguments = androidx.test.platform.app.InstrumentationRegistry.getArguments(); String baseUrl = arguments.getString("TEST_SERVER_URL"); @@ -71,14 +85,10 @@ public void login() throws InterruptedException { try { // Delete account if exists - onView(withContentDescription(R.string.nc_settings)).perform(click()); - onView(withId(R.id.settings_remove_account)).perform(click()); - onView(withText(R.string.nc_settings_remove)).perform(click()); - // The remove button must be clicked two times - onView(withId(R.id.settings_remove_account)).perform(click()); - // And yes: The button must be clicked two times - onView(withText(R.string.nc_settings_remove)).perform(click()); - onView(withText(R.string.nc_settings_remove)).perform(click()); + clickNodeWithContentDescription(context.getString(R.string.nc_settings)); + clickNodeWithText(context.getString(R.string.nc_settings)); + clickNodeWithText(context.getString(R.string.nc_settings_remove_account)); + clickNodeWithText(context.getString(R.string.nc_settings_remove)); } catch (Exception ie2) { // ignore } finally { @@ -124,12 +134,20 @@ public void login() throws InterruptedException { Thread.sleep(5 * 1000); - onView(withContentDescription(R.string.nc_settings)).perform(click()); - onView(withId(R.id.user_name)).check(matches(withText("User One"))); + clickNodeWithContentDescription(context.getString(R.string.nc_settings)); + assertIsDisplayed(onNodeWithText(composeRule, "User One", false, false, false)); activityScenario.onActivity(activity -> { assertEquals(loginName, Objects.requireNonNull(activity.defaultAccountProvider.getDefaultUserBlocking()).getUserId()); }); } + + private void clickNodeWithText(String text) { + performClick(onNodeWithText(composeRule, text, false, false, false)); + } + + private void clickNodeWithContentDescription(String label) { + performClick(onNodeWithContentDescription(composeRule, label, false, false, false)); + } }