fix(v3): route music search through global search

This commit is contained in:
jxxghp
2026-08-07 22:54:39 +08:00
parent d72bb75996
commit d48ee55bab
4 changed files with 32 additions and 12 deletions

View File

@@ -167,7 +167,7 @@ const mediaSearchActions = computed(() => {
},
{
type: 'music',
icon: 'mdi-music-note-search',
icon: 'mdi-music-note-outline',
title: t('mediaType.music'),
description: t('music.subtitle'),
},

View File

@@ -3,8 +3,17 @@ import { DEFAULT_PERMISSIONS } from '@/utils/permission'
import { screen, waitFor, within } from '@testing-library/vue'
import userEvent from '@testing-library/user-event'
import { renderWithProviders } from '@tests/support/render'
import { defineComponent } from 'vue'
import { beforeEach, describe, expect, it } from 'vitest'
const IconStub = defineComponent({
name: 'VIcon',
props: {
icon: String,
},
template: '<i :data-icon="icon" />',
})
async function renderSearchBar() {
return renderWithProviders(SearchBarDialog, {
props: {
@@ -24,6 +33,11 @@ async function renderSearchBar() {
superUser: false,
},
},
global: {
stubs: {
VIcon: IconStub,
},
},
})
}
@@ -92,6 +106,16 @@ describe('SearchBarDialog media source selection', () => {
})
})
it('renders the bundled music icon in the music search action', async () => {
const user = userEvent.setup()
await renderSearchBar()
const input = await screen.findByPlaceholderText('搜索电影、剧集以及更多...')
await user.type(input, '晴天')
expect(getSearchItem('音乐').querySelector('[data-icon="mdi-music-note-outline"]')).not.toBeNull()
})
it('searches actors with the selected supported source', async () => {
const user = userEvent.setup()
const { router } = await renderSearchBar()

View File

@@ -62,6 +62,13 @@ async function renderAppCenter(items: PluginSidebarNavItem[], permissions: Recor
}
describe('app center plugin navigation', () => {
it('keeps resource search and omits the standalone music search menu', async () => {
await renderAppCenter([])
expect(await screen.findByText('搜索结果')).toBeInTheDocument()
expect(screen.queryByText('音乐搜索')).not.toBeInTheDocument()
})
it('uses the shared category, admin and feature permission semantics', async () => {
await renderAppCenter(
[

View File

@@ -31,17 +31,6 @@ export function getNavMenus(t: Composer['t']): NavMenu[] {
permission: 'search',
feature: PERMISSION_FEATURE.SEARCH_RESOURCE,
},
{
title: t('navItems.music'),
full_title: t('music.title'),
icon: 'mdi-music-note-search',
iconColor: 'primary',
to: '/music',
header: t('menu.start'),
admin: false,
permission: 'search',
feature: PERMISSION_FEATURE.SEARCH_RESOURCE,
},
{
title: t('navItems.recommend'),
icon: 'mdi-star-outline',