Skip to content

Commit de8557e

Browse files
committed
test: Jasmine 6
Adjust to Jasmine 6.
1 parent 9bb8a1f commit de8557e

File tree

5 files changed

+16
-26
lines changed

5 files changed

+16
-26
lines changed

tobago-example/tobago-example-demo/src/main/webapp/content/900-test/gridLayout/10-label-horizontal/Grid_Layout_Label_Horizontal.test.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,6 @@ it("test CSS of the fields and labels of 'last1'", function () {
3434
JasmineUtils.checkGridCss(labelFn(), "4", "auto", "3", "auto");
3535
});
3636

37-
it("test CSS of the fields and labels of 'last1'", function () {
38-
let fieldFn = querySelectorFn("#page\\:mainForm\\:last1");
39-
let labelFn = querySelectorFn("#page\\:mainForm\\:last1\\:\\:label");
40-
41-
JasmineUtils.checkGridCss(fieldFn(), "3", "auto", "3", "auto");
42-
JasmineUtils.checkGridCss(labelFn(), "4", "auto", "3", "auto");
43-
});
44-
4537
it("test CSS of the fields and labels of 'first2'", function () {
4638
let fieldFn = querySelectorFn("#page\\:mainForm\\:first2");
4739
let labelFn = querySelectorFn("#page\\:mainForm\\:first2\\:\\:label");

tobago-example/tobago-example-demo/src/main/webapp/content/900-test/selectManyList/server-side-filtering/Server_side_filtering.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ it("SelectManyList: avoid 'no valid selection' error", function (done) {
6464
test.do(() => filterInput().value = "y");
6565
test.event("input", filterInput, () => tobagoSelectItems().length > 0);
6666
test.event("click", lysitheaSelectItem, () => badges().length > 0);
67-
test.do(() => expect(firstBadge().textContent).toBe("Lysithea"));
67+
test.do(() => expect(firstBadge().textContent.trim()).toBe("Lysithea"));
6868
test.event("click", reset, () => badges().length === 0);
6969
test.do(() => expect(popover()).toBeNull());
7070
test.start();

tobago-example/tobago-example-demo/src/main/webapp/content/900-test/z-misc/ajax/Ajax.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import {elementByIdFn, querySelectorAllFn, querySelectorFn} from "/script/tobago-test.js";
1919
import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js";
2020

21-
it("no layout manager", function (done) {
21+
it("Submit -> Reset", function (done) {
2222
const input = elementByIdFn("page:mainForm:form:input::field");
2323
const output = querySelectorFn("#page\\:mainForm\\:form\\:output .form-control-plaintext")
2424
const submit = elementByIdFn("page:mainForm:form:submit");
@@ -41,7 +41,7 @@ it("no layout manager", function (done) {
4141
test.start();
4242
});
4343

44-
it("no layout manager", function (done) {
44+
it("Ajax page reload", function (done) {
4545
const html = querySelectorAllFn("html")
4646
const body = querySelectorFn("body")
4747
const ajaxButton = elementByIdFn("page:mainForm:ajaxPageReload");

tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/integration/BasicTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.jupiter.api.Assertions;
2323
import org.junit.jupiter.api.BeforeAll;
2424
import org.junit.jupiter.api.Test;
25+
import org.openqa.selenium.By;
2526
import org.openqa.selenium.WebDriver;
2627
import org.openqa.selenium.WebElement;
2728
import org.slf4j.Logger;
@@ -61,7 +62,7 @@ void verifyExceptionTest() throws MalformedURLException, UnknownHostException, U
6162
List<WebElement> results = getJasmineResults(webDriver, path);
6263
Assertions.assertTrue(results.size() > 0, "no results detected");
6364
for (WebElement result : results) {
64-
if ("has no exception".equals(result.getAttribute("title"))) {
65+
if ("has no exception".equals(result.findElement(By.tagName("a")).getAttribute("textContent"))) {
6566
Assertions.assertEquals("jasmine-failed", result.getAttribute("class"), result.getAttribute("title"));
6667
} else {
6768
Assertions.assertEquals("jasmine-passed", result.getAttribute("class"), result.getAttribute("title"));
@@ -82,7 +83,7 @@ void verify404Test() throws MalformedURLException, UnknownHostException, Unsuppo
8283
List<WebElement> results = getJasmineResults(webDriver, path);
8384
Assertions.assertTrue(results.size() > 0, "no results detected");
8485
for (WebElement result : results) {
85-
if ("has no 404".equals(result.getAttribute("title"))) {
86+
if ("has no 404".equals(result.findElement(By.tagName("a")).getAttribute("textContent"))) {
8687
Assertions.assertEquals("jasmine-failed", result.getAttribute("class"), result.getAttribute("title"));
8788
} else {
8889
Assertions.assertEquals("jasmine-passed", result.getAttribute("class"), result.getAttribute("title"));

tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/integration/FrontendBase.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import java.time.Duration;
5252
import java.time.LocalTime;
5353
import java.util.List;
54+
import java.util.Objects;
5455
import java.util.stream.Collectors;
5556

5657
abstract class FrontendBase {
@@ -114,7 +115,13 @@ List<WebElement> getJasmineResults(WebDriver webDriver, String path)
114115
.pollingEvery(Duration.ofSeconds(1))
115116
.ignoring(NoSuchElementException.class);
116117
try {
117-
fluentWait.until(driver -> driver.findElement(By.className("jasmine-overall-result")));
118+
fluentWait.until(driver -> {
119+
WebElement progress =
120+
driver.findElement(By.className("jasmine_html-reporter")).findElement(By.tagName("progress"));
121+
int value = Integer.parseInt(Objects.requireNonNull(progress.getAttribute("value")));
122+
int max = Integer.parseInt(Objects.requireNonNull(progress.getAttribute("max")));
123+
return value == max;
124+
});
118125
} catch (TimeoutException e) {
119126
Assertions.fail(path + " timeout");
120127
}
@@ -124,7 +131,7 @@ List<WebElement> getJasmineResults(WebDriver webDriver, String path)
124131
Assertions.fail(errorDetail);
125132
}
126133

127-
return webDriver.findElements(By.cssSelector(".jasmine-symbol-summary li"));
134+
return webDriver.findElements(By.cssSelector(".jasmine-results li"));
128135
}
129136

130137
private String getErrorDetail() throws MalformedURLException, UnknownHostException {
@@ -152,12 +159,7 @@ void parseJasmineResults(List<WebElement> results, String path) throws Malformed
152159
fail = true;
153160
}
154161
stringBuilder.append(": ");
155-
stringBuilder.append(result.getAttribute("title"));
156-
}
157-
if (fail) {
158-
stringBuilder.append("\n");
159-
stringBuilder.append("failures details:\n");
160-
stringBuilder.append(getFailureDetails());
162+
stringBuilder.append(result.findElement(By.tagName("a")).getAttribute("textContent"));
161163
}
162164
LOG.info(stringBuilder.toString());
163165

@@ -167,11 +169,6 @@ void parseJasmineResults(List<WebElement> results, String path) throws Malformed
167169
}
168170
}
169171

170-
private String getFailureDetails() throws MalformedURLException, UnknownHostException {
171-
WebElement failures = getWebDriver().findElement(By.cssSelector(".jasmine-failures"));
172-
return failures.getText();
173-
}
174-
175172
String getTimeLeft(final LocalTime startTime, final int testSize, final int testNo) {
176173
final LocalTime now = LocalTime.now();
177174
final Duration completeWaitTime = Duration.between(startTime, now).dividedBy(testNo).multipliedBy(testSize);

0 commit comments

Comments
 (0)