Skip to content

Commit 2094ade

Browse files
committed
Cleanup the httpEndpoints_meta test and make it more correct
1 parent 43a3f3b commit 2094ade

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/jvmTest/kotlin/IntegrationTests.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ import kotlin.time.Duration.Companion.seconds
2525
@Testcontainers
2626
class IntegrationTests {
2727

28+
/**
29+
* A container running the "raw" Chrome with support for the JSON HTTP API of the DevTools protocol (in addition to
30+
* the web socket API).
31+
*
32+
* One must first connect via the HTTP API at `http://localhost:{port}` and then get the web socket URL from there.
33+
*/
2834
@Container
2935
var chromeContainer: GenericContainer<*> = GenericContainer("zenika/alpine-chrome")
3036
.withExposedPorts(9222)
@@ -51,17 +57,18 @@ class IntegrationTests {
5157
val version = chrome.version()
5258
assertTrue(version.browser.contains("Chrome"))
5359
assertTrue(version.userAgent.contains("HeadlessChrome"))
54-
assertTrue(version.webSocketDebuggerUrl.startsWith("ws://localhost"))
60+
assertTrue(version.webSocketDebuggerUrl.startsWith("ws://"), "the debugger URL should start with ws://, but was: ${version.webSocketDebuggerUrl}")
5561

5662
val protocolJson = chrome.protocolJson()
5763
assertTrue(protocolJson.isNotEmpty(), "the JSON definition of the protocol should not be empty")
5864

59-
val targets = chrome.targets()
60-
assertTrue(targets.isNotEmpty(), "there should be at least the about:blank target")
61-
6265
@Suppress("DEPRECATION") // the point is to test this deprecated API
63-
val googleTab = chrome.newTab("https://www.google.com")
66+
val googleTab = chrome.newTab(url = "https://www.google.com")
6467
assertEquals("https://www.google.com", googleTab.url.trimEnd('/'))
68+
69+
val targets = chrome.targets()
70+
assertTrue(targets.any { it.url.trimEnd('/') == "https://www.google.com" }, "the google.com page target should be listed, got: $targets")
71+
6572
chrome.closeTab(googleTab.id)
6673
}
6774
}

0 commit comments

Comments
 (0)