Fix instrumented test compilation after composable refactor

The Error composable was replaced by Placeholder and TopAppBar lost its
onNavigateUp parameter, but ErrorTest and TopAppBarTest were not
updated, so the androidTest sources no longer compiled. Rewrite
ErrorTest as PlaceholderTest against the new API (the action button is
now omitted entirely without a handler instead of rendered disabled)
and use showNavigationIcon in TopAppBarTest.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
MiMoHo
2026-07-06 02:43:18 +02:00
parent 3ab3943f1e
commit c6753a5ebd
3 changed files with 55 additions and 35 deletions

View File

@@ -1,34 +0,0 @@
/*
* SPDX-FileCopyrightText: 2025 The Calyx Institute
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.aurora.store.compose.composable
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.assertIsNotEnabled
import androidx.compose.ui.test.onNodeWithText
import com.aurora.store.IsolatedTest
import com.aurora.store.R
import org.junit.Test
class ErrorTest : IsolatedTest() {
@Test
fun testErrorWithoutActionHandling() {
setContent {
Error(
painter = painterResource(R.drawable.ic_apps_outage),
message = "An error occurred!",
actionMessage = "Retry"
)
}
composeTestRule.onNodeWithText("Retry")
.assertIsDisplayed()
.assertHasClickAction()
.assertIsNotEnabled()
}
}

View File

@@ -0,0 +1,54 @@
/*
* SPDX-FileCopyrightText: 2025 The Calyx Institute
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.aurora.store.compose.composable
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.aurora.store.IsolatedTest
import com.aurora.store.R
import org.junit.Assert.assertTrue
import org.junit.Test
class PlaceholderTest : IsolatedTest() {
@Test
fun testPlaceholderWithoutActionHandling() {
setContent {
Placeholder(
painter = painterResource(R.drawable.ic_apps_outage),
message = "An error occurred!",
actionLabel = "Retry"
)
}
composeTestRule.onNodeWithText("An error occurred!")
.assertIsDisplayed()
composeTestRule.onNodeWithText("Retry")
.assertDoesNotExist()
}
@Test
fun testPlaceholderActionClick() {
var clicked = false
setContent {
Placeholder(
painter = painterResource(R.drawable.ic_apps_outage),
message = "An error occurred!",
actionLabel = "Retry",
onAction = { clicked = true }
)
}
composeTestRule.onNodeWithText("Retry")
.assertIsDisplayed()
.performClick()
assertTrue(clicked)
}
}

View File

@@ -16,7 +16,7 @@ class TopAppBarTest : IsolatedTest() {
@Test
fun testTitleWithNoNavigationAction() {
setContent {
TopAppBar(title = "About", onNavigateUp = null)
TopAppBar(title = "About", showNavigationIcon = false)
}
composeTestRule.onNodeWithText("About")