test(settings): cover notification configuration (#674)

This commit is contained in:
InfinityPacer
2026-08-13 10:08:58 +08:00
committed by GitHub
parent b3b9248af6
commit 9654bd9852
6 changed files with 379 additions and 8 deletions
@@ -283,6 +283,22 @@ describe('MediaCard', () => {
})
})
it('keeps the local-exists marker hidden when the exists request reports a business failure', async () => {
const media = createMediaInfo({ title: '存在查询失败电影', tmdb_id: 9103 })
const existsRequest = vi.fn<(url: URL) => void>()
server.use(
querySubscribeByMediaHandler('9103', {}),
mediaExistsHandler({ data: {}, message: '查询失败', success: false }, 200, existsRequest),
)
const { container } = await renderCard(media)
getStatusObservers()[0]?.trigger()
await waitFor(() => expect(existsRequest).toHaveBeenCalledOnce())
await waitFor(() => expect(console.error).toHaveBeenCalled())
expect(container.querySelector('.bg-green-500')).toBeNull()
})
it.each([
['TMDB', createMediaInfo({ season: 3, tmdb_id: 9201, type: '电视剧' }), '9201', '3'],
[
@@ -292,6 +292,27 @@ describe('AddSubtitleDownloadDialog submissions', () => {
})
})
it('reveals advanced options and submits the selected media source identity', async () => {
const submitted = vi.fn()
server.use(subtitleDownloadHandler({ data: null, success: true }, 200, submitted))
const user = userEvent.setup()
await renderDialog({ mediaId: '84', mediaSource: 'themoviedb' })
expect(screen.getByLabelText('识别数据源')).not.toBeVisible()
await user.click(screen.getByRole('button', { name: '显示高级选项' }))
await user.selectOptions(screen.getByLabelText('识别数据源'), 'imdb')
await user.clear(screen.getByLabelText('IMDb ID'))
await user.type(screen.getByLabelText('IMDb ID'), 'tt0111161')
await user.click(screen.getByRole('button', { name: '下载字幕' }))
await waitFor(() => expect(submitted).toHaveBeenCalledOnce())
expect(submitted.mock.calls[0][0]).toMatchObject({
media_id: 'tt0111161',
media_source: 'imdb',
})
})
it('preserves the signed enclosure in download/subtitle and prevents duplicate submission', async () => {
const deferred = createDeferred<JsonBodyType>()
const submitted = vi.fn()