-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
122 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { exec } from 'child_process'; | ||
// `expect` keyword is already used by jest. | ||
import { expect as detoxExpect } from 'detox'; | ||
|
||
import { TrezorUserEnvLink } from '@trezor/trezor-user-env-link'; | ||
import TrezorConnect from '@trezor/connect-deeplink'; | ||
|
||
import { openApp } from '../utils'; | ||
import { onOnboarding } from '../pageObjects/onboardingActions'; | ||
import { onCoinEnablingInit } from '../pageObjects/coinEnablingActions'; | ||
|
||
const TREZOR_DEVICE_LABEL = 'Trezor T - Tester'; | ||
// Contains only one BTC account with a single transaction to make the discovery as fast as possible. | ||
const SIMPLE_SEED = 'immune enlist rule measure fan swarm mandate track point menu security fan'; | ||
const platform = device.getPlatform(); | ||
|
||
function openUriScheme(url, platform) { | ||
// Construct the command dynamically using double quotes | ||
const command = `npx uri-scheme open '${url.replace(/'/g, '')}' --${platform}`; | ||
|
||
exec(command, (err, stdout, stderr) => { | ||
if (err) { | ||
console.error('Error:'); | ||
console.error(err); | ||
console.error(); | ||
return; // Exit the function if there's an error | ||
} | ||
console.log(stdout); | ||
console.error(stderr); | ||
}); | ||
} | ||
|
||
describe('Deeplink connect popup.', () => { | ||
beforeAll(async () => { | ||
if (platform === 'android') { | ||
// Prepare Trezor device for test scenario and turn it off. | ||
await TrezorUserEnvLink.disconnect(); | ||
await TrezorUserEnvLink.connect(); | ||
await TrezorUserEnvLink.startEmu({ wipe: true }); | ||
await TrezorUserEnvLink.setupEmu({ | ||
label: TREZOR_DEVICE_LABEL, | ||
mnemonic: SIMPLE_SEED, | ||
}); | ||
await TrezorUserEnvLink.startBridge(); | ||
await TrezorUserEnvLink.stopEmu(); | ||
} | ||
|
||
await openApp({ newInstance: true }); | ||
|
||
await TrezorConnect.init({ | ||
manifest: { | ||
email: '[email protected]', | ||
appUrl: 'http://your.application.com', | ||
}, | ||
deeplinkOpen: url => { | ||
// eslint-disable-next-line no-console | ||
console.log('deeplinkOpen', url); | ||
openUriScheme(url, 'android'); | ||
|
||
// Android.openAsync({ uri: url }); | ||
}, | ||
deeplinkCallbackUrl: 'https://test.com/connect', | ||
// deeplinkUrl: 'https://dev.suite.sldev.cz/connect/develop/deeplink/', | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
if (platform === 'android') { | ||
await TrezorUserEnvLink.stopEmu(); | ||
} | ||
await device.terminateApp(); | ||
}); | ||
|
||
it('Navigate to dashboard', async () => { | ||
await onOnboarding.finishOnboarding(); | ||
console.log('after onboarding'); | ||
|
||
if (platform === 'android') { | ||
console.log('platform is android'); | ||
await TrezorUserEnvLink.startEmu(); | ||
|
||
await waitFor(element(by.id('@screen/CoinEnablingInit'))) | ||
.toBeVisible() | ||
.withTimeout(10000); | ||
|
||
console.log('before waitForBtcToBeVisible'); | ||
await onCoinEnablingInit.waitForBtcToBeVisible(); | ||
|
||
console.log('before enableNetwork'); | ||
await onCoinEnablingInit.enableNetwork('btc'); | ||
// TODO: I don't understand why without eth the part after does not complete. | ||
await onCoinEnablingInit.enableNetwork('eth'); | ||
|
||
console.log('before onCoinEnablingInit.save'); | ||
await onCoinEnablingInit.save(); | ||
|
||
console.log('before waitFor skip-view-only-mode'); | ||
await waitFor(element(by.id('skip-view-only-mode'))) | ||
.toBeVisible() | ||
.withTimeout(60000); // communication between connected Trezor and app takes some time. | ||
|
||
console.log('before skip-view-only-mode tap()'); | ||
await element(by.id('skip-view-only-mode')).tap(); | ||
|
||
console.log('before @home/portfolio/graph'); | ||
await detoxExpect(element(by.id('@home/portfolio/graph'))); // discovery finished and graph is visible | ||
|
||
// TODO: At this point we should be able to call a TrezorConnect from the deeplink package, | ||
// TODO: and check that the app opens it!! | ||
const response = await TrezorConnect.getAddress({ | ||
path: "m/49'/0'/0'/0/0", | ||
coin: 'btc', | ||
}); | ||
|
||
console.log('response', response); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters