Files
App/jest/functional/AddToQueue.test.ts
Violet Caulfield d06e6f36fc Feature/flatten recently played tracks into albums (#878)
* Flatten Multiple Recently Played Tracks into Albums

Flattens multiple recent tracks from the same album into an album navigation card

This one is for you Quen <3

When 3 songs or more from an album are in the recently played section, their album will be rendered instead

* fix navigation in the "play it again" list

* fix playing back stuff

* fix playback indexes for recently played

* fixes to the recently played flashlist

* calm it down on animations lol

* make the item context fire less often

* dememoize and stylize

* make this warm context fire less

* animation changes

* smol animation fixes

* adjusting query staletimes

* make the suggestions query fire once a day

* fix jest

* remove useCallback hooks

* fix key usage here

* I don't think these are necessary since we have a separate query for handling user data

* just to compare

* de memoize some more stuff

* fix this button finally

* put this nitro adapter back in

* git blame pikachu

* bruh

* fix up, clean up

* dehookify

* dehookify more

* add track press

* remove some more imports

* styling consitency

* search page improvements

* smol fixes
2025-12-30 16:27:09 -06:00

42 lines
1.1 KiB
TypeScript

import TrackPlayer from 'react-native-track-player'
import { playLaterInQueue } from '../../src/providers/Player/functions/queue'
import { BaseItemDto } from '@jellyfin/sdk/lib/generated-client/models'
import { getApi } from '../../src/stores'
jest.mock('../../src/stores')
describe('Add to Queue - playLaterInQueue', () => {
beforeEach(() => {
jest.clearAllMocks()
})
it('adds track to the end of the queue', async () => {
const track: BaseItemDto = {
Id: 't1',
Name: 'Test Track',
// Intentionally exclude AlbumId to avoid image URL building
Type: 'Audio',
}
// Mock the Api instance
const mockApi = {
basePath: '',
}
;(getApi as jest.Mock).mockReturnValue(mockApi)
// Mock getQueue to return updated list after add
;(TrackPlayer.getQueue as jest.Mock).mockResolvedValue([{ item: track }])
await playLaterInQueue({
tracks: [track],
queuingType: undefined,
})
expect(TrackPlayer.add).toHaveBeenCalledTimes(1)
const callArg = (TrackPlayer.add as jest.Mock).mock.calls[0][0]
expect(Array.isArray(callArg)).toBe(true)
expect(callArg[0].item.Id).toBe('t1')
})
})