mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-08-15 02:29:31 +08:00
fix: 对齐站点音乐搜索交互
This commit is contained in:
@@ -933,7 +933,7 @@ onMounted(() => {
|
||||
</template>
|
||||
</VListItem>
|
||||
|
||||
<VListItem density="comfortable" link @click="openSiteDialog('music')" class="search-result-item mx-2 my-1">
|
||||
<VListItem density="comfortable" link @click="searchMusicTorrent" class="search-result-item mx-2 my-1">
|
||||
<template #prepend>
|
||||
<div class="result-icon-wrapper">
|
||||
<VIcon icon="mdi-music-box-multiple-outline" size="small" color="medium-emphasis" />
|
||||
@@ -946,6 +946,18 @@ onMounted(() => {
|
||||
{{ t('common.search') }} <span class="primary-text font-weight-medium">{{ searchWord }}</span>
|
||||
{{ t('dialog.searchBar.relatedMusicResources') }}
|
||||
</VListItemSubtitle>
|
||||
<template #append>
|
||||
<VBtn
|
||||
v-if="hasManagePermission"
|
||||
size="x-small"
|
||||
variant="tonal"
|
||||
color="primary"
|
||||
rounded="pill"
|
||||
@click.stop="openSiteDialog('music')"
|
||||
>
|
||||
{{ t('dialog.searchBar.selectSites') }}
|
||||
</VBtn>
|
||||
</template>
|
||||
</VListItem>
|
||||
|
||||
<VListItem density="comfortable" link @click="searchSubtitle" class="search-result-item mx-2 my-1">
|
||||
|
||||
@@ -26,6 +26,7 @@ const IconStub = defineComponent({
|
||||
|
||||
async function renderSearchBar(
|
||||
overrides: {
|
||||
managePermission?: boolean
|
||||
searchPermission?: boolean
|
||||
searchSource?: string
|
||||
} = {},
|
||||
@@ -41,7 +42,7 @@ async function renderSearchBar(
|
||||
...DEFAULT_PERMISSIONS,
|
||||
admin: false,
|
||||
discovery: true,
|
||||
manage: false,
|
||||
manage: overrides.managePermission ?? false,
|
||||
search: overrides.searchPermission ?? false,
|
||||
subscribe: false,
|
||||
},
|
||||
@@ -74,6 +75,12 @@ describe('SearchBarDialog media source selection', () => {
|
||||
localStorage.clear()
|
||||
mocks.apiGet.mockImplementation((path: string) => {
|
||||
if (path === 'system/setting/public/IndexerSites') return Promise.resolve({ value: [11, 99] })
|
||||
if (path === 'site/') {
|
||||
return Promise.resolve([
|
||||
{ id: 11, is_active: true, name: '音乐站' },
|
||||
{ id: 99, is_active: true, name: '综合站' },
|
||||
])
|
||||
}
|
||||
if (path === 'site/media/music') {
|
||||
return Promise.resolve([
|
||||
{ id: 11, is_active: true, name: '音乐站' },
|
||||
@@ -246,7 +253,7 @@ describe('SearchBarDialog media source selection', () => {
|
||||
expect(getSearchItem('音乐')).not.toHaveTextContent('搜索音乐元数据,并进入站点资源搜索、下载和订阅流程')
|
||||
})
|
||||
|
||||
it('searches music sites by keyword without resolving a media identity', async () => {
|
||||
it('searches music sites directly by keyword without resolving a media identity', async () => {
|
||||
const user = userEvent.setup()
|
||||
const { router } = await renderSearchBar({ searchPermission: true })
|
||||
const input = await screen.findByPlaceholderText('搜索电影、剧集以及更多...')
|
||||
@@ -254,6 +261,28 @@ describe('SearchBarDialog media source selection', () => {
|
||||
await user.type(input, '周杰伦')
|
||||
await user.click(getSearchItem('在站点中搜索音乐资源'))
|
||||
|
||||
await waitFor(() => {
|
||||
expect(router.currentRoute.value.path).toBe('/resource')
|
||||
expect(router.currentRoute.value.query).toEqual({
|
||||
area: 'title',
|
||||
keyword: '周杰伦',
|
||||
result_type: 'torrent',
|
||||
sites: '11,99',
|
||||
type: '音乐',
|
||||
})
|
||||
})
|
||||
expect(mocks.apiGet).not.toHaveBeenCalledWith('site/media/music')
|
||||
})
|
||||
|
||||
it('selects music-capable sites before searching by keyword', async () => {
|
||||
const user = userEvent.setup()
|
||||
const { router } = await renderSearchBar({ managePermission: true, searchPermission: true })
|
||||
const input = await screen.findByPlaceholderText('搜索电影、剧集以及更多...')
|
||||
|
||||
await user.type(input, '周杰伦')
|
||||
const musicSiteItem = getSearchItem('在站点中搜索音乐资源')
|
||||
await user.click(within(musicSiteItem).getByRole('button', { name: '选择站点' }))
|
||||
|
||||
await waitFor(() => expect(mocks.apiGet).toHaveBeenCalledWith('site/media/music'))
|
||||
expect(await screen.findByText('音乐站')).toBeInTheDocument()
|
||||
expect(screen.queryByText('停用音乐站')).not.toBeInTheDocument()
|
||||
|
||||
Reference in New Issue
Block a user