Skip to content

feat: expo-example automation test framework#694

Merged
wabicai merged 29 commits intoonekeyfrom
feature/automation-test
Mar 20, 2026
Merged

feat: expo-example automation test framework#694
wabicai merged 29 commits intoonekeyfrom
feature/automation-test

Conversation

@wabicai
Copy link
Copy Markdown
Member

@wabicai wabicai commented Mar 9, 2026

Summary

核心功能

自动化测试框架(expo-example)

  • 新增 AutomationTest 页面,支持设备流程测试(BIP39/SLIP39 钱包创建与导入)和 SDK 批量地址/公钥验证
  • 新增 scenarioCatalog + scenarioResolver:基于 Jira 场景目录(OK-26053/26054/5504/40090)的测试用例解析
  • 新增 PhonePilot MCP client:手机物理操控客户端,支持机械臂控制、OCR 识别、操作序列执行
  • 测试配置持久化到 localStorage

测试套件

  • deviceFlow:设备重置 + BIP39/SLIP39 钱包创建/导入全流程,支持 normal/passphrase_empty/passphrase_1/passphrase_2 变体
  • sdkAddressBatch:SDK 地址批量验证(含 count12_three 新增用例)
  • sdkPubkeyBatch:SDK 公钥批量验证
  • securityCheck:盲签名安全检查
  • chainMethodBatch:链方法批量测试,含 bip39_import_12_api 场景

测试数据

  • 新增 count12_three 地址/公钥测试数据(addressTest + pubkeyTest),含 passphrase 变体
  • 更新 SLIP39 pubKeyData passphrase 变体数据(passphrase 统一为 12345,重新计算 expectedPublicKey)
  • 修复 polkadotGetAddress mock:改用手动 ledger 派生,正确支持 passphrase

UI

  • AutomationTest 页面重构为多面板布局:连接配置、场景选择、进度、报告树
  • 新增 ReportTree(suite → scenario → case 层级)、ProgressBar、ReportSummaryBar 等组件
  • 设备准备模式改为三态选择器(auto / create / import)
  • getFeatures 自动检测重置策略,移除手动 skipReset 模式

日志优化

  • webusb.ts:WebUSB DOMException 非枚举属性序列化为 {} 的问题,改为 name: message 格式
  • errors.tssafeThrowError 对未知错误不再把整个对象当 errorCode 传入

文档

  • automation-test-design.md:重写,反映当前实现架构
  • core-api-guide.md / search-devices.mdx:补充 connectId 格式说明(WebUSB vs BLE)

Test plan

  • expo-example 启动正常,AutomationTest 页面可访问
  • 设备连接后可正常执行 deviceFlow 套件(BIP39 create/import)
  • SDK 地址/公钥批量验证结果与预期数据一致
  • PhonePilot MCP health check 正常响应
  • lint CI 通过(0 errors)

🤖 Generated with Claude Code

@wabicai wabicai marked this pull request as draft March 9, 2026 08:29
@revan-zhang
Copy link
Copy Markdown
Contributor

revan-zhang commented Mar 9, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Mar 9, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​polkadot/​util-crypto@​13.1.1401008088100
Added@​babel/​plugin-proposal-object-rest-spread@​7.20.71001007550100
Added@​babel/​plugin-proposal-optional-chaining@​7.21.01001007450100
Added@​radix-ui/​react-separator@​1.1.71001006791100
Added@​tamagui/​babel-plugin@​1.90.2991006994100
Added@​radix-ui/​react-progress@​1.1.71001006991100
Added@​radix-ui/​react-slot@​1.2.31001006991100
Added@​nexajs/​script@​23.12.13751006982100
Added@​types/​bchaddrjs@​0.4.31001007079100
Added@​radix-ui/​react-checkbox@​1.3.2991007192100
Added@​babel/​preset-react@​7.22.151001007193100
Added@​radix-ui/​react-dropdown-menu@​2.1.15991007192100
Added@​radix-ui/​react-dialog@​1.1.14991007192100
Added@​tamagui/​toast@​1.90.2911007296100
Added@​radix-ui/​react-tooltip@​1.2.7991007292100
Added@​react-navigation/​bottom-tabs@​6.5.121001007397100
Added@​radix-ui/​react-toast@​1.2.14991007392100
Added@​babel/​preset-typescript@​7.23.31001007395100
Added@​types/​bytebuffer@​5.0.431001007377100
Added@​radix-ui/​react-scroll-area@​1.2.9991007391100
Added@​onekeyfe/​cross-inpage-provider-core@​0.0.17851007397100
Added@​react-navigation/​native-stack@​6.9.181001007399100
Added@​alephium/​web3-wallet@​1.5.280100739770
Added@​radix-ui/​react-select@​2.2.5981007492100
Added@​types/​bn.js@​5.1.51001007481100
Added@​nexajs/​address@​23.12.257510010082100
Added@​react-navigation/​native@​6.1.10991007599100
Added@​tamagui/​config@​1.90.2921007694100
Added@​onekeyfe/​react-native-ble-utils@​0.1.4771008084100
Added@​babel/​core@​7.23.9981008096100
Added@​ckb-lumos/​helpers@​0.23.08110010083100
Added@​ton/​core@​0.57.01001008292100
Added@​scure/​bip39@​1.3.010010010082100
See 19 more rows in the dashboard

View full report

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Mar 9, 2026

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm @polkadot/util-crypto is 91.0% likely obfuscated

Confidence: 0.91

Location: Package overview

From: packages/connect-examples/expo-example/package.jsonnpm/@polkadot/util-crypto@13.1.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@polkadot/util-crypto@13.1.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm @react-native/debugger-frontend is 96.0% likely obfuscated

Confidence: 0.96

Location: Package overview

From: ?npm/@react-native/debugger-frontend@0.73.3

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@react-native/debugger-frontend@0.73.3. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

wabicai and others added 17 commits March 12, 2026 22:32
…ified test runner

Refactor automation test from flat mnemonic groups to Jira-based scenario catalog
(OK-26053/26054/5504/40090) with BIP39 and SLIP39 create/import coverage.

- Add PhonePilot MCP client with arm control, OCR, sequence execution
- Add scenarioCatalog and scenarioResolver for test case resolution
- Support passphrase variants (normal/empty/passphrase_1/passphrase_2)
- Add test suites: deviceFlow, sdkAddressBatch, sdkPubkeyBatch
- Rebuild AutomationTestScreen with connection, config, progress, and report panels
- Update SLIP39 test data with unified id format and passphrase support
- Add count12_three address/pubkey test data with passphrase variants

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ssphrase suites

Replace 882-line AutomationTestScreen monolith with 20 focused components
in a two-column layout (live output panel + config sidebar). Add two new
test suite types: passphraseWalletSwitch (create N wallets, cycle switch,
verify address consistency) and specialPassphrase (9 edge-case passphrases
× 3 methods). Harden PhonePilotClient with fetch timeouts, scoped event
listeners, concurrent-run guard, and bounded log buffer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous two-column layout (StickyHeaderBar + LiveOutputPanel +
ConfigSidebar) was inconsistent with other pages and caused poor space
distribution. Switch to standard scrollable PageView with PanelView
cards matching the app's existing design pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…reviations

1. Fix PageView > DeviceProvider > HardwareInputPinDialogProvider nesting
   order to match all other screens (was reversed before).

2. Add [MISMATCH] logging with expected/actual values at all 6 address
   comparison points so failures are clearly visible in the run log.

3. Replace abbreviations: PP Switch → Passphrase Switch,
   Special PP → Special Passphrase, ppSwitchResult →
   passphraseWalletSwitchResult, SPECIAL_PP_METHOD_PATHS →
   SPECIAL_PASSPHRASE_METHOD_PATHS.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove the passphraseWalletSwitch suite entirely as it does not
correspond to any existing test case or Jira ticket. Cleaned up
from types, scenarioCatalog, useAutomationTest, and ScenarioSelector.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Resolved 6 conflicts favoring the onekey (main) branch:
- InitDurationTest: keep sdk.testInitializeDeviceDuration() call
- LockDeviceTest: keep params?.path direct access
- external-modules.d.ts: keep simplified module declarations
- nostrGetPublicKey/polkadotGetPublicKey: keep path: string | string[] type
- ExportDeviceInfo: keep one-line getFieldValue expression

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Redesign UI: two-column layout (config left, report+logs right), card-style
  checkboxes, collapsible scenario groups, tab-based report/logs toggle
- Add real-time per-case live report via liveReportAtom + effectiveReportAtom
- Fix passphrase bug: add ensurePassphraseState helper that toggles device
  passphrase_protection and obtains passphraseState before SDK calls,
  matching the pattern from SLIP39AddressValidation.tsx

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…lector

Add three device preparation modes (full/skipReset/sdkOnly) to give users
finer control over which steps to run during automation testing. The sdkOnly
mode skips PhonePilot entirely and runs SDK tests directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
skipReset only skips the factory-reset step. The wallet creation/import
via executeScenarioPreparation must still run, otherwise the device stays
uninitialized and SDK tests fail with Failure_NotInitialized.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ouble-buildSteps bug

- Redesign AutomationTest UI: balanced panel heights, hover styles, progress layout
- Add DevicePreparationMode 'deviceFlowOnly': runs reset+import/create only, skips all SDK suites
- Fix executeSequence.ts double buildSteps() call causing SLIP39 random share inconsistency
- Add DeviceCompatibility integration stub for Pro (dnxGetAddress)
- Fix canStartAutomationAtom to allow start when deviceFlowOnly with no testSuites selected
- Various UI component improvements: ReportTree filter, LogsSection, PassphraseSelector

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use atomWithStorage from jotai/utils so the test configuration
(scenarios, suites, passphrases, URL, mode, etc.) survives page refreshes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ized)

- executeResetPreparation now takes device features instead of scenarioIndex
- Uses features.unlocked to pick reset-wallet-locked vs reset-wallet-unlocked
- Uses features.initialized to auto-detect factory-reset state and skip reset
  (replaces scenarioIndex===0 heuristic and supplements user skipReset config)
- Logs device state (initialized/unlocked) before each scenario for debugging

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
index.tsx: change XStack alignItems to stretch so both columns have equal
card border height; use fixed height={680} on both ScrollViews instead of
maxHeight="80vh" for consistent sizing.

LogsSection.tsx: replace minHeight/maxHeight with height={650} so the log
TextArea fills the parent 680px scroll container instead of stopping at 400px.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… theme override

Tamagui Button has a built-in theme hover that changes the background
color. Setting hoverStyle={} or omitting backgroundColor lets the theme
win and produces wrong hover visuals. Fix: always include backgroundColor
matching the button's current state in both hoverStyle and pressStyle.

- index.tsx: 开始 (green9/gray5) and 停止 (red9/gray5) buttons
- ConnectionConfig.tsx: 连接/断开 button (blue9/red9)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ash, fix button hover

- types.ts: remove 'skipReset' DevicePreparationMode — reset strategy is
  now auto-detected via getFeatures().initialized; update 'full' description

- useAutomationTest.ts: replace deviceFeatures! non-null assertion with an
  explicit guard that throws a clear error when fetchDeviceFeatures returns
  undefined; remove now-dead skipReset branch from shouldSkipReset condition

- index.tsx + ConnectionConfig.tsx: include backgroundColor in hoverStyle
  and pressStyle to prevent Tamagui theme from overriding custom colors on
  hover/press (fixes flat gray appearance on hover)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Integrates the existing BlindSignatureChainCheck test into the automation
test runner as a new TestSuiteType 'securityCheck'.

- types.ts: add 'securityCheck' to TestSuiteType and TEST_SUITE_INFO
- scenarioCatalog.ts: append 'securityCheck' to all four suite arrays
  (BIP39 create/import, SLIP39 create/import) — test only needs any
  valid wallet, not a specific mnemonic
- useAutomationTest.ts:
  - import convertTestData/getDeviceExpected/securityCheckData
  - add runSecurityCheckSuite callback: disables passphrase_protection,
    sets safetyChecks=0 (strict), runs all 28-method × 2-coinType cases,
    45s timeout per call, device-compat overrides via compatibilityManager
  - wire into runSelectedSdkSuites after specialPassphrase

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add chainMethodBatch TestSuiteType with 5-chain × method × presuppose coverage
- Add bip39_import_12_api scenario (API mnemonic, api-normal-12 sequence)
- Implement runChainMethodBatchSuite in useAutomationTest
- Wire chainMethodBatch into runSelectedSdkSuites after securityCheck
- Add securityCheck + chainMethodBatch to SUITE_EXECUTION_ORDER so buildSelectedSuites includes them
- Update countScenarioTotalTests and getSuiteName for new suite types

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wabicai wabicai marked this pull request as ready for review March 19, 2026 09:37
wabicai and others added 6 commits March 19, 2026 17:39
…tion

Update suite types, scenario matrix, DevicePreparationMode, and data
resolution strategy to match current codebase state.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sted-ternary)

- Fix prettier formatting in automationAtoms, Page, phonePilotMcp, AutomationTest components
- Fix double quotes → single quotes in slip39Test data files
- Fix no-restricted-exports: replace `export { default }` with `import/export default` in count12_three files
- Fix no-nested-ternary in ReportCaseRow
- Fix AlephiumSignTransaction import format
- Fix webusb/errors/DeviceConnector logging to properly display DOMException

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…devices

Add per-platform connectId format reference:
- WebUSB/Bridge: device serial (e.g. PRC10J0017A)
- Android BLE: MAC address
- iOS BLE: CoreBluetooth UUID
- Desktop BLE macOS (Noble): 32-char hex UUID
- Desktop BLE Windows (Noble): 12-char lowercase hex MAC without colons
- Desktop BLE Linux (Noble): MAC address

Add warning that USB and BLE connectIds for the same device are different
values and must be stored separately when both transports are supported.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Revert AlephiumSignTransaction.ts to original (no unintended change)
- Revert noble-ble-handler.ts to original (belongs in a separate PR)
- Revert DeviceConnector.ts to original (belongs in a separate PR)
- Fix slip39Utils.ts import/order warning (remove empty line within import group)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wabicai wabicai changed the title feat: initialize expo-example automation test feat: expo-example automation test framework Mar 20, 2026
wabicai and others added 5 commits March 20, 2026 15:21
…ethodBatch suites

- Add slideConfirm() to PhonePilotClient for left-to-right swipe gesture
- Add confirmCount/noSlide metadata to security check test data (34 methods calibrated)
- Fix expected values: confluxSignMessage 503→false, revert conflux/xrp tx to true
- Add alephiumSignMessage noSlide: true (missed in initial pass)
- Add ChainMethodEntry type with confirmCount/noSlide for chain method data
- Update btc/eth/ada/sol/dot data files with signing confirmation metadata
- setupUIListener now accepts optional buttonOverride for per-suite button handling
- runSecurityCheckSuite: safetyChecks disable→slide, per-case [confirm×N + slide/noSlide]
- runChainMethodBatchSuite: same mechanism, driven by ChainMethodEntry metadata
- Restrict securityCheck/chainMethodBatch to bip39_import_12_api scenario only
- Remove securityCheck from BIP39/SLIP39 create/import suite lists

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace all registry.npmjs.org URLs back to registry.yarnpkg.com

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wabicai
Copy link
Copy Markdown
Member Author

wabicai commented Mar 20, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea480fc65e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wabicai wabicai merged commit e7bb4ab into onekey Mar 20, 2026
9 checks passed
@wabicai wabicai deleted the feature/automation-test branch March 20, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants