mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
tweak tests to be more resilient
This commit is contained in:
@@ -3,9 +3,10 @@ package com.commafeed.e2e;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
|
import org.awaitility.Awaitility;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -14,6 +15,7 @@ import org.mockserver.integration.ClientAndServer;
|
|||||||
import org.mockserver.model.HttpRequest;
|
import org.mockserver.model.HttpRequest;
|
||||||
import org.mockserver.model.HttpResponse;
|
import org.mockserver.model.HttpResponse;
|
||||||
|
|
||||||
|
import com.commafeed.frontend.model.Entries;
|
||||||
import com.microsoft.playwright.Browser;
|
import com.microsoft.playwright.Browser;
|
||||||
import com.microsoft.playwright.Locator;
|
import com.microsoft.playwright.Locator;
|
||||||
import com.microsoft.playwright.Page;
|
import com.microsoft.playwright.Page;
|
||||||
@@ -22,6 +24,7 @@ import com.microsoft.playwright.assertions.PlaywrightAssertions;
|
|||||||
import com.microsoft.playwright.options.AriaRole;
|
import com.microsoft.playwright.options.AriaRole;
|
||||||
|
|
||||||
import io.quarkus.test.junit.QuarkusTest;
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
|
import io.restassured.RestAssured;
|
||||||
|
|
||||||
@QuarkusTest
|
@QuarkusTest
|
||||||
class ReadingIT {
|
class ReadingIT {
|
||||||
@@ -40,11 +43,15 @@ class ReadingIT {
|
|||||||
.respond(HttpResponse.response()
|
.respond(HttpResponse.response()
|
||||||
.withBody(IOUtils.toString(getClass().getResource("/feed/rss.xml"), StandardCharsets.UTF_8))
|
.withBody(IOUtils.toString(getClass().getResource("/feed/rss.xml"), StandardCharsets.UTF_8))
|
||||||
.withDelay(TimeUnit.MILLISECONDS, 100));
|
.withDelay(TimeUnit.MILLISECONDS, 100));
|
||||||
|
|
||||||
|
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
playwright.close();
|
playwright.close();
|
||||||
|
|
||||||
|
RestAssured.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -66,22 +73,32 @@ class ReadingIT {
|
|||||||
main.getByRole(AriaRole.BUTTON, new Locator.GetByRoleOptions().setName("Next")).click();
|
main.getByRole(AriaRole.BUTTON, new Locator.GetByRoleOptions().setName("Next")).click();
|
||||||
main.getByRole(AriaRole.BUTTON, new Locator.GetByRoleOptions().setName("Subscribe").setExact(true)).click();
|
main.getByRole(AriaRole.BUTTON, new Locator.GetByRoleOptions().setName("Subscribe").setExact(true)).click();
|
||||||
|
|
||||||
// click on subscription
|
// click on subscription, "2" is actually the unread count
|
||||||
sidebar.getByText(Pattern.compile("CommaFeed test feed\\d+")).click();
|
sidebar.getByText("CommaFeed test feed2").click();
|
||||||
|
|
||||||
// we have two unread entries
|
// we have two unread entries
|
||||||
PlaywrightAssertions.assertThat(main.locator(".mantine-Paper-root")).hasCount(2);
|
PlaywrightAssertions.assertThat(main.getByRole(AriaRole.ARTICLE)).hasCount(2);
|
||||||
|
|
||||||
// click on first entry
|
// click on first entry
|
||||||
main.getByText("Item 1").click();
|
main.getByText("Item 1").click();
|
||||||
PlaywrightAssertions.assertThat(main.getByText("Item 1 description")).hasCount(1);
|
PlaywrightAssertions.assertThat(main.getByText("Item 1 description")).hasCount(1);
|
||||||
PlaywrightAssertions.assertThat(main.getByText("Item 2 description")).hasCount(0);
|
PlaywrightAssertions.assertThat(main.getByText("Item 2 description")).hasCount(0);
|
||||||
|
|
||||||
// click on subscription
|
// wait for the entry to be marked as read since the UI is updated immediately while the entry is marked as read in the background
|
||||||
sidebar.getByText(Pattern.compile("CommaFeed test feed\\d+")).click();
|
Awaitility.await()
|
||||||
|
.atMost(15, TimeUnit.SECONDS)
|
||||||
|
.until(() -> RestAssured.given()
|
||||||
|
.get("rest/category/entries?id=all&readType=unread")
|
||||||
|
.then()
|
||||||
|
.statusCode(HttpStatus.SC_OK)
|
||||||
|
.extract()
|
||||||
|
.as(Entries.class), e -> e.getEntries().size() == 1);
|
||||||
|
|
||||||
|
// click on subscription, "1" is actually the unread count
|
||||||
|
sidebar.getByText("CommaFeed test feed1").click();
|
||||||
|
|
||||||
// only one unread entry now
|
// only one unread entry now
|
||||||
PlaywrightAssertions.assertThat(main.locator(".mantine-Paper-root")).hasCount(1);
|
PlaywrightAssertions.assertThat(main.getByRole(AriaRole.ARTICLE)).hasCount(1);
|
||||||
|
|
||||||
// click on second entry
|
// click on second entry
|
||||||
main.getByText("Item 2").click();
|
main.getByText("Item 2").click();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import org.apache.hc.core5.http.HttpStatus;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -41,6 +42,11 @@ class WebSocketIT extends BaseIT {
|
|||||||
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void tearDown() {
|
||||||
|
RestAssured.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void sessionClosedIfNotLoggedIn() throws DeploymentException, IOException {
|
void sessionClosedIfNotLoggedIn() throws DeploymentException, IOException {
|
||||||
AtomicBoolean connected = new AtomicBoolean();
|
AtomicBoolean connected = new AtomicBoolean();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.commafeed.integration.rest;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.hc.core5.http.HttpStatus;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
@@ -25,6 +26,11 @@ class AdminIT extends BaseIT {
|
|||||||
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void cleanup() {
|
||||||
|
RestAssured.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class Users {
|
class Users {
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import java.util.Objects;
|
|||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.hc.core5.http.HttpStatus;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
import org.awaitility.Awaitility;
|
import org.awaitility.Awaitility;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
@@ -38,6 +39,11 @@ class FeedIT extends BaseIT {
|
|||||||
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void cleanup() {
|
||||||
|
RestAssured.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class Fetch {
|
class Fetch {
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.commafeed.integration.rest;
|
package com.commafeed.integration.rest;
|
||||||
|
|
||||||
import org.apache.hc.core5.http.HttpStatus;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -37,6 +38,11 @@ class FeverIT extends BaseIT {
|
|||||||
this.userId = user.getId();
|
this.userId = user.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void cleanup() {
|
||||||
|
RestAssured.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void invalidApiKey() {
|
void invalidApiKey() {
|
||||||
FeverResponse response = fetch("feeds", "invalid-key");
|
FeverResponse response = fetch("feeds", "invalid-key");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.commafeed.integration.rest;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -29,6 +30,11 @@ class UserIT extends BaseIT {
|
|||||||
mailbox.clear();
|
mailbox.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void cleanup() {
|
||||||
|
RestAssured.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void resetPassword() {
|
void resetPassword() {
|
||||||
PasswordResetRequest req = new PasswordResetRequest();
|
PasswordResetRequest req = new PasswordResetRequest();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.commafeed.integration.servlet;
|
|||||||
|
|
||||||
import org.apache.hc.core5.http.HttpStatus;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
import org.hamcrest.CoreMatchers;
|
import org.hamcrest.CoreMatchers;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@@ -20,6 +21,11 @@ class CustomCodeIT extends BaseIT {
|
|||||||
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void cleanup() {
|
||||||
|
RestAssured.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test() {
|
void test() {
|
||||||
// get settings
|
// get settings
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.commafeed.integration.servlet;
|
package com.commafeed.integration.servlet;
|
||||||
|
|
||||||
import org.apache.hc.core5.http.HttpStatus;
|
import org.apache.hc.core5.http.HttpStatus;
|
||||||
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@@ -18,6 +19,11 @@ class NextUnreadIT extends BaseIT {
|
|||||||
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
RestAssured.authentication = RestAssured.preemptive().basic("admin", "admin");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AfterEach
|
||||||
|
void cleanup() {
|
||||||
|
RestAssured.reset();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void test() {
|
void test() {
|
||||||
subscribeAndWaitForEntries(getFeedUrl());
|
subscribeAndWaitForEntries(getFeedUrl());
|
||||||
|
|||||||
Reference in New Issue
Block a user