From 6b805c47528d34695a52aeece7162c4cc33ab856 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 12 Oct 2022 10:02:36 +0300 Subject: API: add `showReplies` parameter to `/api/thread` endpoint --- src/test/java/com/juick/server/tests/ServerTests.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/test') diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index 87617cea..da777a92 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -213,6 +213,7 @@ import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.DigestUtils; import org.springframework.util.FileSystemUtils; import org.springframework.util.LinkedMultiValueMap; @@ -1025,6 +1026,7 @@ public class ServerTests { } @Test + @Transactional public void recommendTests() throws Exception { int mid = messagesService.createMessage(ugnich.getUid(), "to be liked", null, Set.of()); @@ -1037,6 +1039,13 @@ public class ServerTests { .andExpect(jsonPath("$[0].recommendations.length()", is(1))) .andExpect(jsonPath("$[0].recommendations[0].uname", is(freefdName))); mockMvc.perform(post("/api/like?mid=" + freefdMid + "&hash=" + freefdHash)).andExpect(status().isForbidden()); + messagesService.createReply(mid, 0, freefd, "reply", null); + mockMvc.perform(get("/api/thread?mid=" + mid + "&hash=" + freefdHash)).andExpect(status().isOk()) + .andExpect(jsonPath("$.length()", is(2))) + .andExpect(jsonPath("$[0].replies", is(1))); + mockMvc.perform(get("/api/thread?mid=" + mid + "&hash=" + freefdHash + "&showReplies=false")).andExpect(status().isOk()) + .andExpect(jsonPath("$.length()", is(1))) + .andExpect(jsonPath("$[0].replies", is(1))); } @Test -- cgit v1.2.3