Skip to content

Commit

Permalink
test: add parse for invalid address
Browse files Browse the repository at this point in the history
  • Loading branch information
dorianvp committed Oct 16, 2024
1 parent aa732e6 commit a0761d3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
9 changes: 7 additions & 2 deletions components/Components/ErrorText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ import { ThemeType } from '../../app/types/ThemeType';
type ErrorTextProps = {
style?: TextStyle;
children: string;
testID?: string;
};

const ErrorText: React.FunctionComponent<ErrorTextProps> = ({ style, children }) => {
const ErrorText: React.FunctionComponent<ErrorTextProps> = ({ style, children, testID }) => {
const { colors } = useTheme() as unknown as ThemeType;

return <Text style={{ color: colors.primary, ...style }}>{children}</Text>;
return (
<Text testID={testID} style={{ color: colors.primary, ...style }}>
{children}
</Text>
);
};

export default ErrorText;
4 changes: 3 additions & 1 deletion components/Send/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,9 @@ const Send: React.FunctionComponent<SendProps> = ({
<FontAwesomeIcon icon={faCheck} color={colors.primary} />
</View>
)}
{validAddress === -1 && <ErrorText>{translate('send.invalidaddress') as string}</ErrorText>}
{validAddress === -1 && (
<ErrorText testID="send.address.error">{translate('send.invalidaddress') as string}</ErrorText>
)}
</View>
<View
style={{
Expand Down
20 changes: 16 additions & 4 deletions e2e/send.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ 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();
Expand All @@ -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();
Expand All @@ -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);
});
});

0 comments on commit a0761d3

Please sign in to comment.