-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure dev-ui relocation are added to the importmap
Signed-off-by: Phillip Kruger <[email protected]>
- Loading branch information
1 parent
75cf0bf
commit 358daa1
Showing
2 changed files
with
56 additions
and
1 deletion.
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
55 changes: 55 additions & 0 deletions
55
...s/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/devui/DevUIImportmapTest.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,55 @@ | ||
package io.quarkus.vertx.http.devui; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.*; | ||
|
||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.RestAssured; | ||
import io.restassured.response.Response; | ||
|
||
public class DevUIImportmapTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.withEmptyApplication(); | ||
|
||
@Test | ||
public void testImportMap() { | ||
Response response = RestAssured.given() | ||
.when() | ||
.get("q/dev-ui/configuration-form-editor").then() | ||
.statusCode(200) | ||
.extract() | ||
.response(); | ||
|
||
String htmlContent = response.asString(); | ||
Pattern pattern = Pattern.compile("<script type=\"importmap\">(.*?)</script>", Pattern.DOTALL); | ||
Matcher matcher = pattern.matcher(htmlContent); | ||
|
||
assertThat("Script tag not found", matcher.find(), is(true)); | ||
String importmapjson = matcher.group(1); | ||
ObjectMapper mapper = new ObjectMapper(); | ||
try { | ||
Map<String, Map<String, String>> importsMap = mapper.readValue(importmapjson, Map.class); | ||
Map<String, String> importMap = importsMap.get("imports"); | ||
assertThat("Normal mapping (@qomponent/qui-badge) not present in the importmap", | ||
importMap.containsKey("@qomponent/qui-badge"), is(true)); | ||
assertThat("Relocated mapping (qui-badge) not present in the importmap", | ||
importMap.containsKey("qui-badge"), is(true)); | ||
} catch (JsonProcessingException ex) { | ||
throw new RuntimeException(ex); | ||
} | ||
|
||
} | ||
|
||
} |