fix: package bug
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
meta:
|
meta:
|
||||||
version: "1.2.1"
|
version: "1.2.2"
|
||||||
|
|
||||||
llm:
|
llm:
|
||||||
default_modes:
|
default_modes:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { vi, beforeEach, afterEach, beforeAll, afterAll } from 'vitest'
|
import { vi, beforeEach, afterEach } from 'vitest'
|
||||||
import { createPinia, setActivePinia } from 'pinia'
|
import { createPinia, setActivePinia } from 'pinia'
|
||||||
|
|
||||||
// Use fake timers globally for consistent async testing.
|
// Use fake timers globally for consistent async testing.
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||||
import { useSystemStore } from '@/stores/system'
|
import { useSystemStore } from '@/stores/system'
|
||||||
|
import type { InitStatusDTO } from '@/types/api'
|
||||||
|
|
||||||
// Mock the API module.
|
// Mock the API module.
|
||||||
vi.mock('@/api', () => ({
|
vi.mock('@/api', () => ({
|
||||||
@@ -12,6 +13,18 @@ vi.mock('@/api', () => ({
|
|||||||
|
|
||||||
import { systemApi } from '@/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', () => {
|
describe('useSystemStore', () => {
|
||||||
let store: ReturnType<typeof useSystemStore>
|
let store: ReturnType<typeof useSystemStore>
|
||||||
|
|
||||||
@@ -35,17 +48,17 @@ describe('useSystemStore', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should return false when status is idle', () => {
|
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)
|
expect(store.isLoading).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return true when status is in_progress', () => {
|
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)
|
expect(store.isLoading).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return false when status is ready and initialized', () => {
|
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)
|
store.setInitialized(true)
|
||||||
expect(store.isLoading).toBe(false)
|
expect(store.isLoading).toBe(false)
|
||||||
})
|
})
|
||||||
@@ -53,12 +66,12 @@ describe('useSystemStore', () => {
|
|||||||
|
|
||||||
describe('isReady', () => {
|
describe('isReady', () => {
|
||||||
it('should return false when not initialized', () => {
|
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)
|
expect(store.isReady).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return true when status is ready and initialized', () => {
|
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)
|
store.setInitialized(true)
|
||||||
expect(store.isReady).toBe(true)
|
expect(store.isReady).toBe(true)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
buildAvatarColorMap,
|
buildAvatarColorMap,
|
||||||
highlightAvatarNames,
|
highlightAvatarNames,
|
||||||
MAX_EVENTS,
|
MAX_EVENTS,
|
||||||
|
type AvatarColorInfo,
|
||||||
} from '@/utils/eventHelper'
|
} from '@/utils/eventHelper'
|
||||||
import type { GameEvent } from '@/types/core'
|
import type { GameEvent } from '@/types/core'
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ describe('eventHelper', () => {
|
|||||||
month: timestamp % 12,
|
month: timestamp % 12,
|
||||||
text: `Event ${id}`,
|
text: `Event ${id}`,
|
||||||
relatedAvatarIds: [],
|
relatedAvatarIds: [],
|
||||||
})
|
} as any) // Partial mock is enough for sorting logic
|
||||||
|
|
||||||
it('should merge events without duplicates', () => {
|
it('should merge events without duplicates', () => {
|
||||||
const existing = [createEvent('1', 100), createEvent('2', 101)]
|
const existing = [createEvent('1', 100), createEvent('2', 101)]
|
||||||
@@ -155,7 +156,9 @@ describe('eventHelper', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should highlight avatar names with color spans', () => {
|
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 text = 'Alice defeated the enemy'
|
||||||
|
|
||||||
const result = highlightAvatarNames(text, colorMap)
|
const result = highlightAvatarNames(text, colorMap)
|
||||||
@@ -166,7 +169,9 @@ describe('eventHelper', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should escape HTML in names', () => {
|
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 text = 'User <script> logged in'
|
||||||
|
|
||||||
const result = highlightAvatarNames(text, colorMap)
|
const result = highlightAvatarNames(text, colorMap)
|
||||||
@@ -176,9 +181,9 @@ describe('eventHelper', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should match longer names first to avoid partial matches', () => {
|
it('should match longer names first to avoid partial matches', () => {
|
||||||
const colorMap = new Map([
|
const colorMap = new Map<string, AvatarColorInfo>([
|
||||||
['张三', 'hsl(100, 70%, 65%)'],
|
['张三', { id: 'zhangsan', color: 'hsl(100, 70%, 65%)' }],
|
||||||
['张三丰', 'hsl(200, 70%, 65%)'],
|
['张三丰', { id: 'zhangsanfeng', color: 'hsl(200, 70%, 65%)' }],
|
||||||
])
|
])
|
||||||
const text = '张三丰是一位大师'
|
const text = '张三丰是一位大师'
|
||||||
|
|
||||||
|
|||||||
@@ -28,5 +28,6 @@
|
|||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"noUncheckedSideEffectImports": true
|
"noUncheckedSideEffectImports": true
|
||||||
},
|
},
|
||||||
"include": ["src"]
|
"include": ["src"],
|
||||||
|
"exclude": ["src/__tests__"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user