refactor(app): 观看历史统一分页契约并移除 limit
This commit is contained in:
1 parent
7b694938c6
commit
c5468a669b
5 files changed
+19
-34
No files matched your search
+9
-7
@@ -138,17 +138,19 @@ class AppLibraryPagingContractTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void should_return_legacy_list_when_recent_limit_is_present() throws Exception {
|
||||
given(progressService.recent(USER_ID, 5))
|
||||
.willReturn(List.of(progress(12L, 88L, 6, "剧名一", 68)));
|
||||
void should_ignore_removed_limit_and_still_return_page_result() throws Exception {
|
||||
// limit 已从契约移除:即使客户端误传,也应走分页并返回 PageResult。
|
||||
given(progressService.recentPage(USER_ID, 1, 20))
|
||||
.willReturn(new PageResult<>(3L, List.of(progress(12L, 88L, 6, "剧名一", 68))));
|
||||
|
||||
watchMvc.perform(get("/app/watch/recent").param("limit", "5"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data").isArray())
|
||||
.andExpect(jsonPath("$.data[0].dramaTitle").value("剧名一"))
|
||||
.andExpect(jsonPath("$.data[0].episodeNumber").value(6));
|
||||
.andExpect(jsonPath("$.data.total").value("3"))
|
||||
.andExpect(jsonPath("$.data.list").isArray())
|
||||
.andExpect(jsonPath("$.data.list.length()").value(1))
|
||||
.andExpect(jsonPath("$.data.list[0].dramaTitle").value("剧名一"));
|
||||
|
||||
verify(progressService).recent(USER_ID, 5);
|
||||
verify(progressService).recentPage(USER_ID, 1, 20);
|
||||
}
|
||||
|
||||
private Drama drama(Long id, String title) {
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ class WatchProgressServiceTest {
|
||||
assertThat(pageCaptor.getValue().getSize()).isEqualTo(20);
|
||||
assertThat(wrapperCaptor.getValue().getSqlSegment())
|
||||
.contains("updated_at DESC")
|
||||
.contains("drama_id DESC");
|
||||
.contains("id DESC");
|
||||
verify(dramaService, times(1)).listByIds(List.of(12L, 13L));
|
||||
verify(episodeService, times(1)).listByIds(List.of(88L, 99L));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user