Fix profile store mocks in usage tests

This commit is contained in:
ekko
2026-05-24 10:07:53 +08:00
committed by ekko
parent f4c70bd849
commit dca8fc6d8a
2 changed files with 28 additions and 2 deletions
+12
View File
@@ -3,11 +3,20 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import { mount, flushPromises } from '@vue/test-utils'
const fetchSkillUsageStatsMock = vi.hoisted(() => vi.fn())
const mockProfilesStore = vi.hoisted(() => ({
activeProfileName: 'default',
profiles: [{ name: 'default' }],
fetchProfiles: vi.fn(),
}))
vi.mock('@/api/hermes/skills', () => ({
fetchSkillUsageStats: fetchSkillUsageStatsMock,
}))
vi.mock('@/stores/hermes/profiles', () => ({
useProfilesStore: () => mockProfilesStore,
}))
vi.mock('vue-i18n', () => ({
useI18n: () => ({
t: (key: string, params?: Record<string, unknown>) => {
@@ -70,6 +79,9 @@ describe('SkillsUsageView', () => {
beforeEach(() => {
fetchSkillUsageStatsMock.mockReset()
fetchSkillUsageStatsMock.mockResolvedValue(sevenDayStats)
mockProfilesStore.activeProfileName = 'default'
mockProfilesStore.profiles = [{ name: 'default' }]
mockProfilesStore.fetchProfiles.mockReset()
})
it('loads rolling 7 day skill usage and renders statistics beside a skill-colored visual trend', async () => {