From d8fe591afd995014ac4c17619755482e09606e0c Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Thu, 14 Dec 2023 12:09:02 -0800 Subject: [PATCH] Fix tests after NPM change --- .../jetty/JettyFlightRoundTripTest.java | 38 ++++++++++--------- .../jetty/js/Example123Registration.java | 5 ++- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java b/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java index bf0bd109d61..7278b18ee3f 100644 --- a/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java +++ b/server/jetty/src/test/java/io/deephaven/server/jetty/JettyFlightRoundTripTest.java @@ -61,7 +61,7 @@ public void jsPlugins() throws Exception { // Note: JettyFlightRoundTripTest is not the most minimal / appropriate bootstrapping for this test, but it is // the most convenient since it has all of the necessary prerequisites new Example123Registration().registerInto(component.registration()); - testJsPluginExamples(true, true); + testJsPluginExamples(false, true, true); } @Test @@ -71,7 +71,7 @@ public void jsPluginsFromManifest() throws Exception { final Path manifestRoot = Path.of(Sentinel.class.getResource("examples").toURI()); new JsPluginsManifestRegistration(manifestRoot) .registerInto(component.registration()); - testJsPluginExamples(false, true); + testJsPluginExamples(false, false, true); } @Test @@ -85,10 +85,11 @@ public void jsPluginsFromNpmPackages() throws Exception { .registerInto(component.registration()); new JsPluginsNpmPackageRegistration(example2Root) .registerInto(component.registration()); - testJsPluginExamples(false, false); + testJsPluginExamples(true, true, false); } - private void testJsPluginExamples(boolean example2IsLimited, boolean hasExample3) throws Exception { + private void testJsPluginExamples(boolean example1IsLimited, boolean example2IsLimited, boolean hasExample3) + throws Exception { final HttpClient client = new HttpClient(); client.start(); try { @@ -97,7 +98,7 @@ private void testJsPluginExamples(boolean example2IsLimited, boolean hasExample3 } else { manifestTest12(client); } - example1Tests(client); + example1Tests(client, example1IsLimited); example2Tests(client, example2IsLimited); if (hasExample3) { example3Tests(client); @@ -119,10 +120,16 @@ private void manifestTest123(HttpClient client) throws InterruptedException, Tim "{\"plugins\":[{\"name\":\"@deephaven_test/example1\",\"version\":\"0.1.0\",\"main\":\"dist/index.js\"},{\"name\":\"@deephaven_test/example2\",\"version\":\"0.2.0\",\"main\":\"dist/index.js\"},{\"name\":\"@deephaven_test/example3\",\"version\":\"0.3.0\",\"main\":\"index.js\"}]}"); } - private void example1Tests(HttpClient client) throws InterruptedException, TimeoutException, ExecutionException { - assertOk(get(client, "js-plugins/@deephaven_test/example1/package.json"), - "application/json", - "{\"name\":\"@deephaven_test/example1\",\"version\":\"0.1.0\",\"main\":\"dist/index.js\",\"files\":[\"dist\"]}"); + private void example1Tests(HttpClient client, boolean isLimited) + throws InterruptedException, TimeoutException, ExecutionException { + if (isLimited) { + assertThat(get(client, "js-plugins/@deephaven_test/example1/package.json").getStatus()) + .isEqualTo(HttpStatus.NOT_FOUND_404); + } else { + assertOk(get(client, "js-plugins/@deephaven_test/example1/package.json"), + "application/json", + "{\"name\":\"@deephaven_test/example1\",\"version\":\"0.1.0\",\"main\":\"dist/index.js\",\"files\":[\"dist\"]}"); + } assertOk( get(client, "js-plugins/@deephaven_test/example1/dist/index.js"), @@ -151,15 +158,10 @@ private void example2Tests(HttpClient client, boolean isLimited) "text/javascript", "// example2/dist/index.js"); - if (isLimited) { - assertThat(get(client, "js-plugins/@deephaven_test/example2/dist/index2.js").getStatus()) - .isEqualTo(HttpStatus.NOT_FOUND_404); - } else { - assertOk( - get(client, "js-plugins/@deephaven_test/example2/dist/index2.js"), - "text/javascript", - "// example2/dist/index2.js"); - } + assertOk( + get(client, "js-plugins/@deephaven_test/example2/dist/index2.js"), + "text/javascript", + "// example2/dist/index2.js"); } private void example3Tests(HttpClient client) throws InterruptedException, TimeoutException, ExecutionException { diff --git a/server/jetty/src/test/java/io/deephaven/server/jetty/js/Example123Registration.java b/server/jetty/src/test/java/io/deephaven/server/jetty/js/Example123Registration.java index 8574d22442a..9fd0e7300fb 100644 --- a/server/jetty/src/test/java/io/deephaven/server/jetty/js/Example123Registration.java +++ b/server/jetty/src/test/java/io/deephaven/server/jetty/js/Example123Registration.java @@ -44,13 +44,14 @@ private static JsPlugin example1() throws URISyntaxException { private static JsPlugin example2() throws URISyntaxException { final Path resourcePath = Path.of(Sentinel.class.getResource("examples/@deephaven_test/example2").toURI()); - final Path main = resourcePath.relativize(resourcePath.resolve("dist/index.js")); + final Path dist = resourcePath.relativize(resourcePath.resolve("dist")); + final Path main = dist.resolve("index.js"); return JsPlugin.builder() .name("@deephaven_test/example2") .version("0.2.0") .main(main) .path(resourcePath) - .paths(Paths.ofPrefixes(main)) + .paths(Paths.ofPrefixes(dist)) .build(); }