mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
remove the possibility to receive notifications when subscribing because that sends a lot of notifications, one for each entry in the feed
This commit is contained in:
@@ -46,8 +46,7 @@ class OPMLImporterTest {
|
||||
importer.importOpml(user, xml);
|
||||
|
||||
Mockito.verify(feedSubscriptionService)
|
||||
.subscribe(Mockito.eq(user), Mockito.anyString(), Mockito.anyString(), Mockito.any(FeedCategory.class), Mockito.anyInt(),
|
||||
Mockito.anyBoolean());
|
||||
.subscribe(Mockito.eq(user), Mockito.anyString(), Mockito.anyString(), Mockito.any(FeedCategory.class), Mockito.anyInt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -123,15 +123,10 @@ public abstract class BaseIT {
|
||||
}
|
||||
|
||||
protected Long subscribe(String feedUrl, String categoryId) {
|
||||
return subscribe(feedUrl, categoryId, false);
|
||||
}
|
||||
|
||||
protected Long subscribe(String feedUrl, String categoryId, boolean pushNotificationsEnabled) {
|
||||
SubscribeRequest subscribeRequest = new SubscribeRequest();
|
||||
subscribeRequest.setUrl(feedUrl);
|
||||
subscribeRequest.setTitle("my title for this feed");
|
||||
subscribeRequest.setCategoryId(categoryId);
|
||||
subscribeRequest.setPushNotificationsEnabled(pushNotificationsEnabled);
|
||||
return RestAssured.given()
|
||||
.body(subscribeRequest)
|
||||
.contentType(ContentType.JSON)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.commafeed.integration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.apache.hc.core5.http.HttpStatus;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -13,6 +15,8 @@ import org.mockserver.verify.VerificationTimes;
|
||||
import com.commafeed.TestConstants;
|
||||
import com.commafeed.backend.model.UserSettings.PushNotificationType;
|
||||
import com.commafeed.frontend.model.Settings;
|
||||
import com.commafeed.frontend.model.Subscription;
|
||||
import com.commafeed.frontend.model.request.FeedModificationRequest;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.RestAssured;
|
||||
@@ -33,7 +37,7 @@ class PushNotificationIT extends BaseIT {
|
||||
}
|
||||
|
||||
@Test
|
||||
void receivedPushNotifications() {
|
||||
void receivedPushNotifications() throws IOException {
|
||||
// mock ntfy server
|
||||
HttpRequest ntfyPost = HttpRequest.request().withMethod("POST").withPath("/ntfy/integration-test");
|
||||
getMockServerClient().when(ntfyPost).respond(HttpResponse.response().withStatusCode(200));
|
||||
@@ -45,8 +49,22 @@ class PushNotificationIT extends BaseIT {
|
||||
settings.getPushNotificationSettings().setTopic("integration-test");
|
||||
RestAssured.given().body(settings).contentType(ContentType.JSON).post("rest/user/settings").then().statusCode(200);
|
||||
|
||||
// subscribe with push notifications enabled
|
||||
subscribe(getFeedUrl(), null, true);
|
||||
// subscribe
|
||||
Long subscriptionId = subscribeAndWaitForEntries(getFeedUrl());
|
||||
Subscription subscription = getSubscription(subscriptionId);
|
||||
|
||||
// enable push notifications
|
||||
FeedModificationRequest req = new FeedModificationRequest();
|
||||
req.setId(subscriptionId);
|
||||
req.setName(subscription.getName());
|
||||
req.setCategoryId(subscription.getCategoryId());
|
||||
req.setPosition(1);
|
||||
req.setPushNotificationsEnabled(true);
|
||||
RestAssured.given().body(req).contentType(ContentType.JSON).post("rest/feed/modify").then().statusCode(HttpStatus.SC_OK);
|
||||
|
||||
// receive two additional entries, those will trigger two push notifications
|
||||
feedNowReturnsMoreEntries();
|
||||
forceRefreshAllFeeds();
|
||||
|
||||
// await push notification for the two entries in the feed
|
||||
Awaitility.await()
|
||||
|
||||
Reference in New Issue
Block a user