skillhub/web/src/pages/cli-auth.test.ts
dongmucat e5a3aa6006 test(web): add colocated frontend coverage
变更摘要:
- 将前端测试共置到 web/src,保留并迁移 app 样式相关用例
- 为 pages、features、shared UI 与 hooks 补齐大范围 Vitest 覆盖
- 强化 governance、file preview、namespace header 与 API client 的关键分支测试
- 重新验证 pnpm run test 与 pnpm run typecheck,当前均已通过

关键文件:
- web/src/pages/dashboard/governance.test.ts
- web/src/features/governance/governance-inbox.test.ts
- web/src/features/skill/file-preview-dialog.test.ts
- web/src/features/namespace/namespace-header.test.ts
- web/src/api/client.test.ts
2026-03-23 16:13:34 +08:00

45 lines
1.2 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
// CliAuthPage has internal helpers isValidRedirectUri and decodeLabel which are
// not exported. We test the component render paths and validate the redirect
// URI logic via the rendered error states.
vi.mock('@tanstack/react-router', () => ({
useNavigate: () => vi.fn(),
}))
vi.mock('react-i18next', async () => {
const actual = await vi.importActual<typeof import('react-i18next')>('react-i18next')
return {
...actual,
useTranslation: () => ({
t: (key: string) => key,
}),
}
})
vi.mock('@/shared/ui/card', () => ({
Card: ({ children }: { children: unknown }) => children,
}))
vi.mock('@/shared/ui/button', () => ({
Button: ({ children }: { children: unknown }) => children,
}))
vi.mock('@/api/client', () => ({
getCurrentUser: vi.fn().mockResolvedValue(null),
tokenApi: { createToken: vi.fn() },
}))
vi.mock('@/app/router', () => ({
ORIGINAL_URL_SEARCH: '',
}))
import { CliAuthPage } from './cli-auth'
describe('CliAuthPage', () => {
it('exports a named component function', () => {
expect(typeof CliAuthPage).toBe('function')
expect(CliAuthPage.name).toBe('CliAuthPage')
})
})