From a0761d3257fa8cb89810ca60fa47c7577db19529 Mon Sep 17 00:00:00 2001 From: dariovp Date: Wed, 16 Oct 2024 17:06:24 -0300 Subject: [PATCH 1/3] test: add parse for invalid address --- components/Components/ErrorText.tsx | 9 +++++++-- components/Send/Send.tsx | 4 +++- e2e/send.test.js | 20 ++++++++++++++++---- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/components/Components/ErrorText.tsx b/components/Components/ErrorText.tsx index 1b36a742b..b0c1def97 100644 --- a/components/Components/ErrorText.tsx +++ b/components/Components/ErrorText.tsx @@ -6,12 +6,17 @@ import { ThemeType } from '../../app/types/ThemeType'; type ErrorTextProps = { style?: TextStyle; children: string; + testID?: string; }; -const ErrorText: React.FunctionComponent = ({ style, children }) => { +const ErrorText: React.FunctionComponent = ({ style, children, testID }) => { const { colors } = useTheme() as unknown as ThemeType; - return {children}; + return ( + + {children} + + ); }; export default ErrorText; diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index 77e07c44a..7528fe97c 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -1001,7 +1001,9 @@ const Send: React.FunctionComponent = ({ )} - {validAddress === -1 && {translate('send.invalidaddress') as string}} + {validAddress === -1 && ( + {translate('send.invalidaddress') as string} + )} new Promise(r => setTimeout(r, ms)); describe('Renders wallet data correctly.', () => { // i just pulled this seed out of thin air + beforeEach(async () => { + await device.launchApp({ + newInstance: true, + }); + }); 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(); @@ -25,7 +30,9 @@ describe('Renders wallet data correctly.', () => { 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().withTimeout(sync_timeout); + 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(); @@ -38,8 +45,13 @@ describe('Renders wallet data correctly.', () => { //await expect(memo).toHaveText( // '1\n2\n3\n4\n5\n6\n7\n8\nReply to: \nuregtest1zkuzfv5m3yhv2j4fmvq5rjurkxenxyq8r7h4daun2zkznrjaa8ra8asgdm8wwgwjvlwwrxx7347r8w0ee6dqyw4rufw4wg9djwcr6frzkezmdw6dud3wsm99eany5r8wgsctlxquu009nzd6hsme2tcsk0v3sgjvxa70er7h27z5epr67p5q767s2z5gt88paru56mxpm6pwz0cu35m', //); - await expect(memo).toHaveText( - '1\n2\n3\n4\n5\n6\n7\n8', - ); + await expect(memo).toHaveText('1\n2\n3\n4\n5\n6\n7\n8'); + }); + it('does not parse an incorrect address', async () => { + await element(by.text('SEND')).tap(); + await element(by.id('send.addressplaceholder')).replaceText('thisisaninvalidaddress'); + await waitFor(element(by.id('send.address.error'))) + .toExist() + .withTimeout(5000); }); }); From ca99a7d708c4a43b2a4bd702a2eb8eb8c0bc23dd Mon Sep 17 00:00:00 2001 From: dariovp Date: Wed, 16 Oct 2024 19:31:17 -0300 Subject: [PATCH 2/3] test: move invalid address to another test file --- e2e/parse_invalid_address.test.js | 21 +++++++ e2e/send.test.js | 12 ---- rust/android/tests/e2e_tests.rs | 92 ++++++++++++++++++++++--------- 3 files changed, 88 insertions(+), 37 deletions(-) create mode 100644 e2e/parse_invalid_address.test.js diff --git a/e2e/parse_invalid_address.test.js b/e2e/parse_invalid_address.test.js new file mode 100644 index 000000000..cf7402495 --- /dev/null +++ b/e2e/parse_invalid_address.test.js @@ -0,0 +1,21 @@ +const { log, device, by, element, expect } = require('detox'); + +import { loadRecipientWallet } from './e2e-utils/loadRecipientWallet.js'; + +const sleep = ms => new Promise(r => setTimeout(r, ms)); + +describe('Renders wallet data correctly.', () => { + beforeEach(async () => { + await device.launchApp({ + newInstance: true, + }); + }); + it('loads a wallet', async () => await loadRecipientWallet()); + it('does not parse an incorrect address', async () => { + await element(by.text('SEND')).tap(); + await element(by.id('send.addressplaceholder')).replaceText('thisisaninvalidaddress'); + await waitFor(element(by.id('send.address.error'))) + .toExist() + .withTimeout(5000); + }); +}); diff --git a/e2e/send.test.js b/e2e/send.test.js index d529443fc..24dbb2554 100644 --- a/e2e/send.test.js +++ b/e2e/send.test.js @@ -6,11 +6,6 @@ const sleep = ms => new Promise(r => setTimeout(r, ms)); describe('Renders wallet data correctly.', () => { // i just pulled this seed out of thin air - beforeEach(async () => { - await device.launchApp({ - newInstance: true, - }); - }); 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(); @@ -47,11 +42,4 @@ describe('Renders wallet data correctly.', () => { //); await expect(memo).toHaveText('1\n2\n3\n4\n5\n6\n7\n8'); }); - it('does not parse an incorrect address', async () => { - await element(by.text('SEND')).tap(); - await element(by.id('send.addressplaceholder')).replaceText('thisisaninvalidaddress'); - await waitFor(element(by.id('send.address.error'))) - .toExist() - .withTimeout(5000); - }); }); diff --git a/rust/android/tests/e2e_tests.rs b/rust/android/tests/e2e_tests.rs index fa9ab340b..f68502c86 100644 --- a/rust/android/tests/e2e_tests.rs +++ b/rust/android/tests/e2e_tests.rs @@ -1,5 +1,5 @@ #[cfg(not(feature = "regchest"))] -use zingolib::testutils::{scenarios}; +use zingolib::testutils::scenarios; use darkside_tests::utils::{prepare_darksidewalletd, DarksideHandler}; @@ -24,12 +24,42 @@ async fn tex_send_address(abi: &str) { }; #[cfg(not(feature = "ci"))] - let (exit_code, output, error) = - zingomobile_utils::android_e2e_test(abi, "tex_send_address"); + let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "tex_send_address"); #[cfg(feature = "ci")] let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "tex_send_address"); - + + #[cfg(feature = "regchest")] + match regchest_utils::close(&docker).await { + Ok(_) => (), + Err(e) => panic!("Failed to close regchest docker container: {:?}", e), + } + + println!("Exit Code: {}", exit_code); + println!("Output: {}", output); + println!("Error: {}", error); + + assert_eq!(exit_code, 0); +} + +async fn parse_invalid_address(abi: &str) { + #[cfg(not(feature = "regchest"))] + let (_regtest_manager, _child_process_handler) = + scenarios::funded_orchard_mobileclient(1_000_000).await; + #[cfg(feature = "regchest")] + let docker = + match regchest_utils::launch(UNIX_SOCKET, Some("funded_orchard_mobileclient")).await { + Ok(d) => d, + Err(e) => panic!("Failed to launch regchest docker container: {:?}", e), + }; + + #[cfg(not(feature = "ci"))] + let (exit_code, output, error) = + zingomobile_utils::android_e2e_test(abi, "parse_invalid_address"); + #[cfg(feature = "ci")] + let (exit_code, output, error) = + zingomobile_utils::android_e2e_test_ci(abi, "parse_invalid_address"); + #[cfg(feature = "regchest")] match regchest_utils::close(&docker).await { Ok(_) => (), @@ -60,7 +90,7 @@ async fn reload_while_tx_pending(abi: &str) { #[cfg(feature = "ci")] let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "reload_while_tx_pending"); - + #[cfg(feature = "regchest")] match regchest_utils::close(&docker).await { Ok(_) => (), @@ -106,13 +136,13 @@ async fn change_custom_regtest_server(abi: &str) { #[cfg(feature = "ci")] let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "change_custom_regtest_server"); - + #[cfg(feature = "regchest")] match regchest_utils::close(&docker).await { Ok(_) => (), Err(e) => panic!("Failed to close regchest docker container: {:?}", e), } - + println!("Exit Code: {}", exit_code); println!("Output: {}", output); println!("Error: {}", error); @@ -152,11 +182,9 @@ async fn change_server_from_list(abi: &str) { async fn new_wallet(abi: &str) { #[cfg(not(feature = "ci"))] - let (exit_code, output, error) = - zingomobile_utils::android_e2e_test(abi, "new_wallet"); + let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "new_wallet"); #[cfg(feature = "ci")] - let (exit_code, output, error) = - zingomobile_utils::android_e2e_test_ci(abi, "new_wallet"); + let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "new_wallet"); println!("Exit Code: {}", exit_code); println!("Output: {}", output); @@ -167,11 +195,9 @@ async fn new_wallet(abi: &str) { async fn screen_awake(abi: &str) { #[cfg(not(feature = "ci"))] - let (exit_code, output, error) = - zingomobile_utils::android_e2e_test(abi, "screen_awake"); + let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "screen_awake"); #[cfg(feature = "ci")] - let (exit_code, output, error) = - zingomobile_utils::android_e2e_test_ci(abi, "screen_awake"); + let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "screen_awake"); println!("Exit Code: {}", exit_code); println!("Output: {}", output); @@ -192,11 +218,9 @@ async fn send(abi: &str) { }; #[cfg(not(feature = "ci"))] - let (exit_code, output, error) = - zingomobile_utils::android_e2e_test(abi, "send"); + let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "send"); #[cfg(feature = "ci")] - let (exit_code, output, error) = - zingomobile_utils::android_e2e_test_ci(abi, "send"); + let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "send"); #[cfg(feature = "regchest")] match regchest_utils::close(&docker).await { @@ -213,11 +237,9 @@ async fn send(abi: &str) { async fn sync_report(abi: &str) { #[cfg(not(feature = "ci"))] - let (exit_code, output, error) = - zingomobile_utils::android_e2e_test(abi, "sync_report"); + let (exit_code, output, error) = zingomobile_utils::android_e2e_test(abi, "sync_report"); #[cfg(feature = "ci")] - let (exit_code, output, error) = - zingomobile_utils::android_e2e_test_ci(abi, "sync_report"); + let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "sync_report"); println!("Exit Code: {}", exit_code); println!("Output: {}", output); @@ -259,7 +281,7 @@ async fn darkside_simple_sync(abi: &str) { #[cfg(feature = "ci")] let (exit_code, output, error) = zingomobile_utils::android_e2e_test_ci(abi, "darkside_simple_sync"); - + println!("Exit Code: {}", exit_code); println!("Output: {}", output); println!("Error: {}", error); @@ -276,6 +298,11 @@ mod e2e { crate::tex_send_address(ABI).await; } + #[tokio::test] + async fn parse_invalid_address() { + crate::parse_invalid_address(ABI).await; + } + #[tokio::test] async fn reload_while_tx_pending() { crate::reload_while_tx_pending(ABI).await; @@ -342,6 +369,11 @@ mod e2e { crate::tex_send_address(ABI).await; } + #[tokio::test] + async fn parse_invalid_address() { + crate::parse_invalid_address(ABI).await; + } + #[tokio::test] async fn reload_while_tx_pending() { crate::reload_while_tx_pending(ABI).await; @@ -408,6 +440,11 @@ mod e2e { crate::tex_send_address(ABI).await; } + #[tokio::test] + async fn parse_invalid_address() { + crate::parse_invalid_address(ABI).await; + } + #[tokio::test] async fn reload_while_tx_pending() { crate::reload_while_tx_pending(ABI).await; @@ -474,6 +511,11 @@ mod e2e { crate::tex_send_address(ABI).await; } + #[tokio::test] + async fn parse_invalid_address() { + crate::parse_invalid_address(ABI).await; + } + #[tokio::test] async fn reload_while_tx_pending() { crate::reload_while_tx_pending(ABI).await; @@ -531,4 +573,4 @@ mod e2e { } } } -} \ No newline at end of file +} From b9fb2eeb5daf72a4c52193be5a7ae9eb020a7a11 Mon Sep 17 00:00:00 2001 From: JC Date: Wed, 16 Oct 2024 17:15:21 -0600 Subject: [PATCH 3/3] fix: fix & ci e2e new test added --- .github/workflows/android-ubuntu-e2e-test-ci.yaml | 1 + .github/workflows/ios-e2e-test.yaml | 1 + e2e/parse_invalid_address.test.js | 10 +++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/android-ubuntu-e2e-test-ci.yaml b/.github/workflows/android-ubuntu-e2e-test-ci.yaml index 071cffaab..649b388e4 100644 --- a/.github/workflows/android-ubuntu-e2e-test-ci.yaml +++ b/.github/workflows/android-ubuntu-e2e-test-ci.yaml @@ -113,6 +113,7 @@ jobs: fail-fast: false matrix: test: [ + "parse_invalid_address", "tex_send_address", "reload_while_tx_pending", "change_custom_server", diff --git a/.github/workflows/ios-e2e-test.yaml b/.github/workflows/ios-e2e-test.yaml index bbcad5f9f..b93516dde 100644 --- a/.github/workflows/ios-e2e-test.yaml +++ b/.github/workflows/ios-e2e-test.yaml @@ -23,6 +23,7 @@ jobs: fail-fast: false matrix: test: [ + "parse_invalid_address", "tex_send_address", "reload_while_tx_pending", "change_custom_server", diff --git a/e2e/parse_invalid_address.test.js b/e2e/parse_invalid_address.test.js index cf7402495..78865bfb3 100644 --- a/e2e/parse_invalid_address.test.js +++ b/e2e/parse_invalid_address.test.js @@ -5,15 +5,15 @@ import { loadRecipientWallet } from './e2e-utils/loadRecipientWallet.js'; const sleep = ms => new Promise(r => setTimeout(r, ms)); describe('Renders wallet data correctly.', () => { - beforeEach(async () => { - await device.launchApp({ - newInstance: true, - }); - }); it('loads a wallet', async () => await loadRecipientWallet()); it('does not parse an incorrect address', async () => { + await waitFor(element(by.id('vt-1'))) + .toExist() + .withTimeout(30000); await element(by.text('SEND')).tap(); + await element(by.id('send.addressplaceholder')).replaceText('thisisaninvalidaddress'); + await waitFor(element(by.id('send.address.error'))) .toExist() .withTimeout(5000);