rename globalSearch

This commit is contained in:
pa
2026-03-14 20:05:10 +09:00
parent b750d3fb9a
commit 84f46a5645
14 changed files with 51 additions and 51 deletions

View File

@@ -5,13 +5,13 @@
import { storeToRefs } from 'pinia';
import { useI18n } from 'vue-i18n';
import { useGlobalSearchStore } from '../stores/globalSearch';
import { useQuickSearchStore } from '../stores/quickSearch';
import { useUserDisplay } from '../composables/useUserDisplay';
import GlobalSearchSync from './GlobalSearchSync.vue';
import QuickSearchSync from './QuickSearchSync.vue';
const { userImage } = useUserDisplay();
const globalSearchStore = useGlobalSearchStore();
const quickSearchStore = useQuickSearchStore();
const {
isOpen,
query,
@@ -23,8 +23,8 @@
ownGroupResults,
joinedGroupResults,
hasResults
} = storeToRefs(globalSearchStore);
const { selectResult } = globalSearchStore;
} = storeToRefs(quickSearchStore);
const { selectResult } = quickSearchStore;
const { t } = useI18n();
/**
@@ -44,7 +44,7 @@
</DialogHeader>
<Command>
<!-- Sync filterState.search store.query -->
<GlobalSearchSync />
<QuickSearchSync />
<CommandInput :placeholder="t('side_panel.search_placeholder')" />
<CommandList class="max-h-[min(400px,50vh)] overflow-y-auto overflow-x-hidden">
<template v-if="!query || query.length < 2">

View File

@@ -15,15 +15,15 @@
import { nextTick, watch } from 'vue';
import { useCommand } from '@/components/ui/command';
import { useGlobalSearchStore } from '../stores/globalSearch';
import { useQuickSearchStore } from '../stores/quickSearch';
const { filterState, allItems, allGroups } = useCommand();
const globalSearchStore = useGlobalSearchStore();
const quickSearchStore = useQuickSearchStore();
watch(
() => filterState.search,
async (value) => {
globalSearchStore.setQuery(value);
quickSearchStore.setQuery(value);
// When query < 2 chars, override the built-in filter
// so all items (hint categories) stay visible

View File

@@ -18,8 +18,8 @@ const mocks = vi.hoisted(() => ({
vi.mock('pinia', async (i) => ({ ...(await i()), storeToRefs: (s) => s }));
vi.mock('vue-i18n', () => ({ useI18n: () => ({ t: (k) => k }) }));
vi.mock('../../stores/globalSearch', () => ({
useGlobalSearchStore: () => ({
vi.mock('../../stores/quickSearch', () => ({
useQuickSearchStore: () => ({
isOpen: mocks.isOpen,
query: mocks.query,
friendResults: mocks.friendResults,
@@ -36,7 +36,7 @@ vi.mock('../../stores/globalSearch', () => ({
vi.mock('../../composables/useUserDisplay', () => ({
useUserDisplay: () => ({ userImage: (...a) => mocks.userImage(...a) })
}));
vi.mock('../GlobalSearchSync.vue', () => ({
vi.mock('../QuickSearchSync.vue', () => ({
default: { template: '<div data-testid="sync" />' }
}));
vi.mock('@/components/ui/dialog', () => ({
@@ -63,9 +63,9 @@ vi.mock('lucide-vue-next', () => ({
Users: { template: '<i />' }
}));
import GlobalSearchDialog from '../GlobalSearchDialog.vue';
import QuickSearchDialog from '../QuickSearchDialog.vue';
describe('GlobalSearchDialog.vue', () => {
describe('QuickSearchDialog.vue', () => {
beforeEach(() => {
mocks.selectResult.mockClear();
mocks.query.value = '';
@@ -74,7 +74,7 @@ describe('GlobalSearchDialog.vue', () => {
});
it('renders search dialog structure', () => {
const wrapper = mount(GlobalSearchDialog);
const wrapper = mount(QuickSearchDialog);
expect(wrapper.text()).toContain('side_panel.search_placeholder');
expect(wrapper.find('[data-testid="sync"]').exists()).toBe(true);
});

View File

@@ -34,17 +34,17 @@ vi.mock('@/components/ui/command', async () => {
};
});
vi.mock('../../stores/globalSearch', () => ({
useGlobalSearchStore: () => ({
vi.mock('../../stores/quickSearch', () => ({
useQuickSearchStore: () => ({
setQuery: (...args) => mocks.setQuery(...args)
})
}));
import GlobalSearchSync from '../GlobalSearchSync.vue';
import QuickSearchSync from '../QuickSearchSync.vue';
describe('GlobalSearchSync.vue', () => {
describe('QuickSearchSync.vue', () => {
it('syncs query and keeps hint groups/items visible when query length < 2', async () => {
mount(GlobalSearchSync);
mount(QuickSearchSync);
mocks.filterState.search = 'a';
await Promise.resolve();