fix(progress): reset koreader device when coming from grimmory (#2640)
This commit is contained in:
@@ -437,6 +437,25 @@ class KoreaderServiceTest {
|
||||
verify(progressRepo).save(progress);
|
||||
}
|
||||
|
||||
@Test
|
||||
void syncProgressToKoreader_usesGrimmoryDeviceInfo() {
|
||||
BookEntity book = bookWithPrimaryFile(11L, BookFileType.PDF);
|
||||
BookLoreUserEntity user = user(42L);
|
||||
UserBookProgressEntity progress = new UserBookProgressEntity();
|
||||
progress.setKoreaderDeviceId("EXAMPLE-ID");
|
||||
progress.setKoreaderDevice("EXAMPLE-DEVICE");
|
||||
when(koreaderUserRepo.findByBookLoreUserId(42L)).thenReturn(Optional.of(koreaderUser(true, true)));
|
||||
when(bookRepo.findById(11L)).thenReturn(Optional.of(book));
|
||||
when(userRepo.findById(42L)).thenReturn(Optional.of(user));
|
||||
when(progressRepo.findByUserIdAndBookId(42L, 11L)).thenReturn(Optional.of(progress));
|
||||
|
||||
service.syncProgressToKoreader(11L, 50f, 42L);
|
||||
|
||||
assertEquals("Grimmory", progress.getKoreaderDevice());
|
||||
assertEquals("Grimmory", progress.getKoreaderDeviceId());
|
||||
verify(progressRepo).save(progress);
|
||||
}
|
||||
|
||||
@Test
|
||||
void normalizeProgressPercent_handlesNullAndRanges() throws Exception {
|
||||
Method method = KoreaderService.class.getDeclaredMethod("normalizeProgressPercent", Float.class);
|
||||
|
||||
Reference in New Issue
Block a user