From d30e1d5a5586c1614bb67af69c0234a1290861b3 Mon Sep 17 00:00:00 2001 From: dariovp Date: Thu, 26 Sep 2024 01:15:26 -0300 Subject: [PATCH 1/4] test: add failing test for ZIP320 send --- e2e/send_tex_address.test.js | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 e2e/send_tex_address.test.js diff --git a/e2e/send_tex_address.test.js b/e2e/send_tex_address.test.js new file mode 100644 index 000000000..ff6da6e1d --- /dev/null +++ b/e2e/send_tex_address.test.js @@ -0,0 +1,38 @@ +const { log, device, by, element, expect } = require('detox'); + +import { loadTestWallet } from './e2e-utils/loadTestWallet.js'; + +const sleep = ms => new Promise(r => setTimeout(r, ms)); + +describe('Renders wallet data correctly.', () => { + it('loads a wallet', loadTestWallet); + it('parses the TEX address and correctly renders the confirm screen', async () => { + await waitFor(element(by.id('vt-1'))) + .toExist() + .withTimeout(20000); + await element(by.text('SEND')).tap(); + + // Address taken from the reference implementation + await element(by.id('send.addressplaceholder')).replaceText('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte'); + await element(by.id('send.amount')).replaceText('0'); + 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 sleep(2000); + await element(by.id('send.button')).tap(); + + await expect(element(by.id('send.confirm.scroll-view'))).toExist(); + await expect(element(by.id('send.confirm.scroll-view'))).toBeVisible(20); + await element(by.id('send.confirm.scroll-view')).scrollTo('bottom'); + + const memo = element(by.id('send.confirm-memo')); + + await expect(memo).toBeVisible(100); + await expect(memo).toHaveText( + '1\n2\n3\n4\n5\n6\n7\n8\nReply to: \nu1lx7nlnqqqs7p4hcqz4hyjgnw7h8zskcgr2f8dfhm96np0gnfdzu7jtms7q2pxd7ufy96wxzdsdy65jvp3td7fj2ltcz0jpak86ddyszl9ykn5s86q3xataya5867z3tj2x8cw0ljyrenymr2gcqmjf50gmexqj233yn3kdaxn2yukwcx87emurufakf82wapgnu5h3fvae6aw9uus2r', + ); + }); +}); From dc3bf71382e9ab007f975839793f7e7c47c38ebc Mon Sep 17 00:00:00 2001 From: dariovp Date: Thu, 26 Sep 2024 13:12:29 -0300 Subject: [PATCH 2/4] test: remove memo references --- e2e/send_tex_address.test.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/e2e/send_tex_address.test.js b/e2e/send_tex_address.test.js index ff6da6e1d..96906ad9b 100644 --- a/e2e/send_tex_address.test.js +++ b/e2e/send_tex_address.test.js @@ -14,25 +14,16 @@ describe('Renders wallet data correctly.', () => { // Address taken from the reference implementation await element(by.id('send.addressplaceholder')).replaceText('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte'); + + await expect(element(by.text('Invalid Address!'))).not.toExist(); + await element(by.id('send.amount')).replaceText('0'); - 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 sleep(2000); await element(by.id('send.button')).tap(); await expect(element(by.id('send.confirm.scroll-view'))).toExist(); await expect(element(by.id('send.confirm.scroll-view'))).toBeVisible(20); await element(by.id('send.confirm.scroll-view')).scrollTo('bottom'); - - const memo = element(by.id('send.confirm-memo')); - - await expect(memo).toBeVisible(100); - await expect(memo).toHaveText( - '1\n2\n3\n4\n5\n6\n7\n8\nReply to: \nu1lx7nlnqqqs7p4hcqz4hyjgnw7h8zskcgr2f8dfhm96np0gnfdzu7jtms7q2pxd7ufy96wxzdsdy65jvp3td7fj2ltcz0jpak86ddyszl9ykn5s86q3xataya5867z3tj2x8cw0ljyrenymr2gcqmjf50gmexqj233yn3kdaxn2yukwcx87emurufakf82wapgnu5h3fvae6aw9uus2r', - ); }); }); From 72cbea511b0dcc52dc78f6bfdc218b9f5f375cb8 Mon Sep 17 00:00:00 2001 From: dariovp Date: Thu, 26 Sep 2024 13:37:59 -0300 Subject: [PATCH 3/4] test: correct timings --- e2e/send_tex_address.test.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/e2e/send_tex_address.test.js b/e2e/send_tex_address.test.js index 96906ad9b..1fa5705a2 100644 --- a/e2e/send_tex_address.test.js +++ b/e2e/send_tex_address.test.js @@ -9,17 +9,21 @@ describe('Renders wallet data correctly.', () => { it('parses the TEX address and correctly renders the confirm screen', async () => { await waitFor(element(by.id('vt-1'))) .toExist() - .withTimeout(20000); + .withTimeout(30000); await element(by.text('SEND')).tap(); // Address taken from the reference implementation await element(by.id('send.addressplaceholder')).replaceText('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte'); - await expect(element(by.text('Invalid Address!'))).not.toExist(); + await waitFor(element(by.text('Invalid Address!'))) + .not.toExist() + .withTimeout(2000); await element(by.id('send.amount')).replaceText('0'); 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(5000); await element(by.id('send.button')).tap(); await expect(element(by.id('send.confirm.scroll-view'))).toExist(); From 928b9dd844c882fc77d455c2c9658ff9112b06dd Mon Sep 17 00:00:00 2001 From: dariovp Date: Thu, 26 Sep 2024 14:33:10 -0300 Subject: [PATCH 4/4] test: use testID prop for address parsing --- components/Send/Send.tsx | 6 +++++- e2e/send_tex_address.test.js | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/Send/Send.tsx b/components/Send/Send.tsx index 52ba69e99..01ed3125b 100644 --- a/components/Send/Send.tsx +++ b/components/Send/Send.tsx @@ -941,7 +941,11 @@ const Send: React.FunctionComponent = ({ /> )} - {validAddress === 1 && } + {validAddress === 1 && ( + + + + )} {validAddress === -1 && {translate('send.invalidaddress') as string}} { // Address taken from the reference implementation await element(by.id('send.addressplaceholder')).replaceText('tex1s2rt77ggv6q989lr49rkgzmh5slsksa9khdgte'); - await waitFor(element(by.text('Invalid Address!'))) - .not.toExist() - .withTimeout(2000); + await waitFor(element(by.id('send.address.check'))) + .toExist() + .withTimeout(5000); await element(by.id('send.amount')).replaceText('0'); await element(by.id('send.scroll-view')).scrollTo('bottom');