mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
Fix cross-issue regressions found during post-0.4.4 merge review:\n\n- preserve permission mode across clear and empty-session replacement flows\n- keep provider effort passthrough and context-window estimates aligned with runtime metadata\n- invalidate recent project caches and trace message signatures when sessions change\n- recognize Windows ARM64 unpacked package-smoke output\n\nTested: bun test scripts/quality-gate/package-smoke/index.test.ts scripts/quality-gate/runner.test.ts\nTested: bun run check:desktop\nTested: bun run check:server\nConfidence: high\nScope-risk: moderate
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import type { RecentProject } from '../api/sessions'
|
|
import {
|
|
getCachedRecentProjects,
|
|
invalidateRecentProjectsCache,
|
|
setCachedRecentProjects,
|
|
} from './recentProjectsCache'
|
|
|
|
function makeProject(path: string): RecentProject {
|
|
return {
|
|
projectPath: path,
|
|
realPath: path,
|
|
projectName: path.split('/').filter(Boolean).pop() || path,
|
|
repoName: null,
|
|
branch: null,
|
|
isGit: false,
|
|
modifiedAt: '2026-05-07T00:00:00.000Z',
|
|
sessionCount: 1,
|
|
}
|
|
}
|
|
|
|
describe('recentProjectsCache', () => {
|
|
afterEach(() => {
|
|
vi.useRealTimers()
|
|
invalidateRecentProjectsCache()
|
|
})
|
|
|
|
it('returns fresh cached projects until they are invalidated or expire', () => {
|
|
vi.useFakeTimers()
|
|
vi.setSystemTime(new Date('2026-05-07T00:00:00.000Z'))
|
|
const projects = [makeProject('/workspace/project')]
|
|
|
|
setCachedRecentProjects(projects)
|
|
|
|
expect(getCachedRecentProjects()).toBe(projects)
|
|
|
|
vi.setSystemTime(new Date('2026-05-07T00:00:29.999Z'))
|
|
expect(getCachedRecentProjects()).toBe(projects)
|
|
|
|
vi.setSystemTime(new Date('2026-05-07T00:00:30.000Z'))
|
|
expect(getCachedRecentProjects()).toBeNull()
|
|
|
|
setCachedRecentProjects(projects)
|
|
invalidateRecentProjectsCache()
|
|
|
|
expect(getCachedRecentProjects()).toBeNull()
|
|
})
|
|
})
|