fix: package bug

This commit is contained in:
bridge
2026-01-19 21:26:09 +08:00
parent bf13cdf2d2
commit a7ab18ea1c
5 changed files with 33 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
meta:
version: "1.2.1"
version: "1.2.2"
llm:
default_modes:

View File

@@ -1,4 +1,4 @@
import { vi, beforeEach, afterEach, beforeAll, afterAll } from 'vitest'
import { vi, beforeEach, afterEach } from 'vitest'
import { createPinia, setActivePinia } from 'pinia'
// Use fake timers globally for consistent async testing.

View File

@@ -1,5 +1,6 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { useSystemStore } from '@/stores/system'
import type { InitStatusDTO } from '@/types/api'
// Mock the API module.
vi.mock('@/api', () => ({
@@ -12,6 +13,18 @@ vi.mock('@/api', () => ({
import { systemApi } from '@/api'
const createMockStatus = (overrides: Partial<InitStatusDTO> = {}): InitStatusDTO => ({
status: 'idle',
phase: 0,
phase_name: '',
progress: 0,
elapsed_seconds: 0,
error: null,
llm_check_failed: false,
llm_error_message: '',
...overrides,
})
describe('useSystemStore', () => {
let store: ReturnType<typeof useSystemStore>
@@ -35,17 +48,17 @@ describe('useSystemStore', () => {
})
it('should return false when status is idle', () => {
store.initStatus = { status: 'idle', progress: 0 }
store.initStatus = createMockStatus({ status: 'idle', progress: 0 })
expect(store.isLoading).toBe(false)
})
it('should return true when status is in_progress', () => {
store.initStatus = { status: 'in_progress', progress: 50 }
store.initStatus = createMockStatus({ status: 'in_progress', progress: 50 })
expect(store.isLoading).toBe(true)
})
it('should return false when status is ready and initialized', () => {
store.initStatus = { status: 'ready', progress: 100 }
store.initStatus = createMockStatus({ status: 'ready', progress: 100 })
store.setInitialized(true)
expect(store.isLoading).toBe(false)
})
@@ -53,12 +66,12 @@ describe('useSystemStore', () => {
describe('isReady', () => {
it('should return false when not initialized', () => {
store.initStatus = { status: 'ready', progress: 100 }
store.initStatus = createMockStatus({ status: 'ready', progress: 100 })
expect(store.isReady).toBe(false)
})
it('should return true when status is ready and initialized', () => {
store.initStatus = { status: 'ready', progress: 100 }
store.initStatus = createMockStatus({ status: 'ready', progress: 100 })
store.setInitialized(true)
expect(store.isReady).toBe(true)
})

View File

@@ -6,6 +6,7 @@ import {
buildAvatarColorMap,
highlightAvatarNames,
MAX_EVENTS,
type AvatarColorInfo,
} from '@/utils/eventHelper'
import type { GameEvent } from '@/types/core'
@@ -56,7 +57,7 @@ describe('eventHelper', () => {
month: timestamp % 12,
text: `Event ${id}`,
relatedAvatarIds: [],
})
} as any) // Partial mock is enough for sorting logic
it('should merge events without duplicates', () => {
const existing = [createEvent('1', 100), createEvent('2', 101)]
@@ -155,7 +156,9 @@ describe('eventHelper', () => {
})
it('should highlight avatar names with color spans', () => {
const colorMap = new Map([['Alice', 'hsl(100, 70%, 65%)']])
const colorMap = new Map<string, AvatarColorInfo>([
['Alice', { id: 'Alice', color: 'hsl(100, 70%, 65%)' }]
])
const text = 'Alice defeated the enemy'
const result = highlightAvatarNames(text, colorMap)
@@ -166,7 +169,9 @@ describe('eventHelper', () => {
})
it('should escape HTML in names', () => {
const colorMap = new Map([['<script>', 'hsl(0, 70%, 65%)']])
const colorMap = new Map<string, AvatarColorInfo>([
['<script>', { id: 'script', color: 'hsl(0, 70%, 65%)' }]
])
const text = 'User <script> logged in'
const result = highlightAvatarNames(text, colorMap)
@@ -176,9 +181,9 @@ describe('eventHelper', () => {
})
it('should match longer names first to avoid partial matches', () => {
const colorMap = new Map([
['张三', 'hsl(100, 70%, 65%)'],
['张三丰', 'hsl(200, 70%, 65%)'],
const colorMap = new Map<string, AvatarColorInfo>([
['张三', { id: 'zhangsan', color: 'hsl(100, 70%, 65%)' }],
['张三丰', { id: 'zhangsanfeng', color: 'hsl(200, 70%, 65%)' }],
])
const text = '张三丰是一位大师'

View File

@@ -28,5 +28,6 @@
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
"include": ["src"],
"exclude": ["src/__tests__"]
}