mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 18:01:42 +00:00
fix: normalize book browse cursor values
This commit is contained in:
parent
ed3a2c64b3
commit
6788943087
2 changed files with 74 additions and 13 deletions
|
|
@ -5,6 +5,7 @@ const sinon = require('sinon')
|
|||
const Database = require('../../../server/Database')
|
||||
const LibraryController = require('../../../server/controllers/LibraryController')
|
||||
const libraryFilters = require('../../../server/utils/queries/libraryFilters')
|
||||
const { decodeBrowseCursor } = require('../../../server/utils/queries/libraryBrowseCursor')
|
||||
const { getLibraryBrowseStrategy } = require('../../../server/utils/queries/libraryBrowseStrategy')
|
||||
const libraryItemsBookFilters = require('../../../server/utils/queries/libraryItemsBookFilters')
|
||||
const libraryItemsPodcastFilters = require('../../../server/utils/queries/libraryItemsPodcastFilters')
|
||||
|
|
@ -290,6 +291,37 @@ describe('LibraryController large-library browse contract', () => {
|
|||
expect(findAndCountAllStub.called).to.equal(false)
|
||||
})
|
||||
|
||||
it('encodes case-insensitive title cursor values to match the executed browse order', async () => {
|
||||
global.ServerSettings = { sortingIgnorePrefix: true }
|
||||
|
||||
sinon.stub(Database.bookModel, 'count').resolves(123)
|
||||
sinon.stub(Database.bookModel, 'findAndCountAll').resolves({ rows: [], count: 123 })
|
||||
sinon.stub(Database.bookModel, 'findAll').resolves([
|
||||
{ id: 'book-1', title: 'Alpha', libraryItem: { id: 'item-1', titleIgnorePrefix: 'Alpha', dataValues: { titleIgnorePrefix: 'Alpha' } } },
|
||||
{ id: 'book-2', title: 'aLPHa', libraryItem: { id: 'item-2', titleIgnorePrefix: 'aLPHa', dataValues: { titleIgnorePrefix: 'aLPHa' } } },
|
||||
{ id: 'book-3', title: 'Beta', libraryItem: { id: 'item-3', titleIgnorePrefix: 'Beta', dataValues: { titleIgnorePrefix: 'Beta' } } }
|
||||
])
|
||||
|
||||
const result = await libraryItemsBookFilters.getFilteredLibraryItems(
|
||||
'lib_1',
|
||||
{ id: 'user_1', canAccessExplicitContent: true, accessAllTags: true },
|
||||
null,
|
||||
null,
|
||||
'media.metadata.title',
|
||||
false,
|
||||
false,
|
||||
[],
|
||||
2,
|
||||
0,
|
||||
false,
|
||||
{ pageMode: 'endless' }
|
||||
)
|
||||
|
||||
const decodedCursor = decodeBrowseCursor(result.nextCursor)
|
||||
|
||||
expect(decodedCursor.values).to.deep.equal(['alpha', 'item-2'])
|
||||
})
|
||||
|
||||
it('defaults omitted sort to deterministic title ordering for endless browse requests', async () => {
|
||||
global.ServerSettings = { sortingIgnorePrefix: true }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue