Skip to content

Commit 0354c63

Browse files
committed
initial migration test
1 parent f833209 commit 0354c63

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

test/helpers/setup.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { execSync } from 'node:child_process';
2+
import fs from 'node:fs';
3+
import path from 'node:path';
24
import { sleep } from './actions';
35
import { getAppId, getAppPath } from './constants';
46

@@ -24,6 +26,36 @@ export async function reinstallApp() {
2426
await driver.activateApp(appId);
2527
}
2628

29+
export function getRnAppPath(): string {
30+
const fallback = path.join(__dirname, '..', '..', 'aut', 'bitkit_rn_regtest.apk');
31+
const appPath = process.env.RN_APK_PATH ?? fallback;
32+
if (!fs.existsSync(appPath)) {
33+
throw new Error(
34+
`RN APK not found at: ${appPath}. Set RN_APK_PATH or place it at ${fallback}`
35+
);
36+
}
37+
return appPath;
38+
}
39+
40+
export function getNativeAppPath(): string {
41+
const fallback = path.join(__dirname, '..', '..', 'aut', 'bitkit_e2e.apk');
42+
const appPath = process.env.NATIVE_APK_PATH ?? fallback;
43+
if (!fs.existsSync(appPath)) {
44+
throw new Error(
45+
`Native APK not found at: ${appPath}. Set NATIVE_APK_PATH or place it at ${fallback}`
46+
);
47+
}
48+
return appPath;
49+
}
50+
51+
export async function reinstallAppFromPath(appPath: string, appId: string = getAppId()) {
52+
console.info(`→ Reinstalling app from: ${appPath}`);
53+
await driver.removeApp(appId);
54+
resetBootedIOSKeychain();
55+
await driver.installApp(appPath);
56+
await driver.activateApp(appId);
57+
}
58+
2759
/**
2860
* Resets iOS simulator to remove stored data between app reinstall cycles.
2961
* (Wallet data is stored in iOS Keychain and persists even after app uninstall

test/specs/migration.e2e.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { elementById, restoreWallet, sleep, tap, typeText, waitForSetupWalletScreenFinish } from '../helpers/actions';
2+
import { ciIt } from '../helpers/suite';
3+
import { getNativeAppPath, getRnAppPath, reinstallAppFromPath } from '../helpers/setup';
4+
5+
const MIGRATION_MNEMONIC =
6+
process.env.MIGRATION_MNEMONIC ??
7+
'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
8+
9+
describe('@migration - Legacy RN migration', () => {
10+
ciIt('@migration_1 - Can restore legacy RN wallet from mnemonic', async () => {
11+
await installLegacyRnApp();
12+
await restoreLegacyRnWallet(MIGRATION_MNEMONIC);
13+
14+
// Restore into native app
15+
// await installNativeApp();
16+
await restoreWallet(MIGRATION_MNEMONIC);
17+
});
18+
});
19+
20+
async function installNativeApp() {
21+
await reinstallAppFromPath(getNativeAppPath());
22+
}
23+
async function installLegacyRnApp() {
24+
await reinstallAppFromPath(getRnAppPath());
25+
}
26+
27+
async function restoreLegacyRnWallet(seed: string) {
28+
await elementById('Continue').waitForDisplayed();
29+
await tap('Check1');
30+
await tap('Check2');
31+
await tap('Continue');
32+
33+
await tap('SkipIntro');
34+
35+
await tap('RestoreWallet');
36+
await tap('MultipleDevices-button');
37+
38+
await typeText('Word-0', seed);
39+
await sleep(1500);
40+
await tap('RestoreButton');
41+
await waitForSetupWalletScreenFinish();
42+
43+
const getStarted = await elementById('GetStartedButton');
44+
await getStarted.waitForDisplayed( { timeout: 120000 });
45+
await tap('GetStartedButton');
46+
await sleep(1000);
47+
}

0 commit comments

Comments
 (0)