Skip to content

Commit 8e3cd29

Browse files
committed
add test for api ref doc analytics
1 parent 12c1338 commit 8e3cd29

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

dokka-aws/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ description = "Custom Dokka plugin for AWS Kotlin SDK API docs"
1818
dependencies {
1919
compileOnly(libs.dokka.base)
2020
compileOnly(libs.dokka.core)
21+
22+
testImplementation(libs.jsoup)
23+
testImplementation(libs.junit.jupiter)
24+
testImplementation(libs.kotest.assertions.core.jvm)
25+
testImplementation(libs.kotlin.test.junit5)
26+
}
27+
28+
tasks.test {
29+
useJUnitPlatform()
2130
}
2231

2332
tasks.withType<KotlinCompile> {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
package aws.sdk.kotlin.dokka
6+
7+
import org.jsoup.Jsoup
8+
import org.junit.jupiter.api.Assumptions.assumeTrue
9+
import org.junit.jupiter.api.Test
10+
import java.io.File
11+
import kotlin.test.assertTrue
12+
13+
class DokkaAwsTest {
14+
@Test
15+
fun testLoadScripts() {
16+
val testFile = File("../build/dokka/htmlMultiModule/index.html")
17+
18+
assumeTrue(
19+
testFile.exists(),
20+
"Skipping test: test file does not exist"
21+
)
22+
23+
val document = Jsoup.parse(testFile, "UTF-8")
24+
25+
val expectedScripts = listOf(
26+
"awshome_s_code.js"
27+
)
28+
29+
val scripts = document.head().select("script[src]")
30+
31+
expectedScripts.forEach { expectedScript ->
32+
assertTrue(
33+
scripts.any { it.attr("src").endsWith(expectedScript) },
34+
"Expected script $expectedScript not found"
35+
)
36+
}
37+
}
38+
}

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ kotlinx-benchmark-version = "0.4.12"
2626
kotlinx-serialization-version = "1.7.3"
2727
mockk-version = "1.13.13"
2828
slf4j-version = "2.0.16"
29+
jsoup-version = "1.19.1"
2930

3031
[libraries]
3132
aws-kotlin-repo-tools-build-support = { module="aws.sdk.kotlin.gradle:build-support", version.ref = "aws-kotlin-repo-tools-version" }
@@ -111,6 +112,8 @@ smithy-aws-smoke-test-model = { module = "software.amazon.smithy:smithy-aws-smok
111112
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-version" }
112113
junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit-version" }
113114

115+
jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup-version" }
116+
114117
kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest-version" }
115118
kotest-assertions-core-jvm = { module = "io.kotest:kotest-assertions-core-jvm", version.ref = "kotest-version" }
116119
kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest-version" }

0 commit comments

Comments
 (0)