This is an automated email from the ASF dual-hosted git repository.
thiagohp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
The following commit(s) were added to refs/heads/master by this push:
new 8c6cc2d96 Rewriting WebResourcesSpec into Java to avoid Geb problems
8c6cc2d96 is described below
commit 8c6cc2d96997894a773854f47a284f085e4c5606
Author: Thiago H. de Paula Figueiredo <[email protected]>
AuthorDate: Fri Dec 1 20:39:09 2023 -0300
Rewriting WebResourcesSpec into Java to avoid Geb problems
(missing changed files)
---
.../services/web/WebResourcesTest.java | 97 ++++++++++------------
.../resources/t5/webresources/pages/MultiLess.tml | 2 +-
2 files changed, 43 insertions(+), 56 deletions(-)
diff --git
a/tapestry-webresources/src/test/java/t5/webresources/services/web/WebResourcesTest.java
b/tapestry-webresources/src/test/java/t5/webresources/services/web/WebResourcesTest.java
index facbc0ef6..e39cb9c58 100644
---
a/tapestry-webresources/src/test/java/t5/webresources/services/web/WebResourcesTest.java
+++
b/tapestry-webresources/src/test/java/t5/webresources/services/web/WebResourcesTest.java
@@ -1,62 +1,49 @@
-package t5.webresources.tests
-
-import geb.spock.GebSpec
-import org.apache.tapestry5.test.JettyRunner
-import spock.lang.Shared
-
-class WebResourcesSpec extends GebSpec {
-
- @Shared
- def runner;
-
- def setupSpec() {
- runner = new JettyRunner("src/test/webapp", "/", 8080, 8081);
-
- runner.start()
+// Copyright 2023 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package t5.webresources.services.web;
+
+import org.apache.tapestry5.test.SeleniumTestCase;
+import org.apache.tapestry5.test.TapestryTestConfiguration;
+import org.testng.annotations.Test;
+
+/**
+ * Adapted from WebResourcesSpec.groovy.s
+ */
+@TapestryTestConfiguration(webAppFolder = "src/test/webapp")
+public class WebResourcesTest extends SeleniumTestCase {
+
+ @Test
+ public void test_CoffeeScript_compilation()
+ {
+ open("/");
+ waitForInitializedPage();
+ assertEquals(getText("banner"), "Index module loaded, bare!");
}
- def cleanupSpec() {
- if (runner != null)
- runner.stop()
+ @Test
+ public void test_Less_compilation()
+ {
+ open("/");
+ click("css=.navbar .dropdown-toggle");
+ click("link=MultiLess");
+ waitForInitializedPage();
+ waitForCondition("document.getElementById('demo') != null",
PAGE_LOAD_TIMEOUT);
+
assertEquals(getEval("window.getComputedStyle(document.getElementById('demo'),
null).getPropertyValue('background-color')"), "rgb(179, 179, 255)");
}
- def "CoffeeScript compilation"() {
-
- when:
-
- // Open index page
- go()
-
- waitFor { $('body').@'data-page-initialized' == 'true' }
-
- then:
-
- // This text is buried inside a CoffeeScript file; for it to be
present in the DOM
- // means that the CoffeeScript was compiled to JS and executed.
- $("#banner").text().trim() == "Index module loaded, bare!"
+ private void waitForInitializedPage() {
+ waitForCondition("$('body').attr('data-page-initialized') == 'true' ",
PAGE_LOAD_TIMEOUT);
}
- def "Less compilation"() {
-
- when:
-
- go()
-
- waitFor { $('body').@'data-page-initialized' == 'true' }
-
- // Because the CoffeeScript may already be pre-compiled, it can
outrace the Less compilation.
- // For some reason, the navbar is invisible (at least to Selenium)
until the CSS loads.
-
- // waitFor { $(".navbar .dropdown-toggle").visible() }
-
- $(".navbar .dropdown-toggle").click()
-
- $(".navbar .dropdown-menu a", text: "MultiLess").click()
-
- waitFor { !$(".demo").empty }
-
- then:
-
- $(".demo").css("background-color") == "rgb(179, 179, 255)"
- }
}
diff --git
a/tapestry-webresources/src/test/resources/t5/webresources/pages/MultiLess.tml
b/tapestry-webresources/src/test/resources/t5/webresources/pages/MultiLess.tml
index 86559e8ca..12107e876 100644
---
a/tapestry-webresources/src/test/resources/t5/webresources/pages/MultiLess.tml
+++
b/tapestry-webresources/src/test/resources/t5/webresources/pages/MultiLess.tml
@@ -4,7 +4,7 @@
-<div class="demo">
+<div class="demo" id="demo">
<h3>Primary: should be dark blue.</h3>