Skip to content

Commit a65e5c4

Browse files
committed
feat: add a common UI test for FilterChip
1 parent 2d51002 commit a65e5c4

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

composeApp/build.gradle.kts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ kotlin {
1313
commonWebpackConfig {
1414
outputFileName = "composeApp.js"
1515
}
16+
testTask {
17+
useKarma {
18+
useFirefox()
19+
}
20+
}
1621
}
1722
binaries.executable()
1823
}
1924

2025
androidTarget {}
2126

22-
jvm("desktop")
27+
jvm()
2328

2429
listOf(
2530
iosX64(),
@@ -55,12 +60,25 @@ kotlin {
5560
implementation(libs.compose.webview)
5661
}
5762
}
58-
val desktopMain by getting {
63+
val jvmMain by getting {
5964
dependencies {
6065
implementation(compose.desktop.common)
6166
implementation(compose.desktop.currentOs)
6267
}
6368
}
69+
70+
val commonTest by getting {
71+
dependencies {
72+
implementation(kotlin("test"))
73+
74+
@OptIn(org.jetbrains.compose.ExperimentalComposeLibrary::class)
75+
implementation(compose.uiTest)
76+
}
77+
}
78+
79+
jvmTest.dependencies {
80+
implementation(compose.desktop.currentOs)
81+
}
6482
}
6583
}
6684

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package components
2+
3+
import androidx.compose.ui.test.ExperimentalTestApi
4+
import androidx.compose.ui.test.onNodeWithContentDescription
5+
import androidx.compose.ui.test.onNodeWithText
6+
import androidx.compose.ui.test.performClick
7+
import androidx.compose.ui.test.runComposeUiTest
8+
import kotlin.test.Test
9+
10+
class FilterChipTest {
11+
12+
@OptIn(ExperimentalTestApi::class)
13+
@Test
14+
fun `filter chip should be clickable and icon should be visible when clicked`() = runComposeUiTest {
15+
setContent {
16+
FilterChipExample()
17+
}
18+
19+
onNodeWithText("Filter chip").assertExists()
20+
onNodeWithText("Filter chip").performClick()
21+
onNodeWithContentDescription("Done icon").assertExists()
22+
}
23+
}

composeApp/src/desktopMain/kotlin/components/ConditionalWebView.kt renamed to composeApp/src/jvmMain/kotlin/components/ConditionalWebView.kt

File renamed without changes.

0 commit comments

Comments
 (0)