MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.04k stars 1.06k forks source link

E2E test support for HW wallet support -> implementation (Ledger) #9544

Open angelcheung22 opened 2 months ago

angelcheung22 commented 2 months ago

Add validation for the Ledger and HW wallet support in mobile (and extension) within the E2E tests? In the past we've discussed the potential of using software emulators (existing or custom) to mock the responses from the device as needed at the URL or library level.

We can try mock @ledgerhq/react-native-hw-transport-ble to bypass the bluetooth communication. and then we can try to see how to do it in e2e tests. the only downside is if library upgrade, we may need to change the mock again to refect the library API change.

angelcheung22 commented 3 weeks ago

Pretty stuck as the mocking failed. and MM QA team has a meeting on 20 June to discuss overall QA strategy, so put on hold

Akaryatrh commented 1 week ago

Quick statement on our findings:

But when doing so, we're facing an error with module loading.

I have setup a branch to test mocking strategy here: https://github.com/MetaMask/metamask-mobile/tree/feat/e2e-ledger

Instructions:

If you have the same issue as me, you'll see that app is crashing :confused:

Capture d’écran 2024-06-10 à 14.55.44 (1).png

How mocks are working: Basically It's needed to duplicate a file and add the mock.ts extension instead of .ts beside the original file. Then metro builder should take the mock file instead. Related logic based on env variable IS_TEST can be seen inside metro.config.js Some hooks have been mocked just to test if mocking strategy was working. But at the end we would like to mock the bluetooth library only (potentially react-native-ble-plx or lower)