From d0e47e1bfb32f14b2613d353e1df7c11ad51cb61 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 17 Feb 2019 16:04:18 +0100 Subject: Fixed tests with headless Chrome. --- build.gradle | 7 ++++++- kvision-modules/kvision-bootstrap/build.gradle | 3 +++ .../src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt | 2 +- kvision-modules/kvision-bootstrap/webpack.config.d/bootstrap.js | 4 ++++ kvision-modules/kvision-bootstrap/webpack.config.d/css.js | 2 ++ kvision-modules/kvision-datetime/build.gradle | 3 +++ kvision-modules/kvision-handlebars/build.gradle | 3 +++ kvision-modules/kvision-i18n/build.gradle | 3 +++ kvision-modules/kvision-richtext/build.gradle | 3 +++ kvision-modules/kvision-select/build.gradle | 3 +++ kvision-modules/kvision-spinner/build.gradle | 3 +++ .../kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt | 4 ++-- kvision-modules/kvision-upload/build.gradle | 3 +++ kvision-modules/shared.gradle | 5 +++++ 14 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 kvision-modules/kvision-bootstrap/webpack.config.d/bootstrap.js create mode 100644 kvision-modules/kvision-bootstrap/webpack.config.d/css.js diff --git a/build.gradle b/build.gradle index 705fe84a..69d5470a 100644 --- a/build.gradle +++ b/build.gradle @@ -139,6 +139,7 @@ if (!project.gradle.startParameter.taskNames.contains("dokka")) { dependency("element-resize-event", "3.0.3") dependency("navigo", "7.0.0") devDependency("karma", "3.1.4") + devDependency("karma-chrome-launcher", "2.2.0") devDependency("qunit", "2.8.0") } @@ -147,7 +148,10 @@ if (!project.gradle.startParameter.taskNames.contains("dokka")) { contentPath = file('src/main/web') mode = production ? "production" : "development" } - + karma { + plugins = ["karma-chrome-launcher"] + browsers = ["ChromeHeadless"] + } define "PRODUCTION", production } @@ -233,6 +237,7 @@ if (!project.gradle.startParameter.taskNames.contains("dokka")) { afterEvaluate { tasks.getByName("webpack-bundle") { dependsOn(copyResources) } tasks.getByName("webpack-run") { dependsOn(copyResources) } + tasks.getByName("test") { dependsOn(copyResources, copyResourcesForTests) } tasks.getByName("karma-start") { dependsOn(copyResources, copyResourcesForTests) } } } diff --git a/kvision-modules/kvision-bootstrap/build.gradle b/kvision-modules/kvision-bootstrap/build.gradle index a1aec534..e81e384c 100644 --- a/kvision-modules/kvision-bootstrap/build.gradle +++ b/kvision-modules/kvision-bootstrap/build.gradle @@ -9,6 +9,9 @@ kotlinFrontend { dependency("font-awesome-webpack", "github:jarecsni/font-awesome-webpack") dependency("awesome-bootstrap-checkbox", "0.3.7") dependency("bootstrap-vertical-tabs", "1.2.2") + devDependency("karma", "3.1.4") + devDependency("karma-chrome-launcher", "2.2.0") + devDependency("qunit", "2.8.0") } } diff --git a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt index 477ab1f6..e87626ca 100644 --- a/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt +++ b/kvision-modules/kvision-bootstrap/src/test/kotlin/test/pl/treksoft/kvision/window/WindowSpec.kt @@ -44,7 +44,7 @@ class WindowSpec : DomSpec { ) window.isResizable = true assertEqualsHtml( - "

Window title

", + "

Window title

", element?.innerHTML, "Should render floating window with resizable handler" ) diff --git a/kvision-modules/kvision-bootstrap/webpack.config.d/bootstrap.js b/kvision-modules/kvision-bootstrap/webpack.config.d/bootstrap.js new file mode 100644 index 00000000..32a7c4d0 --- /dev/null +++ b/kvision-modules/kvision-bootstrap/webpack.config.d/bootstrap.js @@ -0,0 +1,4 @@ +config.module.rules.push({test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/font-woff'}); +config.module.rules.push({test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=application/octet-stream'}); +config.module.rules.push({test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader'}); +config.module.rules.push({test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url-loader?limit=10000&mimetype=image/svg+xml'}); diff --git a/kvision-modules/kvision-bootstrap/webpack.config.d/css.js b/kvision-modules/kvision-bootstrap/webpack.config.d/css.js new file mode 100644 index 00000000..5d710d35 --- /dev/null +++ b/kvision-modules/kvision-bootstrap/webpack.config.d/css.js @@ -0,0 +1,2 @@ +config.module.rules.push({ test: /\.css$/, loader: "style-loader!css-loader" }); + diff --git a/kvision-modules/kvision-datetime/build.gradle b/kvision-modules/kvision-datetime/build.gradle index b853d2f4..610b1d9c 100644 --- a/kvision-modules/kvision-datetime/build.gradle +++ b/kvision-modules/kvision-datetime/build.gradle @@ -4,6 +4,9 @@ kotlinFrontend { npm { dependency("bootstrap-datetime-picker", "2.4.4") + devDependency("karma", "3.1.4") + devDependency("karma-chrome-launcher", "2.2.0") + devDependency("qunit", "2.8.0") } } diff --git a/kvision-modules/kvision-handlebars/build.gradle b/kvision-modules/kvision-handlebars/build.gradle index 3a374298..f0cc69ec 100644 --- a/kvision-modules/kvision-handlebars/build.gradle +++ b/kvision-modules/kvision-handlebars/build.gradle @@ -5,6 +5,9 @@ kotlinFrontend { npm { dependency("handlebars", "4.0.12") dependency("handlebars-loader", "1.7.1") + devDependency("karma", "3.1.4") + devDependency("karma-chrome-launcher", "2.2.0") + devDependency("qunit", "2.8.0") } } diff --git a/kvision-modules/kvision-i18n/build.gradle b/kvision-modules/kvision-i18n/build.gradle index a2b6d3f8..88147bbe 100644 --- a/kvision-modules/kvision-i18n/build.gradle +++ b/kvision-modules/kvision-i18n/build.gradle @@ -4,6 +4,9 @@ kotlinFrontend { npm { dependency("jed", "1.1.1") + devDependency("karma", "3.1.4") + devDependency("karma-chrome-launcher", "2.2.0") + devDependency("qunit", "2.8.0") } } diff --git a/kvision-modules/kvision-richtext/build.gradle b/kvision-modules/kvision-richtext/build.gradle index 6f0c918d..9b74fd1c 100644 --- a/kvision-modules/kvision-richtext/build.gradle +++ b/kvision-modules/kvision-richtext/build.gradle @@ -4,6 +4,9 @@ kotlinFrontend { npm { dependency("trix", "1.0.0") + devDependency("karma", "3.1.4") + devDependency("karma-chrome-launcher", "2.2.0") + devDependency("qunit", "2.8.0") } } diff --git a/kvision-modules/kvision-select/build.gradle b/kvision-modules/kvision-select/build.gradle index f8fcbc8a..65b8a83c 100644 --- a/kvision-modules/kvision-select/build.gradle +++ b/kvision-modules/kvision-select/build.gradle @@ -5,6 +5,9 @@ kotlinFrontend { npm { dependency("bootstrap-select", "1.12.4") dependency("ajax-bootstrap-select", "1.4.3") + devDependency("karma", "3.1.4") + devDependency("karma-chrome-launcher", "2.2.0") + devDependency("qunit", "2.8.0") } } diff --git a/kvision-modules/kvision-spinner/build.gradle b/kvision-modules/kvision-spinner/build.gradle index 0c3a2940..e7600e5a 100644 --- a/kvision-modules/kvision-spinner/build.gradle +++ b/kvision-modules/kvision-spinner/build.gradle @@ -4,6 +4,9 @@ kotlinFrontend { npm { dependency("bootstrap-touchspin", "4.2.5") + devDependency("karma", "3.1.4") + devDependency("karma-chrome-launcher", "2.2.0") + devDependency("qunit", "2.8.0") } } diff --git a/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt b/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt index e2eec3f9..30f12a93 100644 --- a/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt +++ b/kvision-modules/kvision-spinner/src/test/kotlin/test/pl/treksoft/kvision/form/spinner/SpinnerSpec.kt @@ -43,13 +43,13 @@ class SpinnerSpec : DomSpec { val element = document.getElementById("test") val id = ti.input.id assertEqualsHtml( - "
", + "
", element?.innerHTML, "Should render correct spinner input form control" ) ti.validatorError = "Validation Error" assertEqualsHtml( - "
Validation Error
", + "
Validation Error
", element?.innerHTML, "Should render correct spinner input form control with validation error" ) diff --git a/kvision-modules/kvision-upload/build.gradle b/kvision-modules/kvision-upload/build.gradle index 943bb927..8b90532c 100644 --- a/kvision-modules/kvision-upload/build.gradle +++ b/kvision-modules/kvision-upload/build.gradle @@ -4,6 +4,9 @@ kotlinFrontend { npm { dependency("bootstrap-fileinput", "4.5.2") + devDependency("karma", "3.1.4") + devDependency("karma-chrome-launcher", "2.2.0") + devDependency("qunit", "2.8.0") } } diff --git a/kvision-modules/shared.gradle b/kvision-modules/shared.gradle index 4ded9c6c..2b45f630 100644 --- a/kvision-modules/shared.gradle +++ b/kvision-modules/shared.gradle @@ -11,6 +11,11 @@ kotlinFrontend { } define "PRODUCTION", production + + karma { + plugins = ["karma-chrome-launcher"] + browsers = ["ChromeHeadless"] + } } -- cgit