From 146894f7df9db78969957dfad652b39777009a17 Mon Sep 17 00:00:00 2001 From: Julian Waluschyk Date: Mon, 4 Nov 2024 11:00:25 +0100 Subject: [PATCH] adjustments to resolve comments --- .../metis/conversation/ui/post/PostItem.kt | 2 +- .../ConversationAnswerMessagesUITest.kt | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt index 09b844c45..5df625238 100644 --- a/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt +++ b/feature/metis/conversation/src/main/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ui/post/PostItem.kt @@ -119,7 +119,7 @@ internal fun PostItem( it .background(color = MaterialTheme.colorScheme.errorContainer) .clickable(onClick = onRequestRetrySend) - } else Modifier + } else modifier .combinedClickable( onClick = onClick, onLongClick = onLongClick diff --git a/feature/metis/conversation/src/test/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ConversationAnswerMessagesUITest.kt b/feature/metis/conversation/src/test/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ConversationAnswerMessagesUITest.kt index f6087ee20..d216728cb 100644 --- a/feature/metis/conversation/src/test/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ConversationAnswerMessagesUITest.kt +++ b/feature/metis/conversation/src/test/kotlin/de/tum/informatics/www1/artemis/native_app/feature/metis/conversation/ConversationAnswerMessagesUITest.kt @@ -1,16 +1,25 @@ package de.tum.informatics.www1.artemis.native_app.feature.metis.conversation import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.semantics.SemanticsActions +import androidx.compose.ui.semantics.SemanticsProperties +import androidx.compose.ui.semantics.getOrNull import androidx.compose.ui.test.assert +import androidx.compose.ui.test.assertHasClickAction import androidx.compose.ui.test.hasAnyChild +import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.hasText +import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onParent +import androidx.compose.ui.test.onRoot import androidx.compose.ui.test.performClick +import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performSemanticsAction +import androidx.compose.ui.test.printToLog import de.tum.informatics.www1.artemis.native_app.core.data.DataState import de.tum.informatics.www1.artemis.native_app.core.model.Course import de.tum.informatics.www1.artemis.native_app.core.test.BaseComposeTest @@ -75,6 +84,8 @@ class ConversationAnswerMessagesUITest : BaseComposeTest() { reactions = emptyList() ) + private fun testTagForAnswerPost(answerPostId: String) = "answerPost$answerPostId" + @Test fun `test GIVEN post is not resolved WHEN resolving the post THEN the post is resolved with the first answer post`() { var resolvedPost: IBasePost? = null @@ -167,13 +178,12 @@ class ConversationAnswerMessagesUITest : BaseComposeTest() { setupUi(resolvedPost) { CompletableDeferred() } - composeTestRule.onNodeWithText(post.content).assertExists() - composeTestRule.onNodeWithText(context.getString(R.string.post_is_resolved)).assertExists() - composeTestRule.onNodeWithText(context.getString(R.string.post_resolves)).assertExists() composeTestRule - .onNodeWithText(answers[resolvingIndex].content!!, useUnmergedTree = true) - .onParent() + .onNodeWithTag(testTagForAnswerPost(answers[resolvingIndex].postId), useUnmergedTree = true) .assert(hasAnyChild(hasText(context.getString(R.string.post_resolves)))) + composeTestRule + .onNodeWithTag(testTagForAnswerPost(answers[1].postId), useUnmergedTree = true) + .assert(hasAnyChild(hasText(context.getString(R.string.post_resolves)).not())) } private fun setupUi(post: PostPojo, onResolvePost: ((IBasePost) -> Deferred)?) {