Skip to content

Commit 4a03590

Browse files
committed
wip
1 parent 2187dc0 commit 4a03590

File tree

4 files changed

+119
-2
lines changed

4 files changed

+119
-2
lines changed

Diff for: suite-native/app/.detoxrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module.exports = {
4343
emulator: {
4444
type: 'android.emulator',
4545
device: {
46-
avdName: 'Pixel_3a_API_31',
46+
avdName: 'Pixel_6_API_33',
4747
},
4848
},
4949
},

Diff for: suite-native/app/e2e/tests/deeplinkPopup.test.ts

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import { exec } from 'child_process';
2+
// `expect` keyword is already used by jest.
3+
import { expect as detoxExpect } from 'detox';
4+
5+
import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link';
6+
import TrezorConnect from '@trezor/connect-deeplink';
7+
8+
import { openApp } from '../utils';
9+
import { onOnboarding } from '../pageObjects/onboardingActions';
10+
import { onCoinEnablingInit } from '../pageObjects/coinEnablingActions';
11+
12+
const TREZOR_DEVICE_LABEL = 'Trezor T - Tester';
13+
// Contains only one BTC account with a single transaction to make the discovery as fast as possible.
14+
const SIMPLE_SEED = 'immune enlist rule measure fan swarm mandate track point menu security fan';
15+
const platform = device.getPlatform();
16+
17+
function openUriScheme(url, platform) {
18+
const command = `npx uri-scheme open '${url.replace(/'/g, '')}' --${platform}`;
19+
20+
exec(command, (err, stdout, stderr) => {
21+
if (err) {
22+
console.error('Error:');
23+
console.error(err);
24+
console.error();
25+
return;
26+
}
27+
console.log(stdout);
28+
console.error(stderr);
29+
});
30+
}
31+
32+
describe('Deeplink connect popup.', () => {
33+
beforeAll(async () => {
34+
if (platform === 'android') {
35+
// Prepare Trezor device for test scenario and turn it off.
36+
await TrezorUserEnvLink.disconnect();
37+
await TrezorUserEnvLink.connect();
38+
await TrezorUserEnvLink.startEmu({ wipe: true });
39+
await TrezorUserEnvLink.setupEmu({
40+
label: TREZOR_DEVICE_LABEL,
41+
mnemonic: SIMPLE_SEED,
42+
});
43+
await TrezorUserEnvLink.startBridge();
44+
await TrezorUserEnvLink.stopEmu();
45+
}
46+
47+
await openApp({ newInstance: true });
48+
49+
await TrezorConnect.init({
50+
manifest: {
51+
52+
appUrl: 'http://your.application.com',
53+
},
54+
deeplinkOpen: url => {
55+
// eslint-disable-next-line no-console
56+
console.log('deeplinkOpen', url);
57+
openUriScheme(url, 'android');
58+
},
59+
deeplinkCallbackUrl: 'https://test.com/connect',
60+
// deeplinkUrl: 'https://dev.suite.sldev.cz/connect/develop/deeplink/',
61+
});
62+
});
63+
64+
afterAll(async () => {
65+
if (platform === 'android') {
66+
await TrezorUserEnvLink.stopEmu();
67+
}
68+
await device.terminateApp();
69+
});
70+
71+
it('Navigate to dashboard', async () => {
72+
await onOnboarding.finishOnboarding();
73+
console.log('after onboarding');
74+
75+
if (platform === 'android') {
76+
console.log('platform is android');
77+
await TrezorUserEnvLink.startEmu();
78+
79+
await waitFor(element(by.id('@screen/CoinEnablingInit')))
80+
.toBeVisible()
81+
.withTimeout(10000);
82+
83+
console.log('before waitForBtcToBeVisible');
84+
await onCoinEnablingInit.waitForBtcToBeVisible();
85+
86+
console.log('before enableNetwork');
87+
await onCoinEnablingInit.enableNetwork('btc');
88+
// TODO: I don't understand why without eth the part after does not complete.
89+
await onCoinEnablingInit.enableNetwork('eth');
90+
91+
console.log('before onCoinEnablingInit.save');
92+
await onCoinEnablingInit.save();
93+
94+
console.log('before waitFor skip-view-only-mode');
95+
await waitFor(element(by.id('skip-view-only-mode')))
96+
.toBeVisible()
97+
.withTimeout(60000); // communication between connected Trezor and app takes some time.
98+
99+
console.log('before skip-view-only-mode tap()');
100+
await element(by.id('skip-view-only-mode')).tap();
101+
102+
console.log('before @home/portfolio/graph');
103+
await detoxExpect(element(by.id('@home/portfolio/graph'))); // discovery finished and graph is visible
104+
105+
// TODO: At this point we should be able to call a TrezorConnect from the deeplink package,
106+
// TODO: and check that the app opens it!!
107+
const response = await TrezorConnect.getAddress({
108+
path: "m/49'/0'/0'/0/0",
109+
coin: 'btc',
110+
});
111+
112+
console.log('response', response);
113+
}
114+
});
115+
});

Diff for: suite-native/app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"@suite-native/toasts": "workspace:*",
7777
"@suite-native/transactions": "workspace:*",
7878
"@trezor/connect": "workspace:*",
79+
"@trezor/connect-deeplink": "workspace:^",
7980
"@trezor/react-native-usb": "workspace:*",
8081
"@trezor/styles": "workspace:*",
8182
"@trezor/theme": "workspace:*",

Diff for: yarn.lock

+2-1
Original file line numberDiff line numberDiff line change
@@ -9598,6 +9598,7 @@ __metadata:
95989598
"@suite-native/toasts": "workspace:*"
95999599
"@suite-native/transactions": "workspace:*"
96009600
"@trezor/connect": "workspace:*"
9601+
"@trezor/connect-deeplink": "workspace:^"
96019602
"@trezor/react-native-usb": "workspace:*"
96029603
"@trezor/styles": "workspace:*"
96039604
"@trezor/theme": "workspace:*"
@@ -11235,7 +11236,7 @@ __metadata:
1123511236
languageName: unknown
1123611237
linkType: soft
1123711238

11238-
"@trezor/connect-deeplink@workspace:*, @trezor/connect-deeplink@workspace:packages/connect-deeplink":
11239+
"@trezor/connect-deeplink@workspace:*, @trezor/connect-deeplink@workspace:^, @trezor/connect-deeplink@workspace:packages/connect-deeplink":
1123911240
version: 0.0.0-use.local
1124011241
resolution: "@trezor/connect-deeplink@workspace:packages/connect-deeplink"
1124111242
dependencies:

0 commit comments

Comments
 (0)