diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt index 6818a780..1dc72113 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt @@ -29,6 +29,7 @@ import org.springframework.boot.test.context.SpringBootTest import org.springframework.data.domain.PageRequest import org.springframework.data.domain.Sort import org.springframework.test.context.junit.jupiter.SpringExtension +import java.net.URL @ExtendWith(SpringExtension::class) @SpringBootTest @@ -403,6 +404,30 @@ class BookDtoDaoTest( assertThat(found.map { it.name }).containsExactly("X-Men", "Another X-Men adventure") } + @Test + fun `given books when searching by single letter then results are ordered by rank`() { + // given + seriesLifecycle.addBooks( + series, + listOf( + makeBook("J", seriesId = series.id, libraryId = library.id), + makeBook("Adventures of J. J.", seriesId = series.id, libraryId = library.id), + makeBook("Jackal", seriesId = series.id, libraryId = library.id), + ) + ) + + // when + val found = bookDtoDao.findAll( + BookSearchWithReadProgress(searchTerm = "j"), + user.id, + UnpagedSorted(Sort.by("relevance")), + ).content + + // then + assertThat(found).hasSize(2) + assertThat(found.map { it.name }).containsExactly("J", "Adventures of J. J.") + } + @Test fun `when searching by unknown field then empty result are returned and no exception is thrown`() { assertThatCode { @@ -417,4 +442,25 @@ class BookDtoDaoTest( assertThat(found).hasSize(0) }.doesNotThrowAnyException() } + + @Test + fun `given books in CJK when searching by CJK term then results are ordered by rank`() { + // given + seriesLifecycle.addBooks( + series, + listOf( + makeBook("[不道德公會][河添太一 ][東立]Vol.04-搬运", seriesId = series.id, libraryId = library.id, url = URL("file:/file.cbz")), + ) + ) + + // when + val found = bookDtoDao.findAll( + BookSearchWithReadProgress(searchTerm = "不道德"), + user.id, + UnpagedSorted(Sort.by("relevance")), + ).content + + // then + assertThat(found).hasSize(1) + } }