-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
612 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
integration-tests/src/main/resources/web/components/calendar/_imported.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
|
||
.calendar { | ||
h1 { | ||
background-color: red; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
integration-tests/src/main/resources/web/components/calendar/calendar.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div class="calendar"> | ||
<h1>Calendar</h1> | ||
<a href="page1">page1</a> | ||
<a href="page1" id="page1">page1</a> | ||
</div> |
2 changes: 2 additions & 0 deletions
2
integration-tests/src/main/resources/web/components/calendar/calendar.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
@import "_imported"; | ||
|
||
.calendar { | ||
h1 { | ||
font-size: 4rem; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
75 changes: 75 additions & 0 deletions
75
integration-tests/src/main/resources/web/public/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
integration-tests/src/main/resources/web/public/static/hello.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# hello |
64 changes: 64 additions & 0 deletions
64
integration-tests/src/test/java/io/quarkiverse/web/bundler/it/BundledTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.quarkiverse.web.bundler.it; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.assertj.core.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInfo; | ||
|
||
import io.quarkiverse.web.bundler.runtime.Bundled; | ||
import io.quarkus.devtools.testing.SnapshotTesting; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.restassured.RestAssured; | ||
import io.restassured.response.Response; | ||
|
||
@QuarkusTest | ||
public class BundledTest { | ||
|
||
@Inject | ||
Bundled bundled; | ||
|
||
@Test | ||
void testBundled(TestInfo info) throws Throwable { | ||
final Path temp = Files.createTempDirectory("bundled-test"); | ||
assertBundledFileMatchSnapshot(info, temp, "main.css", bundled.style("main")); | ||
|
||
Assertions.assertThat(bundled.mapping().names()) | ||
.containsExactlyInAnyOrder( | ||
"ajax-loader.gif", | ||
"slick.eot", | ||
"main.css", | ||
"main.css.map", | ||
"slick.ttf", | ||
"page1.css.map", | ||
"chunk.js.map", | ||
"chunk.js", | ||
"page1.css", | ||
"page1.js.map", | ||
"main.js", | ||
"slick.woff", | ||
"slick.svg", | ||
"page1.js", | ||
"main.js.map"); | ||
|
||
for (String name : bundled.mapping().names()) { | ||
RestAssured.get(bundled.resolve(name)) | ||
.then() | ||
.statusCode(200); | ||
} | ||
} | ||
|
||
private static void assertBundledFileMatchSnapshot(TestInfo info, Path dir, String name, String path) throws Throwable { | ||
final Response response = RestAssured.get(path) | ||
.then() | ||
.statusCode(200) | ||
.extract().response(); | ||
final String body = response.body().asString(); | ||
Files.writeString(dir.resolve(name), body); | ||
SnapshotTesting.assertThatMatchSnapshot(info, dir, name); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
integration-tests/src/test/java/io/quarkiverse/web/bundler/it/PublicAssetsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.quarkiverse.web.bundler.it; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.restassured.RestAssured; | ||
|
||
@QuarkusTest | ||
public class PublicAssetsTest { | ||
|
||
@TestHTTPResource("/images/logo.svg") | ||
URL logo; | ||
|
||
@TestHTTPResource("/hello.txt") | ||
URL txt; | ||
|
||
@TestHTTPResource("/static/hello.md") | ||
URL md; | ||
|
||
@Test | ||
void testLogo() throws IOException { | ||
RestAssured.get(logo) | ||
.then() | ||
.statusCode(200) | ||
.body(is(asString("/web/public/images/logo.svg"))); | ||
} | ||
|
||
@Test | ||
void testMD() throws IOException { | ||
RestAssured.get(md) | ||
.then() | ||
.statusCode(200) | ||
.body(is(asString("/web/public/static/hello.md"))); | ||
} | ||
|
||
@Test | ||
void testTXT() throws IOException { | ||
RestAssured.get(txt) | ||
.then() | ||
.statusCode(200) | ||
.body(is(asString("/web/public/hello.txt"))); | ||
} | ||
|
||
private static String asString(String name) throws IOException { | ||
try (InputStream resourceAsStream = PublicAssetsTest.class.getResourceAsStream(name)) { | ||
return new String(resourceAsStream.readAllBytes(), StandardCharsets.UTF_8); | ||
} | ||
} | ||
|
||
} |
14 changes: 0 additions & 14 deletions
14
integration-tests/src/test/java/io/quarkiverse/web/bundler/it/WebResourceTest.java
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
integration-tests/src/test/java/io/quarkiverse/web/bundler/it/WebTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package io.quarkiverse.web.bundler.it; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.net.URL; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import com.microsoft.playwright.BrowserContext; | ||
import com.microsoft.playwright.Page; | ||
import com.microsoft.playwright.Response; | ||
import com.microsoft.playwright.assertions.PlaywrightAssertions; | ||
|
||
import io.quarkiverse.quinoa.testing.QuarkusPlaywrightManager; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
import io.quarkus.test.common.http.TestHTTPResource; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
@QuarkusTestResource(QuarkusPlaywrightManager.class) | ||
public class WebTest { | ||
@QuarkusPlaywrightManager.InjectPlaywright | ||
BrowserContext context; | ||
|
||
@TestHTTPResource("/") | ||
URL url; | ||
|
||
@Test | ||
void root() { | ||
final Page page = context.newPage(); | ||
Response response = page.navigate(url.toString()); | ||
Assertions.assertEquals("OK", response.statusText()); | ||
|
||
page.waitForLoadState(); | ||
|
||
PlaywrightAssertions.assertThat(page).hasTitle("QWA"); | ||
|
||
page.waitForCondition(() -> page.innerText("#message") | ||
.equals("Unleash the script!!!!")); | ||
|
||
assertThat( | ||
page.querySelector("#message").evaluate("element => getComputedStyle(element).color")) | ||
.isEqualTo("rgb(255, 127, 80)"); | ||
|
||
assertThat( | ||
page.querySelector(".calendar h1").evaluate("element => getComputedStyle(element).color")) | ||
.isEqualTo("rgb(0, 0, 255)"); | ||
|
||
assertThat( | ||
page.querySelector(".calendar h1").evaluate("element => getComputedStyle(element).backgroundColor")) | ||
.isEqualTo("rgb(255, 0, 0)"); | ||
|
||
page.click("#page1"); | ||
page.waitForLoadState(); | ||
|
||
PlaywrightAssertions.assertThat(page).hasTitle("Page 1"); | ||
|
||
page.waitForCondition(() -> page.innerText("#message") | ||
.equals("This is page 1")); | ||
|
||
assertThat( | ||
page.querySelector("#message").evaluate("element => getComputedStyle(element).color")) | ||
.isEqualTo("rgb(0, 191, 255)"); | ||
|
||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
integration-tests/src/test/java/io/quarkiverse/web/bundler/it/WebTestIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.quarkiverse.web.bundler.it; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class WebTestIT extends WebTest { | ||
|
||
// Run the same tests | ||
|
||
} |
Oops, something went wrong.