feat: 支持Mac Intel获取密钥, 提供完整支持

This commit is contained in:
电摇小子
2026-09-13 20:08:40 +08:00
parent 9288256a5e
commit 70c55442f3
18 changed files with 384 additions and 26 deletions
@@ -55,6 +55,7 @@ function renderPage(
onSelectDbRoot: vi.fn(),
onToggleDbKey: vi.fn(),
onAutoGetKey: vi.fn(),
onInstallIntelKeyRuntime: vi.fn(),
onRefreshEnvironment: vi.fn(),
onGuideNext: vi.fn(),
onGuideBack: vi.fn(),
@@ -77,6 +78,37 @@ function renderPage(
}
describe('DatabaseConnectionPage', () => {
it('uses the automatic Intel Mac flow without exposing implementation details', () => {
renderPage({
platform: 'darwin',
mode: 'automatic',
guideStep: 3,
environment: {
platform: 'darwin',
architecture: 'x64',
osVersion: 'macOS fixture',
appVersion: 'v2.1.6',
wechatVersion: '4.1.10',
dataStructureVersion: '微信 4.x(WCDB)',
dataDirectoryDetected: true,
diagnosticSummary: 'fixture',
autoDetectSupported: true,
wechatRunning: true,
accountIdentified: true,
dbConnected: false,
encryptionAvailable: true,
pythonAvailable: true,
fridaAvailable: true,
wechatAdhocSigned: true,
sipDisabled: true
}
})
expect(screen.getByRole('button', { name: '开始获取密钥' })).toBeVisible()
expect(screen.queryByText(/管理员授权|电脑密码/)).not.toBeInTheDocument()
expect(screen.queryByText(/Frida|Python|SIP|重新签名/)).not.toBeInTheDocument()
})
it('renders a discovered nickname and avatar before connection', () => {
const { container } = renderPage({
mode: 'automatic',
@@ -31,6 +31,36 @@ const state: DatabaseKeyState = {
}
describe('database key controls', () => {
it('offers automatic key detection on Intel Mac without exposing implementation details', async () => {
const user = userEvent.setup()
const onDetect = vi.fn()
render(
<DatabaseKeyAutoDetect
state={{
...state,
environment: {
...state.environment!,
platform: 'darwin',
architecture: 'x64',
pythonAvailable: true,
fridaAvailable: true,
wechatAdhocSigned: true,
sipDisabled: true
}
}}
disabled={false}
onDetect={onDetect}
onRefresh={vi.fn()}
/>
)
expect(screen.getByText('Intel Mac 自动获取')).toBeVisible()
expect(screen.getByText(/按页面提示操作即可/)).toBeVisible()
expect(screen.queryByText(/Frida|Python|SIP|签名/)).not.toBeInTheDocument()
await user.click(screen.getByRole('button', { name: '自动获取密钥' }))
expect(onDetect).toHaveBeenCalledOnce()
})
it('keeps auto-detect and refresh callbacks separate', async () => {
const user = userEvent.setup()
const onDetect = vi.fn()