mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-26 10:13:48 +02:00
use oxfmt instead of prettier
This commit is contained in:
@@ -126,7 +126,9 @@
|
||||
<Spinner class="text-2xl" />
|
||||
</div>
|
||||
<template v-else-if="searchWorldResults.length > 0">
|
||||
<ItemGroup class="grid gap-3" style="grid-template-columns: repeat(auto-fill, minmax(180px, 1fr))">
|
||||
<ItemGroup
|
||||
class="grid gap-3"
|
||||
style="grid-template-columns: repeat(auto-fill, minmax(180px, 1fr))">
|
||||
<Item
|
||||
v-for="world in searchWorldResults"
|
||||
:key="world.id"
|
||||
@@ -200,7 +202,9 @@
|
||||
<Spinner class="text-2xl" />
|
||||
</div>
|
||||
<template v-else-if="searchAvatarPage.length > 0">
|
||||
<ItemGroup class="grid gap-3" style="grid-template-columns: repeat(auto-fill, minmax(180px, 1fr))">
|
||||
<ItemGroup
|
||||
class="grid gap-3"
|
||||
style="grid-template-columns: repeat(auto-fill, minmax(180px, 1fr))">
|
||||
<Item
|
||||
v-for="avatar in searchAvatarPage"
|
||||
:key="avatar.id"
|
||||
@@ -300,15 +304,7 @@
|
||||
import { Spinner } from '@/components/ui/spinner';
|
||||
import AvatarProviderDialog from '../Settings/dialogs/AvatarProviderDialog.vue';
|
||||
import SearchPagination from './components/SearchPagination.vue';
|
||||
import {
|
||||
Item,
|
||||
ItemContent,
|
||||
ItemDescription,
|
||||
ItemGroup,
|
||||
ItemHeader,
|
||||
ItemMedia,
|
||||
ItemTitle
|
||||
} from '@/components/ui/item';
|
||||
import { Item, ItemContent, ItemDescription, ItemGroup, ItemHeader, ItemMedia, ItemTitle } from '@/components/ui/item';
|
||||
|
||||
import { computed, onUnmounted, ref } from 'vue';
|
||||
import { useMagicKeys, whenever } from '@vueuse/core';
|
||||
@@ -408,14 +404,8 @@
|
||||
clearWorldSearch
|
||||
} = useSearchWorld();
|
||||
|
||||
const {
|
||||
searchGroupParams,
|
||||
searchGroupResults,
|
||||
isSearchGroupLoading,
|
||||
searchGroup,
|
||||
moreSearchGroup,
|
||||
clearGroupSearch
|
||||
} = useSearchGroup();
|
||||
const { searchGroupParams, searchGroupResults, isSearchGroupLoading, searchGroup, moreSearchGroup, clearGroupSearch } =
|
||||
useSearchGroup();
|
||||
|
||||
const paginationConfig = computed(() => {
|
||||
switch (activeSearchTab.value) {
|
||||
|
||||
@@ -102,7 +102,8 @@ vi.mock('../../../stores', () => ({
|
||||
randomUserColours: mocks.randomUserColours
|
||||
}),
|
||||
useAvatarProviderStore: () => ({
|
||||
avatarRemoteDatabaseProviderList: mocks.avatarRemoteDatabaseProviderList,
|
||||
avatarRemoteDatabaseProviderList:
|
||||
mocks.avatarRemoteDatabaseProviderList,
|
||||
avatarRemoteDatabaseProvider: mocks.avatarRemoteDatabaseProvider,
|
||||
isAvatarProviderDialogVisible: mocks.isAvatarProviderDialogVisible,
|
||||
setAvatarProvider: (...args) => mocks.setAvatarProvider(...args)
|
||||
@@ -171,14 +172,22 @@ vi.mock('@/components/ui/tabs', () => ({
|
||||
'</div>'
|
||||
},
|
||||
TabsList: { template: '<div><slot /></div>' },
|
||||
TabsTrigger: { props: ['value'], template: '<button :data-value="value"><slot /></button>' },
|
||||
TabsContent: { props: ['value'], template: '<section :data-testid="`content-${value}`"><slot /></section>' }
|
||||
TabsTrigger: {
|
||||
props: ['value'],
|
||||
template: '<button :data-value="value"><slot /></button>'
|
||||
},
|
||||
TabsContent: {
|
||||
props: ['value'],
|
||||
template:
|
||||
'<section :data-testid="`content-${value}`"><slot /></section>'
|
||||
}
|
||||
}));
|
||||
|
||||
vi.mock('@/components/ui/button', () => ({
|
||||
Button: {
|
||||
emits: ['click'],
|
||||
template: '<button data-testid="button" v-bind="$attrs" @click="$emit(\'click\')"><slot /></button>'
|
||||
template:
|
||||
'<button data-testid="button" v-bind="$attrs" @click="$emit(\'click\')"><slot /></button>'
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -212,7 +221,8 @@ vi.mock('@/components/ui/select', () => ({
|
||||
vi.mock('@/components/ui/item', () => ({
|
||||
Item: {
|
||||
emits: ['click'],
|
||||
template: '<article class="item" @click="$emit(\'click\')"><slot /></article>'
|
||||
template:
|
||||
'<article class="item" @click="$emit(\'click\')"><slot /></article>'
|
||||
},
|
||||
ItemGroup: { template: '<div><slot /></div>' },
|
||||
ItemHeader: { template: '<div><slot /></div>' },
|
||||
@@ -254,7 +264,9 @@ function mountSearch() {
|
||||
global: {
|
||||
stubs: {
|
||||
TooltipWrapper: { template: '<div><slot /></div>' },
|
||||
AvatarProviderDialog: { template: '<div data-testid="avatar-provider-dialog" />' },
|
||||
AvatarProviderDialog: {
|
||||
template: '<div data-testid="avatar-provider-dialog" />'
|
||||
},
|
||||
SearchPagination: {
|
||||
props: ['show', 'prevDisabled', 'nextDisabled'],
|
||||
emits: ['prev', 'next'],
|
||||
@@ -310,16 +322,24 @@ describe('Search.vue', () => {
|
||||
await wrapper.get('button.ml-2').trigger('click');
|
||||
|
||||
expect(mocks.useSearchUserApi.clearUserSearch).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.useSearchWorldApi.clearWorldSearch).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.useSearchAvatarApi.clearAvatarSearch).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.useSearchGroupApi.clearGroupSearch).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.useSearchWorldApi.clearWorldSearch).toHaveBeenCalledTimes(
|
||||
1
|
||||
);
|
||||
expect(
|
||||
mocks.useSearchAvatarApi.clearAvatarSearch
|
||||
).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.useSearchGroupApi.clearGroupSearch).toHaveBeenCalledTimes(
|
||||
1
|
||||
);
|
||||
expect(mocks.clearSearch).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('runs user search on Enter when active tab is user', async () => {
|
||||
const wrapper = mountSearch();
|
||||
|
||||
await wrapper.get('[data-testid="search-input"]').trigger('keyup.enter');
|
||||
await wrapper
|
||||
.get('[data-testid="search-input"]')
|
||||
.trigger('keyup.enter');
|
||||
|
||||
expect(mocks.useSearchUserApi.searchUser).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.useSearchAvatarApi.searchAvatar).not.toHaveBeenCalled();
|
||||
@@ -330,9 +350,13 @@ describe('Search.vue', () => {
|
||||
mocks.searchText.value = 'ab';
|
||||
|
||||
await wrapper.get('[data-testid="set-tab-avatar"]').trigger('click');
|
||||
await wrapper.get('[data-testid="search-input"]').trigger('keyup.enter');
|
||||
await wrapper
|
||||
.get('[data-testid="search-input"]')
|
||||
.trigger('keyup.enter');
|
||||
|
||||
expect(mocks.toastWarning).toHaveBeenCalledWith('view.search.avatar.min_chars_warning');
|
||||
expect(mocks.toastWarning).toHaveBeenCalledWith(
|
||||
'view.search.avatar.min_chars_warning'
|
||||
);
|
||||
expect(mocks.useSearchAvatarApi.searchAvatar).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -43,8 +43,14 @@ describe('useSearchAvatar', () => {
|
||||
await api.searchAvatar();
|
||||
|
||||
expect(mocks.lookupAvatars).toHaveBeenCalledWith('search', 'alice');
|
||||
expect(api.searchAvatarResults.value.map((x) => x.id)).toEqual(['avtr_1', 'avtr_2']);
|
||||
expect(api.searchAvatarPage.value.map((x) => x.id)).toEqual(['avtr_1', 'avtr_2']);
|
||||
expect(api.searchAvatarResults.value.map((x) => x.id)).toEqual([
|
||||
'avtr_1',
|
||||
'avtr_2'
|
||||
]);
|
||||
expect(api.searchAvatarPage.value.map((x) => x.id)).toEqual([
|
||||
'avtr_1',
|
||||
'avtr_2'
|
||||
]);
|
||||
expect(api.searchAvatarPageNum.value).toBe(0);
|
||||
});
|
||||
|
||||
@@ -60,7 +66,9 @@ describe('useSearchAvatar', () => {
|
||||
|
||||
it('paginates results by 10 items', () => {
|
||||
const api = useSearchAvatar();
|
||||
api.searchAvatarResults.value = Array.from({ length: 25 }, (_, i) => ({ id: `avtr_${i}` }));
|
||||
api.searchAvatarResults.value = Array.from({ length: 25 }, (_, i) => ({
|
||||
id: `avtr_${i}`
|
||||
}));
|
||||
api.searchAvatarPage.value = api.searchAvatarResults.value.slice(0, 10);
|
||||
|
||||
api.moreSearchAvatar(1);
|
||||
|
||||
@@ -38,7 +38,9 @@ describe('useSearchGroup', () => {
|
||||
it('starts group search with normalized query', async () => {
|
||||
mocks.searchText.value = 'group+name';
|
||||
mocks.replaceBioSymbols.mockReturnValue('group name');
|
||||
mocks.groupSearch.mockResolvedValue({ json: [{ id: 'grp_1' }, { id: 'grp_1' }, { id: 'grp_2' }] });
|
||||
mocks.groupSearch.mockResolvedValue({
|
||||
json: [{ id: 'grp_1' }, { id: 'grp_1' }, { id: 'grp_2' }]
|
||||
});
|
||||
|
||||
const api = useSearchGroup();
|
||||
await api.searchGroup();
|
||||
@@ -49,7 +51,10 @@ describe('useSearchGroup', () => {
|
||||
offset: 0,
|
||||
query: 'group name'
|
||||
});
|
||||
expect(api.searchGroupResults.value.map((x) => x.id)).toEqual(['grp_1', 'grp_2']);
|
||||
expect(api.searchGroupResults.value.map((x) => x.id)).toEqual([
|
||||
'grp_1',
|
||||
'grp_2'
|
||||
]);
|
||||
});
|
||||
|
||||
it('moves backward paging offset without going below zero', async () => {
|
||||
@@ -59,6 +64,10 @@ describe('useSearchGroup', () => {
|
||||
|
||||
await api.moreSearchGroup(-1);
|
||||
|
||||
expect(mocks.groupSearch).toHaveBeenCalledWith({ n: 10, offset: 0, query: 'abc' });
|
||||
expect(mocks.groupSearch).toHaveBeenCalledWith({
|
||||
n: 10,
|
||||
offset: 0,
|
||||
query: 'abc'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -44,10 +44,19 @@ describe('useSearchUser', () => {
|
||||
|
||||
it('passes page direction into handleMoreSearchUser', async () => {
|
||||
const api = useSearchUser();
|
||||
api.searchUserParams.value = { n: 10, offset: 10, search: 'Alice', customFields: 'displayName', sort: 'relevance' };
|
||||
api.searchUserParams.value = {
|
||||
n: 10,
|
||||
offset: 10,
|
||||
search: 'Alice',
|
||||
customFields: 'displayName',
|
||||
sort: 'relevance'
|
||||
};
|
||||
|
||||
await api.handleMoreSearchUser(-1);
|
||||
|
||||
expect(mocks.moreSearchUser).toHaveBeenCalledWith(-1, api.searchUserParams.value);
|
||||
expect(mocks.moreSearchUser).toHaveBeenCalledWith(
|
||||
-1,
|
||||
api.searchUserParams.value
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,7 +49,9 @@ describe('useSearchWorld', () => {
|
||||
mocks.searchText.value = 'home world';
|
||||
mocks.replaceBioSymbols.mockReturnValue('home world');
|
||||
mocks.cachedWorlds.set('wrld_1', { id: 'wrld_1', name: 'World One' });
|
||||
mocks.getWorlds.mockResolvedValue({ json: [{ id: 'wrld_1' }, { id: 'wrld_missing' }] });
|
||||
mocks.getWorlds.mockResolvedValue({
|
||||
json: [{ id: 'wrld_1' }, { id: 'wrld_missing' }]
|
||||
});
|
||||
|
||||
const api = useSearchWorld();
|
||||
api.searchWorld({});
|
||||
@@ -72,7 +74,14 @@ describe('useSearchWorld', () => {
|
||||
|
||||
it('selects category row and uses row sort settings', async () => {
|
||||
mocks.cachedConfig.value = {
|
||||
dynamicWorldRows: [{ index: 2, sortHeading: 'featured', sortOrder: 'ascending', tag: 'party' }]
|
||||
dynamicWorldRows: [
|
||||
{
|
||||
index: 2,
|
||||
sortHeading: 'featured',
|
||||
sortOrder: 'ascending',
|
||||
tag: 'party'
|
||||
}
|
||||
]
|
||||
};
|
||||
mocks.getWorlds.mockResolvedValue({ json: [] });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user