Skip to content

Commit 88dba24

Browse files
committed
add a quill test (not working at the moment)
1 parent 3ce9948 commit 88dba24

File tree

4 files changed

+140
-0
lines changed

4 files changed

+140
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright (c) 2002-2025 Gargoyle Software Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* https://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
package org.htmlunit.libraries;
16+
17+
import java.net.URL;
18+
19+
import org.eclipse.jetty.server.Server;
20+
import org.htmlunit.WebDriverTestCase;
21+
import org.htmlunit.WebServerTestCase;
22+
import org.htmlunit.junit.BrowserRunner;
23+
import org.htmlunit.junit.BrowserRunner.Alerts;
24+
import org.htmlunit.junit.BrowserRunner.HtmlUnitNYI;
25+
import org.junit.AfterClass;
26+
import org.junit.BeforeClass;
27+
import org.junit.Test;
28+
import org.junit.runner.RunWith;
29+
import org.openqa.selenium.By;
30+
import org.openqa.selenium.WebDriver;
31+
32+
/**
33+
* Tests for https://github.com/slab/quill.
34+
*
35+
* @author Ronald Brill
36+
*/
37+
@RunWith(BrowserRunner.class)
38+
public class QuillTest extends WebDriverTestCase {
39+
40+
/** The server. */
41+
protected static Server SERVER_;
42+
43+
/**
44+
* @throws Exception if an error occurs
45+
*/
46+
@BeforeClass
47+
public static void startSesrver() throws Exception {
48+
SERVER_ = WebServerTestCase.createWebServer("src/test/resources/libraries/quill/", null);
49+
}
50+
51+
/**
52+
* @throws Exception if an error occurs
53+
*/
54+
@AfterClass
55+
public static void stopServer() throws Exception {
56+
if (SERVER_ != null) {
57+
SERVER_.stop();
58+
SERVER_.destroy();
59+
SERVER_ = null;
60+
}
61+
}
62+
63+
/**
64+
* @return the resource base URL
65+
*/
66+
protected URL getBaseUrl() {
67+
return URL_FIRST;
68+
}
69+
70+
/**
71+
* @throws Exception if the test fails
72+
*/
73+
@Test
74+
@Alerts("Bold Italic\\nHello World!\\nSome initial bold text")
75+
@HtmlUnitNYI
76+
public void basic() throws Exception {
77+
// fails because the lib uses classes
78+
doTest("QuillTest.html");
79+
}
80+
81+
private void doTest(final String filename) throws Exception {
82+
final WebDriver driver = getWebDriver();
83+
driver.get(getBaseUrl() + filename);
84+
85+
String content = driver.findElement(By.tagName("body")).getText();
86+
content = content.replace("\r", "").replace("\n", "\\n");
87+
assertEquals(getExpectedAlerts()[0], content);
88+
}
89+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>QuillTest</title>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
6+
7+
<!-- Include Quill stylesheet -->
8+
<link href="quill.snow.css" rel="stylesheet" />
9+
</head>
10+
<body>
11+
12+
13+
<!-- Create the toolbar container -->
14+
<div id="toolbar">
15+
<button class="ql-bold">Bold</button>
16+
<button class="ql-italic">Italic</button>
17+
</div>
18+
19+
<!-- Create the editor container -->
20+
<div id="editor">
21+
<p>Hello World!</p>
22+
<p>Some initial <strong>bold</strong> text</p>
23+
<p><br /></p>
24+
</div>
25+
26+
<!-- Include the Quill library -->
27+
<script src="quill.js"></script>
28+
29+
<!-- Initialize Quill editor -->
30+
<script>
31+
const quill = new Quill("#editor", {
32+
theme: "snow",
33+
});
34+
</script>
35+
36+
</body>
37+
</html>
38+

src/test/resources/libraries/quill/quill.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)