Skip to content

Commit c25c858

Browse files
authored
Fix HTML transition tests for Chrome 140 (#5426)
This PR fixes TransitionTests for Chrome 140 ## Testing in html prpoject `./gradlew jsTest` ## Release Notes N/A
1 parent cd7ed11 commit c25c858

File tree

4 files changed

+372
-185
lines changed

4 files changed

+372
-185
lines changed

html/buildSrc/src/main/kotlin/SeleniumDriverPlugin.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
44
import java.io.File
55
import java.net.URL
66

7-
private val CHROME_DRIVER_VERSION = "114.0.5735.90"
8-
private val GECKO_DRIVER_VERSION = "0.31.0"
7+
// https://googlechromelabs.github.io/chrome-for-testing/
8+
private val CHROME_DRIVER_VERSION = "140.0.7339.82"
9+
private val GECKO_DRIVER_VERSION = "0.36.0"
910

1011
private fun download(url: String, file: File) {
1112
println("downloading ${url} to ${file}")
@@ -42,17 +43,18 @@ private fun resolvePath(id: String): String {
4243
val arch = DefaultNativePlatform.getCurrentArchitecture()
4344

4445
val geckoRepo = "https://github.com/mozilla/geckodriver/releases/download/v$GECKO_DRIVER_VERSION/"
45-
val chromeRepo = "https://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/"
46+
val chromeRepo = "https://storage.googleapis.com/chrome-for-testing-public/$CHROME_DRIVER_VERSION/"
4647

4748
return when (id) {
49+
//https://googlechromelabs.github.io/chrome-for-testing/
4850
"chrome" -> chromeRepo + when {
49-
os.isWindows -> "chromedriver_win32.zip"
51+
os.isWindows -> "win32/chromedriver-win32.zip"
5052
os.isMacOsX -> if (arch.isArm) {
51-
"chromedriver_mac64_m1.zip"
53+
"mac-arm64/chromedriver-mac-arm64.zip"
5254
} else {
53-
"chromedriver_mac64.zip"
55+
"mac-x64/chromedriver-mac-x64.zip"
5456
}
55-
else -> "chromedriver_linux64.zip"
57+
else -> "linux64/chromedriver-linux64.zip"
5658
}
5759
"gecko" -> geckoRepo + when {
5860
os.isWindows -> "geckodriver-v$GECKO_DRIVER_VERSION-win64.zip"

html/core/src/jsMain/kotlin/org/jetbrains/compose/web/css/CSSUnits.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
package org.jetbrains.compose.web.css
44

5+
// External declarations for CSS OM - https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model
6+
57
external interface CSSNumericValue<T : CSSUnit> : StylePropertyValue, CSSVariableValueAs<CSSNumericValue<T>>
68

79
external interface CSSSizeValue<T : CSSUnit> : CSSNumericValue<T> {

html/core/src/jsTest/kotlin/css/TransitionsTests.kt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,34 @@ import org.jetbrains.compose.web.css.timingFunction
1414
import org.jetbrains.compose.web.css.transitions
1515
import org.jetbrains.compose.web.dom.Div
1616
import org.jetbrains.compose.web.testutils.runTest
17+
import org.w3c.dom.css.CSSStyleDeclaration
1718
import kotlin.test.Test
1819
import kotlin.test.assertEquals
1920

2021
@ExperimentalComposeWebApi
2122
class TransitionsTests {
23+
24+
private fun CSSStyleDeclaration.computedTransition(): String {
25+
val cssDelimiter = Regex(",\\s*")
26+
27+
// setting transition property affects subProperties, but we should check for them separately
28+
val props = transitionProperty.split(cssDelimiter)
29+
val durations = transitionDuration.split(cssDelimiter)
30+
val timings = transitionTimingFunction.split(cssDelimiter)
31+
val delays = transitionDelay.split(cssDelimiter)
32+
33+
return props.indices.joinToString(", ") { i ->
34+
"${props[i]} ${durations[i]} ${timings[i]} ${delays[i]}"
35+
}
36+
}
37+
2238
@Test
2339
fun duration() = runTest {
2440
composition {
2541
Div({ style { transitions { "width" { duration(1.s) } }}})
2642
}
2743

28-
assertEquals("width 1s ease 0s", nextChild().style.transition)
44+
assertEquals("width 1s ease 0s", nextChild().style.computedTransition())
2945
}
3046

3147
@Test
@@ -34,7 +50,7 @@ class TransitionsTests {
3450
Div({ style { transitions { "width" { duration(1.s) }; "height" { duration(2.s) } }}})
3551
}
3652

37-
assertEquals("width 1s ease 0s, height 2s ease 0s", nextChild().style.transition)
53+
assertEquals("width 1s ease 0s, height 2s ease 0s", nextChild().style.computedTransition())
3854
}
3955

4056
@Test
@@ -43,7 +59,7 @@ class TransitionsTests {
4359
Div({ style { transitions { all { duration(1.s) } }}})
4460
}
4561

46-
assertEquals("all 1s ease 0s", nextChild().style.transition)
62+
assertEquals("all 1s ease 0s", nextChild().style.computedTransition())
4763
}
4864

4965
@Test
@@ -52,7 +68,7 @@ class TransitionsTests {
5268
Div({ style { transitions { "width" { duration(1.s); timingFunction(AnimationTimingFunction.EaseInOut) }}}})
5369
}
5470

55-
assertEquals("width 1s ease-in-out 0s", nextChild().style.transition)
71+
assertEquals("width 1s ease-in-out 0s", nextChild().style.computedTransition())
5672
}
5773

5874
@Test
@@ -61,7 +77,7 @@ class TransitionsTests {
6177
Div({ style { transitions { "width" { duration(1.s); delay(2.s) }}}})
6278
}
6379

64-
assertEquals("width 1s ease 2s", nextChild().style.transition)
80+
assertEquals("width 1s ease 2s", nextChild().style.computedTransition())
6581
}
6682

6783
@Test
@@ -73,8 +89,8 @@ class TransitionsTests {
7389
Div({ style { transitions { defaultDuration(1.s); myList { duration(2.s) }}}})
7490
}
7591

76-
assertEquals("width 1s ease 0s, height 1s ease 0s", nextChild().style.transition)
77-
assertEquals("width 0s ease 0s, height 1s ease 0s, width 2s ease 0s", nextChild().style.transition)
78-
assertEquals("width 2s ease 0s, height 2s ease 0s", nextChild().style.transition)
92+
assertEquals("width 1s ease 0s, height 1s ease 0s", nextChild().style.computedTransition())
93+
assertEquals("width 0s ease 0s, height 1s ease 0s, width 2s ease 0s", nextChild().style.computedTransition())
94+
assertEquals("width 2s ease 0s, height 2s ease 0s", nextChild().style.computedTransition())
7995
}
8096
}

0 commit comments

Comments
 (0)