mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-08-01 01:39:12 -04:00
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:
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class TopAppBarTest : IsolatedTest() {
|
||||
@Test
|
||||
fun testTitleWithNoNavigationAction() {
|
||||
setContent {
|
||||
TopAppBar(title = "About", onNavigateUp = null)
|
||||
TopAppBar(title = "About", showNavigationIcon = false)
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithText("About")
|
||||
|
||||
Reference in New Issue
Block a user