Skip to content

Commit

Permalink
debug test exception: AssertionError: No node found that matches Test…
Browse files Browse the repository at this point in the history
…Tag = 'EnvironmentDropdown/DropdownItem/*' in scrollable container
  • Loading branch information
sunny-chung committed Nov 6, 2024
1 parent 05b4426 commit a00d2a2
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.SemanticsPropertyKey
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -155,6 +158,9 @@ fun <T : DropDownable> ContextMenuView(
expanded = isShowContextMenu,
onDismissRequest = onDismissRequest,
modifier = Modifier.background(colors.backgroundContextMenu)
.semantics {
set(DropDownDisplayTexts, populatedItems.map { it.displayText })
}
.run {
if (testTagParts != null) {
testTag(buildTestTag(*testTagParts, TestTagPart.DropdownMenu)!!)
Expand Down Expand Up @@ -228,3 +234,10 @@ data class DropDownMap<T>(private val values: List<DropDownKeyValue<T>>) {
operator fun get(key: T) = mapByKey[key]

}

val DropDownDisplayTexts = SemanticsPropertyKey<List<String>>(
name = "DropDownDisplayTexts",
mergePolicy = { parentValue, childValue ->
parentValue ?: childValue
}
)

0 comments on commit a00d2a2

Please sign in to comment.