mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-10-06 22:00:49 +08:00
fix: expose macOS login-time key detection
This commit is contained in:
@@ -78,6 +78,43 @@ function renderPage(
|
||||
}
|
||||
|
||||
describe('DatabaseConnectionPage', () => {
|
||||
it('guides Apple Silicon users to log in while key capture is active', async () => {
|
||||
const onAutoGetKey = vi.fn()
|
||||
const { props, rerender } = renderPage({
|
||||
platform: 'darwin',
|
||||
mode: 'automatic',
|
||||
guideStep: 3,
|
||||
onAutoGetKey,
|
||||
environment: {
|
||||
platform: 'darwin',
|
||||
architecture: 'arm64',
|
||||
osVersion: 'macOS fixture',
|
||||
appVersion: 'v2.3.0',
|
||||
wechatVersion: '4.1.13',
|
||||
dataStructureVersion: '微信 4.x(WCDB)',
|
||||
dataDirectoryDetected: true,
|
||||
diagnosticSummary: 'fixture',
|
||||
autoDetectSupported: true,
|
||||
wechatRunning: true,
|
||||
accountIdentified: true,
|
||||
dbConnected: false,
|
||||
encryptionAvailable: true
|
||||
}
|
||||
})
|
||||
|
||||
await userEvent.click(screen.getByRole('button', { name: '开始获取密钥' }))
|
||||
expect(onAutoGetKey).toHaveBeenCalledOnce()
|
||||
|
||||
rerender(
|
||||
<TooltipProvider>
|
||||
<DatabaseConnectionPage {...props} mode="automatic" guideStep={4} isFetching />
|
||||
</TooltipProvider>
|
||||
)
|
||||
expect(screen.getByText('正在监听 macOS 登录密钥')).toBeVisible()
|
||||
expect(screen.getByText(/立即回到微信点击登录/)).toBeVisible()
|
||||
expect(screen.getByRole('button', { name: '正在获取密钥…' })).toBeDisabled()
|
||||
})
|
||||
|
||||
it('uses the automatic Intel Mac flow without exposing implementation details', () => {
|
||||
renderPage({
|
||||
platform: 'darwin',
|
||||
|
||||
@@ -31,6 +31,34 @@ const state: DatabaseKeyState = {
|
||||
}
|
||||
|
||||
describe('database key controls', () => {
|
||||
it('offers login-time key capture on Apple Silicon macOS', async () => {
|
||||
const user = userEvent.setup()
|
||||
const onDetect = vi.fn()
|
||||
render(
|
||||
<DatabaseKeyAutoDetect
|
||||
state={{
|
||||
...state,
|
||||
environment: {
|
||||
...state.environment!,
|
||||
platform: 'darwin',
|
||||
architecture: 'arm64',
|
||||
osVersion: 'macOS fixture',
|
||||
wechatVersion: '4.1.13',
|
||||
autoDetectSupported: true
|
||||
}
|
||||
}}
|
||||
disabled={false}
|
||||
onDetect={onDetect}
|
||||
onRefresh={vi.fn()}
|
||||
/>
|
||||
)
|
||||
|
||||
expect(screen.getByText('macOS 自动获取')).toBeVisible()
|
||||
expect(screen.getByText(/通常不需要扫码/)).toBeVisible()
|
||||
await user.click(screen.getByRole('button', { name: '自动获取密钥' }))
|
||||
expect(onDetect).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('offers automatic key detection on Intel Mac without exposing implementation details', async () => {
|
||||
const user = userEvent.setup()
|
||||
const onDetect = vi.fn()
|
||||
|
||||
@@ -25,6 +25,8 @@ describe('database key validation', () => {
|
||||
|
||||
it('maps automatic detection progress into stable phases', () => {
|
||||
expect(mapAutoDetectPhase('正在查找微信进程')).toBeGreaterThan(0)
|
||||
expect(mapAutoDetectPhase('正在请求管理员授权')).toBe(2)
|
||||
expect(mapAutoDetectPhase('授权后请在微信登录界面点击“登录”')).toBe(3)
|
||||
expect(mapAutoDetectPhase('已获取数据库密钥')).toBe(5)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user