forked from Archives/Athou_commafeed
use quarkus-playwright to simplify tests
This commit is contained in:
@@ -503,6 +503,12 @@
|
|||||||
<artifactId>quarkus-junit5-mockito</artifactId>
|
<artifactId>quarkus-junit5-mockito</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkiverse.playwright</groupId>
|
||||||
|
<artifactId>quarkus-playwright</artifactId>
|
||||||
|
<version>2.1.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mock-server</groupId>
|
<groupId>org.mock-server</groupId>
|
||||||
<artifactId>mockserver-junit-jupiter</artifactId>
|
<artifactId>mockserver-junit-jupiter</artifactId>
|
||||||
@@ -519,12 +525,6 @@
|
|||||||
<artifactId>awaitility</artifactId>
|
<artifactId>awaitility</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.microsoft.playwright</groupId>
|
|
||||||
<artifactId>playwright</artifactId>
|
|
||||||
<version>1.52.0</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.reflections</groupId>
|
<groupId>org.reflections</groupId>
|
||||||
<artifactId>reflections</artifactId>
|
<artifactId>reflections</artifactId>
|
||||||
|
|||||||
@@ -1,38 +1,33 @@
|
|||||||
package com.commafeed.e2e;
|
package com.commafeed.e2e;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import com.microsoft.playwright.Browser;
|
import com.microsoft.playwright.BrowserContext;
|
||||||
import com.microsoft.playwright.Locator;
|
import com.microsoft.playwright.Locator;
|
||||||
import com.microsoft.playwright.Page;
|
import com.microsoft.playwright.Page;
|
||||||
import com.microsoft.playwright.Playwright;
|
|
||||||
import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
||||||
import com.microsoft.playwright.options.AriaRole;
|
import com.microsoft.playwright.options.AriaRole;
|
||||||
|
|
||||||
|
import io.quarkiverse.playwright.InjectPlaywright;
|
||||||
|
import io.quarkiverse.playwright.WithPlaywright;
|
||||||
import io.quarkus.test.junit.QuarkusTest;
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
|
|
||||||
@QuarkusTest
|
@QuarkusTest
|
||||||
|
@WithPlaywright
|
||||||
class AuthentificationIT {
|
class AuthentificationIT {
|
||||||
|
|
||||||
private final Playwright playwright = Playwright.create();
|
@InjectPlaywright
|
||||||
private final Browser browser = playwright.chromium().launch();
|
private BrowserContext context;
|
||||||
|
|
||||||
private Page page;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void init() {
|
|
||||||
page = browser.newContext().newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
playwright.close();
|
context.clearCookies();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loginFail() {
|
void loginFail() {
|
||||||
|
Page page = context.newPage();
|
||||||
page.navigate(getLoginPageUrl());
|
page.navigate(getLoginPageUrl());
|
||||||
page.getByPlaceholder("User Name or E-mail").fill("admin");
|
page.getByPlaceholder("User Name or E-mail").fill("admin");
|
||||||
page.getByPlaceholder("Password").fill("wrong_password");
|
page.getByPlaceholder("Password").fill("wrong_password");
|
||||||
@@ -42,6 +37,7 @@ class AuthentificationIT {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loginSuccess() {
|
void loginSuccess() {
|
||||||
|
Page page = context.newPage();
|
||||||
page.navigate(getLoginPageUrl());
|
page.navigate(getLoginPageUrl());
|
||||||
PlaywrightTestUtils.login(page);
|
PlaywrightTestUtils.login(page);
|
||||||
PlaywrightAssertions.assertThat(page).hasURL("http://localhost:8085/#/app/category/all");
|
PlaywrightAssertions.assertThat(page).hasURL("http://localhost:8085/#/app/category/all");
|
||||||
@@ -49,6 +45,7 @@ class AuthentificationIT {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void registerFailPasswordTooSimple() {
|
void registerFailPasswordTooSimple() {
|
||||||
|
Page page = context.newPage();
|
||||||
page.navigate(getLoginPageUrl());
|
page.navigate(getLoginPageUrl());
|
||||||
page.getByText("Sign up!").click();
|
page.getByText("Sign up!").click();
|
||||||
page.getByPlaceholder("User Name").fill("user");
|
page.getByPlaceholder("User Name").fill("user");
|
||||||
@@ -65,6 +62,7 @@ class AuthentificationIT {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void registerSuccess() {
|
void registerSuccess() {
|
||||||
|
Page page = context.newPage();
|
||||||
page.navigate(getLoginPageUrl());
|
page.navigate(getLoginPageUrl());
|
||||||
page.getByText("Sign up!").click();
|
page.getByText("Sign up!").click();
|
||||||
page.getByPlaceholder("User Name").fill("user");
|
page.getByPlaceholder("User Name").fill("user");
|
||||||
|
|||||||
@@ -1,36 +1,25 @@
|
|||||||
package com.commafeed.e2e;
|
package com.commafeed.e2e;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import com.microsoft.playwright.Browser;
|
import com.microsoft.playwright.BrowserContext;
|
||||||
import com.microsoft.playwright.Page;
|
import com.microsoft.playwright.Page;
|
||||||
import com.microsoft.playwright.Playwright;
|
|
||||||
import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
||||||
|
|
||||||
|
import io.quarkiverse.playwright.InjectPlaywright;
|
||||||
|
import io.quarkiverse.playwright.WithPlaywright;
|
||||||
import io.quarkus.test.junit.QuarkusTest;
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
|
|
||||||
@QuarkusTest
|
@QuarkusTest
|
||||||
|
@WithPlaywright
|
||||||
class DocumentationIT {
|
class DocumentationIT {
|
||||||
|
|
||||||
private final Playwright playwright = Playwright.create();
|
@InjectPlaywright
|
||||||
private final Browser browser = playwright.chromium().launch();
|
private BrowserContext context;
|
||||||
|
|
||||||
private Page page;
|
|
||||||
|
|
||||||
@BeforeEach
|
|
||||||
void init() {
|
|
||||||
page = browser.newContext().newPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterEach
|
|
||||||
void cleanup() {
|
|
||||||
playwright.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void documentationAvailable() {
|
void documentationAvailable() {
|
||||||
|
Page page = context.newPage();
|
||||||
page.navigate("http://localhost:8085/#/api");
|
page.navigate("http://localhost:8085/#/api");
|
||||||
PlaywrightAssertions.assertThat(page.getByText("Download OpenAPI specification:")).isVisible();
|
PlaywrightAssertions.assertThat(page.getByText("Download OpenAPI specification:")).isVisible();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,28 +17,28 @@ import org.mockserver.model.HttpRequest;
|
|||||||
import org.mockserver.model.HttpResponse;
|
import org.mockserver.model.HttpResponse;
|
||||||
|
|
||||||
import com.commafeed.frontend.model.Entries;
|
import com.commafeed.frontend.model.Entries;
|
||||||
import com.microsoft.playwright.Browser;
|
import com.microsoft.playwright.BrowserContext;
|
||||||
import com.microsoft.playwright.Locator;
|
import com.microsoft.playwright.Locator;
|
||||||
import com.microsoft.playwright.Page;
|
import com.microsoft.playwright.Page;
|
||||||
import com.microsoft.playwright.Playwright;
|
|
||||||
import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
||||||
import com.microsoft.playwright.options.AriaRole;
|
import com.microsoft.playwright.options.AriaRole;
|
||||||
|
|
||||||
|
import io.quarkiverse.playwright.InjectPlaywright;
|
||||||
|
import io.quarkiverse.playwright.WithPlaywright;
|
||||||
import io.quarkus.test.junit.QuarkusTest;
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
import io.restassured.RestAssured;
|
import io.restassured.RestAssured;
|
||||||
|
|
||||||
@QuarkusTest
|
@QuarkusTest
|
||||||
|
@WithPlaywright
|
||||||
class ReadingIT {
|
class ReadingIT {
|
||||||
|
|
||||||
private final Playwright playwright = Playwright.create();
|
@InjectPlaywright
|
||||||
private final Browser browser = playwright.chromium().launch();
|
private BrowserContext context;
|
||||||
|
|
||||||
private Page page;
|
|
||||||
private MockServerClient mockServerClient;
|
private MockServerClient mockServerClient;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void init() throws IOException {
|
void init() throws IOException {
|
||||||
this.page = browser.newContext().newPage();
|
|
||||||
this.mockServerClient = ClientAndServer.startClientAndServer(0);
|
this.mockServerClient = ClientAndServer.startClientAndServer(0);
|
||||||
this.mockServerClient.when(HttpRequest.request().withMethod("GET"))
|
this.mockServerClient.when(HttpRequest.request().withMethod("GET"))
|
||||||
.respond(HttpResponse.response()
|
.respond(HttpResponse.response()
|
||||||
@@ -50,13 +50,13 @@ class ReadingIT {
|
|||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
playwright.close();
|
|
||||||
|
|
||||||
RestAssured.reset();
|
RestAssured.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void scenario() {
|
void scenario() {
|
||||||
|
Page page = context.newPage();
|
||||||
|
|
||||||
// login
|
// login
|
||||||
page.navigate("http://localhost:8085");
|
page.navigate("http://localhost:8085");
|
||||||
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Log in")).click();
|
page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Log in")).click();
|
||||||
|
|||||||
Reference in New Issue
Block a user