diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index fe58c7de..27065e46 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -346,15 +346,14 @@ public class AllWebUITest { } ---- -The library also brings a very elegant way to do e2e testing using https://github.com/microsoft/playwright-java[Playright]: +The library also brings a very elegant way to do e2e testing using https://docs.quarkiverse.io/quarkus-playwright/dev/[Quarkus Playright]: [source,java] ---- import com.microsoft.playwright.BrowserContext; import com.microsoft.playwright.Page; import com.microsoft.playwright.Response; -import io.quarkiverse.quinoa.testing.QuarkusPlaywrightManager; -import io.quarkiverse.quinoa.testing.QuinoaTestProfiles; -import io.quarkus.test.common.QuarkusTestResource; +import io.quarkiverse.playwright.WithPlaywright; +import io.quarkiverse.playwright.InjectPlaywright; import io.quarkus.test.common.http.TestHTTPResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @@ -365,9 +364,9 @@ import java.net.URL; @QuarkusTest @TestProfile(QuinoaTestProfiles.Enable.class) -@QuarkusTestResource(QuarkusPlaywrightManager.class) +@WithPlaywright public class MyWebUITest { - @QuarkusPlaywrightManager.InjectPlaywright + @InjectPlaywright BrowserContext context; @TestHTTPResource("/") diff --git a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaRootPathTest.java b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaRootPathTest.java index 4da0ab2a..3190c3e4 100644 --- a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaRootPathTest.java +++ b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaRootPathTest.java @@ -9,18 +9,18 @@ import com.microsoft.playwright.Page; import com.microsoft.playwright.Response; -import io.quarkiverse.quinoa.testing.QuarkusPlaywrightManager; -import io.quarkus.test.common.QuarkusTestResource; +import io.quarkiverse.playwright.InjectPlaywright; +import io.quarkiverse.playwright.WithPlaywright; import io.quarkus.test.common.http.TestHTTPResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @QuarkusTest @TestProfile(TestProfiles.RootPathTests.class) -@QuarkusTestResource(QuarkusPlaywrightManager.class) +@WithPlaywright public class QuinoaRootPathTest { - @QuarkusPlaywrightManager.InjectPlaywright + @InjectPlaywright BrowserContext context; @TestHTTPResource("/") diff --git a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIAngularTest.java b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIAngularTest.java index ffcd2b6d..889af19e 100644 --- a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIAngularTest.java +++ b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIAngularTest.java @@ -5,6 +5,7 @@ import java.net.URL; +import io.quarkiverse.playwright.WithPlaywright; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -13,18 +14,17 @@ import com.microsoft.playwright.Page; import com.microsoft.playwright.Response; -import io.quarkiverse.quinoa.testing.QuarkusPlaywrightManager; -import io.quarkus.test.common.QuarkusTestResource; +import io.quarkiverse.playwright.InjectPlaywright; import io.quarkus.test.common.http.TestHTTPResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @QuarkusTest @TestProfile(TestProfiles.AngularTests.class) -@QuarkusTestResource(QuarkusPlaywrightManager.class) +@WithPlaywright public class QuinoaUIAngularTest { - @QuarkusPlaywrightManager.InjectPlaywright + @InjectPlaywright BrowserContext context; @TestHTTPResource("/") diff --git a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUILitTest.java b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUILitTest.java index dfd59a82..07d2740a 100644 --- a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUILitTest.java +++ b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUILitTest.java @@ -2,6 +2,7 @@ import java.net.URL; +import io.quarkiverse.playwright.WithPlaywright; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -10,18 +11,17 @@ import com.microsoft.playwright.Page; import com.microsoft.playwright.Response; -import io.quarkiverse.quinoa.testing.QuarkusPlaywrightManager; -import io.quarkus.test.common.QuarkusTestResource; +import io.quarkiverse.playwright.InjectPlaywright; import io.quarkus.test.common.http.TestHTTPResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @QuarkusTest @TestProfile(TestProfiles.LitTests.class) -@QuarkusTestResource(QuarkusPlaywrightManager.class) +@WithPlaywright public class QuinoaUILitTest { - @QuarkusPlaywrightManager.InjectPlaywright + @InjectPlaywright BrowserContext context; @TestHTTPResource("/") diff --git a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIReactTest.java b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIReactTest.java index ec0d0a30..bb0e2230 100644 --- a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIReactTest.java +++ b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIReactTest.java @@ -13,8 +13,8 @@ import com.microsoft.playwright.Page; import com.microsoft.playwright.Response; -import io.quarkiverse.quinoa.testing.QuarkusPlaywrightManager; -import io.quarkus.test.common.QuarkusTestResource; +import io.quarkiverse.playwright.InjectPlaywright; +import io.quarkiverse.playwright.WithPlaywright; import io.quarkus.test.common.http.TestHTTPResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @@ -22,10 +22,10 @@ @QuarkusTest @TestProfile(TestProfiles.ReactTests.class) -@QuarkusTestResource(QuarkusPlaywrightManager.class) +@WithPlaywright public class QuinoaUIReactTest { - @QuarkusPlaywrightManager.InjectPlaywright + @InjectPlaywright BrowserContext context; @TestHTTPResource("/index.html") diff --git a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIVueTest.java b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIVueTest.java index 866fbedc..fe0c0084 100644 --- a/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIVueTest.java +++ b/integration-tests/src/test/java/io/quarkiverse/quinoa/it/QuinoaUIVueTest.java @@ -9,18 +9,18 @@ import com.microsoft.playwright.Page; import com.microsoft.playwright.Response; -import io.quarkiverse.quinoa.testing.QuarkusPlaywrightManager; -import io.quarkus.test.common.QuarkusTestResource; +import io.quarkiverse.playwright.InjectPlaywright; +import io.quarkiverse.playwright.WithPlaywright; import io.quarkus.test.common.http.TestHTTPResource; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.TestProfile; @QuarkusTest @TestProfile(TestProfiles.VueTests.class) -@QuarkusTestResource(QuarkusPlaywrightManager.class) +@WithPlaywright public class QuinoaUIVueTest { - @QuarkusPlaywrightManager.InjectPlaywright + @InjectPlaywright BrowserContext context; @TestHTTPResource("/") diff --git a/pom.xml b/pom.xml index 95e69027..2e51bb7c 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ UTF-8 UTF-8 3.3.0 - 1.37.0 + 0.0.1 3.24.2 1.14.0 diff --git a/testing/pom.xml b/testing/pom.xml index 9091e324..757ed135 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -10,14 +10,9 @@ Quarkus - Quinoa - Testing - com.microsoft.playwright - playwright - ${playright.version} - - - com.microsoft.playwright - driver-bundle - ${playright.version} + io.quarkiverse.playwright + quarkus-playwright + ${quarkus-playright.version} io.quarkus diff --git a/testing/src/main/java/io/quarkiverse/quinoa/testing/QuarkusPlaywrightManager.java b/testing/src/main/java/io/quarkiverse/quinoa/testing/QuarkusPlaywrightManager.java deleted file mode 100644 index 133376cf..00000000 --- a/testing/src/main/java/io/quarkiverse/quinoa/testing/QuarkusPlaywrightManager.java +++ /dev/null @@ -1,54 +0,0 @@ -package io.quarkiverse.quinoa.testing; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import com.microsoft.playwright.Browser; -import com.microsoft.playwright.BrowserContext; -import com.microsoft.playwright.BrowserType; -import com.microsoft.playwright.Playwright; - -import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; - -public class QuarkusPlaywrightManager implements QuarkusTestResourceLifecycleManager { - - private BrowserContext context; - private Playwright playwright; - - @Override - public Map start() { - playwright = com.microsoft.playwright.Playwright.create(); - Browser browser = playwright.chromium().launch( - new BrowserType.LaunchOptions() - .setArgs(List.of("--headless", "--disable-gpu", "--no-sandbox"))); - context = browser.newContext(); - return Collections.emptyMap(); - } - - @Override - public void stop() { - if (playwright != null) { - playwright.close(); - playwright = null; - } - } - - @Override - public void inject(TestInjector testInjector) { - testInjector.injectIntoFields(context, - new TestInjector.AnnotatedAndMatchesType(InjectPlaywright.class, BrowserContext.class)); - testInjector.injectIntoFields(playwright, - new TestInjector.AnnotatedAndMatchesType(InjectPlaywright.class, Playwright.class)); - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - public @interface InjectPlaywright { - } - -}