Skip to content

Commit

Permalink
Merge pull request #713 from juanky201271/dev_ci_e2e_tests_fixing
Browse files Browse the repository at this point in the history
CI e2e tests
  • Loading branch information
juanky201271 authored Oct 1, 2024
2 parents 53e20e8 + 065fb95 commit 647ac7c
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ jobs:
needs: android-ubuntu-integration-test-actions-avd-cache
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
test: ["offline_testsuite", "execute_sync_from_seed", "execute_send_from_orchard", "execute_currentprice_and_value_transfers_from_seed", "execute_sapling_balance_from_seed"]
env:
Expand Down
1 change: 1 addition & 0 deletions __tests__/__snapshots__/SyncReport.snapshot.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ exports[`Component SyncReport - test SyncReport - snapshot 1`] = `
"maxHeight": "85%",
}
}
testID="syncreport.scroll-view"
>
<View>
<View
Expand Down
4 changes: 2 additions & 2 deletions app/LoadingApp/LoadingApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ export class LoadingAppClass extends Component<LoadingAppClassProps, LoadingAppC
type: state.type,
isConnectionExpensive: state.details && state.details.isConnectionExpensive,
},
screen: screen !== 0 ? 1 : 0,
screen: screen === 3 ? 3 : screen !== 0 ? 1 : 0,
actionButtonsDisabled: true,
});
if (isConnected !== state.isConnected) {
Expand Down Expand Up @@ -1316,7 +1316,7 @@ export class LoadingAppClass extends Component<LoadingAppClassProps, LoadingAppC
{netInfo.isConnected && (
<View style={{ marginTop: 20, display: 'flex', alignItems: 'center' }}>
<Button
testID="loadingapp.restorewalletseed"
testID="loadingapp.restorewalletseedufvk"
type={ButtonTypeEnum.Secondary}
title={translate('loadingapp.restorewalletseedufvk') as string}
disabled={actionButtonsDisabled}
Expand Down
3 changes: 2 additions & 1 deletion components/SyncReport/SyncReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ const SyncReport: React.FunctionComponent<SyncReportProps> = ({ closeModal }) =>
/>

<ScrollView
testID="syncreport.scroll-view"
style={{ maxHeight: '85%' }}
contentContainerStyle={{
flexDirection: 'column',
Expand Down Expand Up @@ -444,7 +445,7 @@ const SyncReport: React.FunctionComponent<SyncReportProps> = ({ closeModal }) =>
margin: 5,
}}
/>
<Text style={{ color: colors.text }}>
<Text testID="syncreport.wallettotalblocks" style={{ color: colors.text }}>
{serverWallet + (translate('report.blocks') as string)}
</Text>
</View>
Expand Down
2 changes: 1 addition & 1 deletion e2e/change_custom_regtest_server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

describe('Change the Server.', () => {
// i just pulled this seed out of thin air
it('loads a wallet', loadTestWallet);
it('loads a wallet', async () => await loadTestWallet());
it('Go settings & change to a correct Testnet server URI.', async () => {
//await sleep(4000);

Expand Down
8 changes: 4 additions & 4 deletions e2e/change_custom_server.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { log, by, element } = require('detox');
const { log, by, element, fail } = require('detox');

import { loadTestWallet } from "./e2e-utils/loadTestWallet.js";

const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

describe('Change the Server.', () => {
// i just pulled this seed out of thin air
it('loads a wallet', loadTestWallet);
it('loads a wallet', async () => await loadTestWallet());
it('Go settings & change to a correct Mainnet server URI.', async () => {
//await sleep(4000);

Expand All @@ -28,7 +28,7 @@ describe('Change the Server.', () => {
// waiting for the custom server field
await waitFor(element(by.id('settings.custom-server-field'))).toBeVisible()
.whileElement(by.id('settings.scroll-view')).scroll(100, 'down');
await element(by.id("settings.custom-server-field")).replaceText('https://lwd1.zcash-infra.com:9067');
await element(by.id("settings.custom-server-field")).replaceText('https://lwd2.zcash-infra.com:9067');

// waiting for the toggle, tap on mainnet
await waitFor(element(by.id('settings.custom-server-chain.mainnet'))).toBeVisible()
Expand Down Expand Up @@ -65,7 +65,7 @@ describe('Change the Server.', () => {

// the 2 blocks have to be greater then the 1 blocks
if (!(blockssyncednowNum_2 > blockssyncednowNum_1)) {
fail('The sync process is not progressing.');
throw new Error('The sync process is not progressing.');
}
});
});
2 changes: 1 addition & 1 deletion e2e/change_custom_testnet_server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

describe('Change the Server.', () => {
// i just pulled this seed out of thin air
it('loads a wallet', loadTestWallet);
it('loads a wallet', async () => await loadTestWallet());
it('Go settings & change to a correct Testnet server URI.', async () => {
//await sleep(4000);

Expand Down
8 changes: 4 additions & 4 deletions e2e/change_server_from_list.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { log, by, element } = require('detox');
const { log, by, element, fail } = require('detox');

import { loadTestWallet } from "./e2e-utils/loadTestWallet.js";

const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

describe('Change the Server from the list.', () => {
// i just pulled this seed out of thin air
it('loads a wallet', loadTestWallet);
it('loads a wallet', async () => await loadTestWallet());
it('Go settings & change to an existent server in the list.', async () => {
//await sleep(4000);

Expand Down Expand Up @@ -48,7 +48,7 @@ describe('Change the Server from the list.', () => {
log.info('blocks 1:', blockssyncednowNum_1);

// wait a little bit
await sleep(25000);
await sleep(40000);

// getting blocks now synced from the screen
const blockssyncednow_2 = element(by.id('syncreport.syncednow'));
Expand All @@ -59,7 +59,7 @@ describe('Change the Server from the list.', () => {

// the 2 blocks have to be greater then the 1 blocks
if (!(blockssyncednowNum_2 > blockssyncednowNum_1)) {
fail('The sync process is not progressing.');
throw new Error('The sync process is not progressing.');
}
});
});
2 changes: 1 addition & 1 deletion e2e/darkside_simple_sync.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { loadDarksideWallet } from "./e2e-utils/loadDarksideWallet.js";
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

describe('Syncs a darkside chain', () => {
it('loads the wallet', loadDarksideWallet);
it('loads the wallet', async () => await loadDarksideWallet());
it('should sync the darkside chain', async () => {
// wait for fully synced.
//await sleep(4000);
Expand Down
18 changes: 9 additions & 9 deletions e2e/e2e-utils/loadDarksideWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

let loadDarksideWallet = async () => {
await sleep(5000);
await sleep(2000);

// the start always is like a fress install -> create a new wallet
// go to setting modal screen
Expand Down Expand Up @@ -55,16 +55,16 @@ let loadDarksideWallet = async () => {
await element(by.text('CONFIRM')).tap();

// restore from seed
await waitFor(element(by.id('loadingapp.restorewalletseed'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("loadingapp.restorewalletseed")).tap();
await waitFor(element(by.id('seed.seedinput'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("seed.seedinput")).replaceText(
await waitFor(element(by.id('loadingapp.restorewalletseedufvk'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("loadingapp.restorewalletseedufvk")).tap();
await waitFor(element(by.id('import.seedufvkinput'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("import.seedufvkinput")).replaceText(
'still champion voice habit trend flight survey between bitter process artefact blind carbon truly provide dizzy crush flush breeze blouse charge solid fish spread'
);
await waitFor(element(by.id('seed.birthdayinput'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("seed.birthdayinput")).replaceText('0');
await waitFor(element(by.id('seed.button.ok'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id('seed.button.ok')).tap();
await waitFor(element(by.id('import.birthdayinput'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("import.birthdayinput")).replaceText('0');
await waitFor(element(by.id('import.button.ok'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id('import.button.ok')).tap();
}

export { loadDarksideWallet };
19 changes: 9 additions & 10 deletions e2e/e2e-utils/loadRecipientWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

let loadRecipientWallet = async () => {
await sleep(5000);
await sleep(2000);

// the start always is like a fress install -> create a new wallet
// go to setting modal screen
Expand Down Expand Up @@ -54,18 +54,17 @@ let loadRecipientWallet = async () => {
await waitFor(element(by.text('CONFIRM'))).toBeVisible().withTimeout(sync_timeout);
await element(by.text('CONFIRM')).tap();


// restore from seed
await waitFor(element(by.id('loadingapp.restorewalletseed'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("loadingapp.restorewalletseed")).tap();
await waitFor(element(by.id('seed.seedinput'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("seed.seedinput")).replaceText(
await waitFor(element(by.id('loadingapp.restorewalletseedufvk'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("loadingapp.restorewalletseedufvk")).tap();
await waitFor(element(by.id('import.seedufvkinput'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("import.seedufvkinput")).replaceText(
'hospital museum valve antique skate museum unfold vocal weird milk scale social vessel identify crowd hospital control album rib bulb path oven civil tank'
);
await waitFor(element(by.id('seed.birthdayinput'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("seed.birthdayinput")).replaceText('1994579');
await waitFor(element(by.id('seed.button.ok'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id('seed.button.ok')).tap();
await waitFor(element(by.id('import.birthdayinput'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id("import.birthdayinput")).replaceText('1994579');
await waitFor(element(by.id('import.button.ok'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id('import.button.ok')).tap();
}

export { loadRecipientWallet };
2 changes: 1 addition & 1 deletion e2e/e2e-utils/loadTestWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

let loadTestWallet = async () => {
// waiting while app is detecting the best server
await sleep(5000);
await sleep(2000);

// the start always is like a fresh install -> create a new wallet
// go to setting modal screen
Expand Down
2 changes: 1 addition & 1 deletion e2e/reload_while_tx_pending.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { loadRecipientWallet } from "./e2e-utils/loadRecipientWallet.js";
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

describe('Maintains correct information while tx pending', () => {
it('loads the wallet', loadRecipientWallet);
it('loads the wallet', async () => await loadRecipientWallet());
it('should send from orchard to sapling pool', async () => {
// wait for fully synced.
//await sleep(4000);
Expand Down
12 changes: 6 additions & 6 deletions e2e/screen_awake.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { log, device, by, element } = require('detox');
const { log, device, by, element, fail } = require('detox');
const { spawnSync, execSync } = require('child_process');

import { loadTestWallet } from "./e2e-utils/loadTestWallet.js";
Expand All @@ -7,7 +7,7 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

describe('Kepp the screen awake while syncing.', () => {
// i just pulled this seed out of thin air
it('loads a wallet', loadTestWallet);
it('loads a wallet', async () => await loadTestWallet());
it('When App is syncing -> The screen have to be awake all the time', async () => {
//await sleep(4000);

Expand All @@ -18,7 +18,7 @@ describe('Kepp the screen awake while syncing.', () => {
const resultSet = spawnSync('adb', ['-e', 'shell', 'settings', 'put', 'system', 'screen_off_timeout', '10000']);

if (resultSet.status !== 0) {
fail(`Failed to execute SET command: ${resultSet.stderr}`);
throw new Error(`Failed to execute SET command: ${resultSet.stderr}`);
}

// put the App to sleep because we need some progress in the syncing for 20 seconds
Expand All @@ -30,21 +30,21 @@ describe('Kepp the screen awake while syncing.', () => {

if (Number(t.toString().trim()) !== 10000) {
spawnSync('adb', ['-e', 'shell', 'settings', 'put', 'system', 'screen_off_timeout', currentValue]);
fail('setting screen off timeout is not working, it is not 10000 (10 s.)');
throw new Error('setting screen off timeout is not working, it is not 10000 (10 s.)');
}

const resultGet = spawnSync('adb', ['-e', 'shell', 'dumpsys', 'power']);

if (resultGet.status !== 0) {
spawnSync('adb', ['-e', 'shell', 'settings', 'put', 'system', 'screen_off_timeout', currentValue]);
fail(`Failed to execute DUMPSYS POWER command: ${resultGet.stderr}`);
throw new Error(`Failed to execute DUMPSYS POWER command: ${resultGet.stderr}`);
}
const output = resultGet.stdout.toString();
const isScreenAwake = output.includes('mWakefulness=Awake');

if (!isScreenAwake) {
spawnSync('adb', ['-e', 'shell', 'settings', 'put', 'system', 'screen_off_timeout', currentValue]);
fail('After 20 seconds (screen off timeout 10s) the screen is not awake.');
throw new Error('After 20 seconds (screen off timeout 10s) the screen is not awake.');
}
const r = spawnSync('adb', ['-e', 'shell', 'settings', 'put', 'system', 'screen_off_timeout', currentValue]);
log.info(r);
Expand Down
10 changes: 6 additions & 4 deletions e2e/send.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
const { log, device, by, element, expect } = require('detox');

import { loadTestWallet } from './e2e-utils/loadTestWallet.js';
import { loadRecipientWallet } from './e2e-utils/loadRecipientWallet.js';

const sleep = ms => new Promise(r => setTimeout(r, ms));

describe('Renders wallet data correctly.', () => {
// i just pulled this seed out of thin air
it('loads a wallet', loadTestWallet);
it('loads a wallet', async () => await loadRecipientWallet());
it('adds return address to the memo if that option is selected, and correctly renders confirm screen', async () => {
await element(by.text('SEND')).tap();

await element(by.id('send.addressplaceholder')).replaceText(
'u1lx7nlnqqqs7p4hcqz4hyjgnw7h8zskcgr2f8dfhm96np0gnfdzu7jtms7q2pxd7ufy96wxzdsdy65jvp3td7fj2ltcz0jpak86ddyszl9ykn5s86q3xataya5867z3tj2x8cw0ljyrenymr2gcqmjf50gmexqj233yn3kdaxn2yukwcx87emurufakf82wapgnu5h3fvae6aw9uus2r',
);
await element(by.id('send.amount')).replaceText('0');
//await element(by.id('send.amount')).replaceText('0');
//await element(by.id('send.scroll-view')).scrollTo('bottom');
await waitFor(element(by.id('send.checkboxua'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id('send.checkboxua')).tap();
await element(by.id('send.scroll-view')).scrollTo('bottom');
await element(by.id('send.memo-field')).replaceText('1\n2\n3\n4\n5\n6\n7\n8');
await element(by.id('send.scroll-view')).scrollTo('bottom');

await waitFor(element(by.id('send.button'))).toBeVisible();
await waitFor(element(by.id('send.button'))).toBeVisible().withTimeout(sync_timeout);
await element(by.id('send.button')).tap();

await expect(element(by.id('send.confirm.scroll-view'))).toExist();
Expand Down
Loading

0 comments on commit 647ac7c

Please sign in to comment.