mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-08-21 16:32:35 +08:00
ci(test): run frontend checks on v2 pushes (#572)
This commit is contained in:
@@ -461,6 +461,55 @@ describe('MediaCard', () => {
|
||||
expect(dialogProps).toMatchObject({ subscribedSeasons: [2] })
|
||||
})
|
||||
|
||||
it.each([
|
||||
[
|
||||
'structured TMDB identity',
|
||||
createMediaInfo({
|
||||
media_id: 'series-9554',
|
||||
mediaid_prefix: undefined,
|
||||
season: 2,
|
||||
source: 'themoviedb',
|
||||
tmdb_id: undefined,
|
||||
type: '电视剧',
|
||||
}),
|
||||
'tmdb:series-9554',
|
||||
[
|
||||
{ id: 93, media_id: 'series-9554', media_source: 'themoviedb', season: 4, type: '电视剧' },
|
||||
{ id: 94, media_id: 'other', media_source: 'themoviedb', season: 5, type: '电视剧' },
|
||||
],
|
||||
[4],
|
||||
],
|
||||
[
|
||||
'legacy AniList identity',
|
||||
createMediaInfo({ anilist_id: 154588, season: 2, source: 'anilist', tmdb_id: undefined, type: '电视剧' }),
|
||||
'anilist:154588',
|
||||
[
|
||||
{ anilistid: 154588, id: 95, season: 1, type: '电视剧' },
|
||||
{ anilistid: 154589, id: 96, season: 3, type: '电视剧' },
|
||||
],
|
||||
[1],
|
||||
],
|
||||
])('matches %s when collecting subscribed TV seasons', async (_label, media, mediaId, subscribes, expected) => {
|
||||
server.use(
|
||||
querySubscribeByMediaHandler(mediaId, { id: 93, season: 2 }),
|
||||
mediaExistsHandler({ data: { item: {} }, success: false }),
|
||||
subscribeListHandler(subscribes),
|
||||
http.get(new URL('system/setting/public/DefaultTvSubscribeConfig', API_BASE_URL).href, () =>
|
||||
HttpResponse.json({ data: { value: {} }, success: true }),
|
||||
),
|
||||
)
|
||||
const { container } = await renderCard(media)
|
||||
getStatusObservers()[0]?.trigger()
|
||||
await waitFor(() => expect(getActionButtons(container).at(-1)).toHaveClass('text-error'))
|
||||
|
||||
await fireEvent.mouseEnter(getHoverArea(container))
|
||||
await fireEvent.click(getActionButtons(container).at(-1) as HTMLButtonElement)
|
||||
|
||||
await waitFor(() => expect(mocks.openSharedDialog).toHaveBeenCalledOnce())
|
||||
const [, dialogProps] = mocks.openSharedDialog.mock.calls[0] as [unknown, Record<string, unknown>]
|
||||
expect(dialogProps).toMatchObject({ subscribedSeasons: expected })
|
||||
})
|
||||
|
||||
it('updates image badges on load and falls back after an image error', async () => {
|
||||
const media = createMediaInfo({
|
||||
poster_path: '/original/poster.jpg',
|
||||
|
||||
@@ -154,6 +154,18 @@ describe('SubscribeSeasonDialog', () => {
|
||||
},
|
||||
'custom:custom-7305',
|
||||
],
|
||||
[
|
||||
'source-only TMDB',
|
||||
{
|
||||
bangumi_id: undefined,
|
||||
douban_id: undefined,
|
||||
media_id: 'source-7306',
|
||||
mediaid_prefix: undefined,
|
||||
source: 'themoviedb',
|
||||
tmdb_id: undefined,
|
||||
},
|
||||
'tmdb:source-7306',
|
||||
],
|
||||
] as const)('uses the %s media identifier without requesting TMDB groups', async (_label, overrides, mediaId) => {
|
||||
const media = createTvMedia(overrides)
|
||||
const requested = vi.fn()
|
||||
|
||||
@@ -892,6 +892,39 @@ describe('MediaDetailView subscriptions, seasons, and episode groups', () => {
|
||||
expect(container.querySelector('.v-expansion-panel')).toHaveTextContent('第 2 季')
|
||||
})
|
||||
|
||||
it('scrolls the episode-group rail in both directions', async () => {
|
||||
const media = createSubscribeTv({
|
||||
season_info: [createMediaSeason({ season_number: 1 })],
|
||||
title: '剧集组滚动剧',
|
||||
tmdb_id: 8718,
|
||||
})
|
||||
const groups = Array.from({ length: 5 }, (_, index) => ({
|
||||
episode_count: 8 + index,
|
||||
group_count: 1,
|
||||
id: `group-${index}`,
|
||||
name: `剧集组 ${index}`,
|
||||
}))
|
||||
const user = userEvent.setup()
|
||||
const { container } = await renderDetail({ episodeGroups: groups, media, type: '电视剧' })
|
||||
const rail = container.querySelector<HTMLElement>('.episode-group-rail')
|
||||
expect(rail).not.toBeNull()
|
||||
Object.defineProperties(rail, {
|
||||
clientWidth: { configurable: true, value: 400 },
|
||||
scrollLeft: { configurable: true, value: 0, writable: true },
|
||||
scrollWidth: { configurable: true, value: 1000 },
|
||||
})
|
||||
rail!.scrollBy = vi.fn()
|
||||
await fireEvent.scroll(rail as HTMLElement)
|
||||
|
||||
await user.click(screen.getByRole('button', { name: '查看更多剧集组' }))
|
||||
expect(rail!.scrollBy).toHaveBeenCalledWith({ behavior: 'smooth', left: 288 })
|
||||
|
||||
rail!.scrollLeft = 300
|
||||
await fireEvent.scroll(rail as HTMLElement)
|
||||
await user.click(screen.getByRole('button', { name: '查看上一组剧集组' }))
|
||||
expect(rail!.scrollBy).toHaveBeenCalledWith({ behavior: 'smooth', left: -288 })
|
||||
})
|
||||
|
||||
it('ignores stale episode-group seasons after a newer group is selected', async () => {
|
||||
const media = createSubscribeTv({
|
||||
season_info: [createMediaSeason({ season_number: 1 })],
|
||||
|
||||
Reference in New Issue
Block a user