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