mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-07 09:51:37 +00:00
fix: default browse queries to title sort
This commit is contained in:
parent
2d13ec3f8c
commit
ed3a2c64b3
2 changed files with 35 additions and 0 deletions
|
|
@ -504,6 +504,7 @@ module.exports = {
|
|||
if (filterGroup === 'series' && collapseseries) {
|
||||
collapseseries = false
|
||||
}
|
||||
sortBy = sortBy || 'media.metadata.title'
|
||||
if (filterGroup !== 'series' && sortBy === 'sequence') {
|
||||
sortBy = 'media.metadata.title'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,6 +290,40 @@ describe('LibraryController large-library browse contract', () => {
|
|||
expect(findAndCountAllStub.called).to.equal(false)
|
||||
})
|
||||
|
||||
it('defaults omitted sort to deterministic title ordering for endless browse requests', async () => {
|
||||
global.ServerSettings = { sortingIgnorePrefix: true }
|
||||
|
||||
const countStub = sinon.stub(Database.bookModel, 'count').resolves(10)
|
||||
const findAndCountAllStub = sinon.stub(Database.bookModel, 'findAndCountAll').resolves({ rows: [], count: 10 })
|
||||
const findAllStub = sinon.stub(Database.bookModel, 'findAll').resolves([
|
||||
{ id: 'book-1', title: 'Alpha', libraryItem: { id: 'item-1', titleIgnorePrefix: 'Alpha', dataValues: { titleIgnorePrefix: 'Alpha' } } }
|
||||
])
|
||||
|
||||
const result = await libraryItemsBookFilters.getFilteredLibraryItems(
|
||||
'lib_1',
|
||||
{ id: 'user_1', canAccessExplicitContent: true, accessAllTags: true },
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
[],
|
||||
20,
|
||||
0,
|
||||
false,
|
||||
{ pageMode: 'endless' }
|
||||
)
|
||||
|
||||
expect(result.paginationMode).to.equal('keyset')
|
||||
expect(findAllStub.calledOnce).to.equal(true)
|
||||
expect(findAndCountAllStub.called).to.equal(false)
|
||||
expect(countStub.calledOnce).to.equal(true)
|
||||
expect(findAllStub.firstCall.args[0].order).to.have.length(2)
|
||||
expect(findAllStub.firstCall.args[0].order[0][0].val || findAllStub.firstCall.args[0].order[0][0]).to.include('titleIgnorePrefix')
|
||||
expect(findAllStub.firstCall.args[0].order[1][0].val || findAllStub.firstCall.args[0].order[1][0]).to.include('libraryItem')
|
||||
expect(findAllStub.firstCall.args[0].order[1][0].val || findAllStub.firstCall.args[0].order[1][0]).to.include('id')
|
||||
})
|
||||
|
||||
it('uses offset fallback for progress browse requests with null-valued sort fields', async () => {
|
||||
const countStub = sinon.stub(Database.bookModel, 'count').resolves(123)
|
||||
const findAllStub = sinon.stub(Database.bookModel, 'findAll').resolves([])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue