Skip to content

Commit

Permalink
adjustments to resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
julian-wls committed Nov 4, 2024
1 parent 2619f75 commit 146894f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<MetisModificationFailure>)?) {
Expand Down

0 comments on commit 146894f

Please sign in to comment.