mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-24 09:13:50 +02:00
refactor untils
This commit is contained in:
@@ -17,6 +17,7 @@ const mocks = vi.hoisted(() => ({
|
||||
favoriteFriendGroups: null,
|
||||
groupedByGroupKeyFavoriteFriends: null,
|
||||
localFriendFavorites: null,
|
||||
lastLocation: null,
|
||||
configGetString: vi.fn(),
|
||||
configGetBool: vi.fn(),
|
||||
configSetString: vi.fn(),
|
||||
@@ -37,6 +38,10 @@ mocks.sidebarSortMethods = mocks.makeRef('status');
|
||||
mocks.favoriteFriendGroups = mocks.makeRef([]);
|
||||
mocks.groupedByGroupKeyFavoriteFriends = mocks.makeRef({});
|
||||
mocks.localFriendFavorites = mocks.makeRef({});
|
||||
mocks.lastLocation = mocks.makeRef({
|
||||
location: 'wrld_home:123',
|
||||
friendList: new Map()
|
||||
});
|
||||
|
||||
vi.mock('pinia', () => ({
|
||||
storeToRefs: (store) => store
|
||||
@@ -68,6 +73,9 @@ vi.mock('../../../stores', () => ({
|
||||
favoriteFriendGroups: mocks.favoriteFriendGroups,
|
||||
groupedByGroupKeyFavoriteFriends: mocks.groupedByGroupKeyFavoriteFriends,
|
||||
localFriendFavorites: mocks.localFriendFavorites
|
||||
}),
|
||||
useLocationStore: () => ({
|
||||
lastLocation: mocks.lastLocation
|
||||
})
|
||||
}));
|
||||
|
||||
@@ -225,6 +233,10 @@ describe('FriendsLocations.vue', () => {
|
||||
mocks.favoriteFriendGroups.value = [];
|
||||
mocks.groupedByGroupKeyFavoriteFriends.value = {};
|
||||
mocks.localFriendFavorites.value = {};
|
||||
mocks.lastLocation.value = {
|
||||
location: 'wrld_home:123',
|
||||
friendList: new Map()
|
||||
};
|
||||
|
||||
mocks.configGetString.mockReset();
|
||||
mocks.configGetBool.mockReset();
|
||||
|
||||
@@ -314,20 +314,24 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useVirtualizer } from '@tanstack/vue-virtual';
|
||||
|
||||
import {
|
||||
handleImageUploadInput,
|
||||
readFileAsBase64,
|
||||
resizeImageToFitLimits,
|
||||
uploadImageLegacy,
|
||||
withUploadTimeout
|
||||
} from '../../shared/utils/imageUpload';
|
||||
import { useAppearanceSettingsStore, useAvatarStore, useModalStore, useUserStore } from '../../stores';
|
||||
import { ContextMenuContent, ContextMenuItem, ContextMenuSeparator } from '../../components/ui/context-menu';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from '../../components/ui/dropdown-menu';
|
||||
import { Field, FieldContent, FieldLabel } from '../../components/ui/field';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '../../components/ui/popover';
|
||||
import {
|
||||
applyAvatar,
|
||||
selectAvatarWithoutConfirmation,
|
||||
showAvatarDialog
|
||||
} from '../../coordinators/avatarCoordinator';
|
||||
import {
|
||||
handleImageUploadInput,
|
||||
resizeImageToFitLimits,
|
||||
uploadImageLegacy
|
||||
} from '../../coordinators/imageUploadCoordinator';
|
||||
import { DataTableEmpty, DataTableLayout } from '../../components/ui/data-table';
|
||||
import { ToggleGroup, ToggleGroupItem } from '../../components/ui/toggle-group';
|
||||
import { readFileAsBase64, withUploadTimeout } from '../../shared/utils/imageUpload';
|
||||
import { Badge } from '../../components/ui/badge';
|
||||
import { Button } from '../../components/ui/button';
|
||||
import { Input } from '../../components/ui/input';
|
||||
@@ -347,7 +351,6 @@
|
||||
import ManageTagsDialog from './ManageTagsDialog.vue';
|
||||
import MyAvatarCard from './components/MyAvatarCard.vue';
|
||||
import configRepository from '../../services/config.js';
|
||||
import { showAvatarDialog, selectAvatarWithoutConfirmation, applyAvatar } from '../../coordinators/avatarCoordinator';
|
||||
|
||||
const { t } = useI18n();
|
||||
const appearanceSettingsStore = useAppearanceSettingsStore();
|
||||
|
||||
@@ -55,6 +55,9 @@ const mocks = vi.hoisted(() => ({
|
||||
gameStore: {
|
||||
isGameRunning: { value: true }
|
||||
},
|
||||
instanceStore: {
|
||||
cachedInstances: new Map()
|
||||
},
|
||||
configRepository: {
|
||||
getBool: vi.fn(),
|
||||
setBool: vi.fn()
|
||||
@@ -111,6 +114,7 @@ vi.mock('../../../../stores', () => ({
|
||||
useGameStore: () => mocks.gameStore,
|
||||
useLaunchStore: () => mocks.launchStore,
|
||||
useLocationStore: () => mocks.locationStore,
|
||||
useInstanceStore: () => mocks.instanceStore,
|
||||
useUserStore: () => mocks.userStore
|
||||
}));
|
||||
|
||||
@@ -233,6 +237,7 @@ describe('FriendsSidebar.vue', () => {
|
||||
mocks.friendStore.activeFriends.value = [];
|
||||
mocks.friendStore.offlineFriends.value = [];
|
||||
mocks.friendStore.friendsInSameInstance.value = [];
|
||||
mocks.instanceStore.cachedInstances = new Map();
|
||||
|
||||
mocks.appearanceStore.isSidebarGroupByInstance.value = false;
|
||||
mocks.appearanceStore.isHideFriendsInSameInstance.value = false;
|
||||
|
||||
@@ -18,15 +18,25 @@ const mocks = vi.hoisted(() => ({
|
||||
},
|
||||
userStore: {
|
||||
cachedUsers: new Map(),
|
||||
showSendBoopDialog: vi.fn()
|
||||
showSendBoopDialog: vi.fn(),
|
||||
currentUser: { id: 'usr_me' }
|
||||
},
|
||||
friendStore: {
|
||||
friends: new Map()
|
||||
},
|
||||
groupStore: {},
|
||||
locationStore: {
|
||||
lastLocation: { value: { location: 'wrld_home:123' } }
|
||||
lastLocation: {
|
||||
location: 'wrld_home:123',
|
||||
value: { location: 'wrld_home:123' }
|
||||
}
|
||||
},
|
||||
gameStore: {
|
||||
isGameRunning: { value: true }
|
||||
},
|
||||
instanceStore: {
|
||||
cachedInstances: new Map()
|
||||
},
|
||||
showUserDialog: vi.fn(),
|
||||
showGroupDialog: vi.fn()
|
||||
}));
|
||||
@@ -42,9 +52,11 @@ vi.mock('pinia', async (importOriginal) => {
|
||||
vi.mock('../../../../stores', () => ({
|
||||
useNotificationStore: () => mocks.notificationStore,
|
||||
useUserStore: () => mocks.userStore,
|
||||
useFriendStore: () => mocks.friendStore,
|
||||
useGroupStore: () => mocks.groupStore,
|
||||
useLocationStore: () => mocks.locationStore,
|
||||
useGameStore: () => mocks.gameStore
|
||||
useGameStore: () => mocks.gameStore,
|
||||
useInstanceStore: () => mocks.instanceStore
|
||||
}));
|
||||
|
||||
vi.mock('../../../../coordinators/userCoordinator', () => ({
|
||||
@@ -60,6 +72,13 @@ vi.mock('../../../../shared/utils', () => ({
|
||||
userImage: vi.fn(() => 'https://example.com/avatar.png')
|
||||
}));
|
||||
|
||||
vi.mock('../../../../composables/useUserDisplay', () => ({
|
||||
useUserDisplay: () => ({
|
||||
userImage: vi.fn(() => 'https://example.com/avatar.png'),
|
||||
userStatusClass: vi.fn(() => '')
|
||||
})
|
||||
}));
|
||||
|
||||
vi.mock('vue-i18n', () => ({
|
||||
useI18n: () => ({
|
||||
t: (key) => key,
|
||||
@@ -170,6 +189,8 @@ describe('NotificationItem.vue', () => {
|
||||
mocks.userStore.showSendBoopDialog.mockReset();
|
||||
mocks.showGroupDialog.mockReset();
|
||||
mocks.userStore.cachedUsers = new Map();
|
||||
mocks.friendStore.friends = new Map();
|
||||
mocks.instanceStore.cachedInstances = new Map();
|
||||
});
|
||||
|
||||
test('renders sender and opens user dialog on sender click', async () => {
|
||||
|
||||
@@ -586,7 +586,8 @@
|
||||
} from '../../shared/utils';
|
||||
import { inventoryRequest, miscRequest, userRequest, vrcPlusIconRequest, vrcPlusImageRequest } from '../../api';
|
||||
import { useAdvancedSettingsStore, useAuthStore, useGalleryStore, useModalStore, useUserStore } from '../../stores';
|
||||
import { handleImageUploadInput, readFileAsBase64, withUploadTimeout } from '../../shared/utils/imageUpload';
|
||||
import { readFileAsBase64, withUploadTimeout } from '../../shared/utils/imageUpload';
|
||||
import { handleImageUploadInput } from '../../coordinators/imageUploadCoordinator';
|
||||
import { emojiAnimationStyleList, emojiAnimationStyleUrl } from '../../shared/constants';
|
||||
import { AppDebug } from '../../services/appConfig';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user