Skip to content

Commit

Permalink
Detox/Fix failing tests (#2607)
Browse files Browse the repository at this point in the history
* fixed all failing tests

* remove a

Co-authored-by: Ibrahim Taveras <ibrahimtaveras@ibrahims-mbp.myfiosgateway.com>
  • Loading branch information
ibrahimtaveras00 and Ibrahim Taveras authored Apr 30, 2021
1 parent 427d6ff commit 2a634ae
Show file tree
Hide file tree
Showing 20 changed files with 286 additions and 205 deletions.
1 change: 1 addition & 0 deletions app/components/UI/AccountOverview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ class AccountOverview extends PureComponent {
: { borderColor: colors.white }
]}
numberOfLines={1}
testID={'edit-account-label'}
>
{name}
</Text>
Expand Down
1 change: 1 addition & 0 deletions app/components/UI/DrawerView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ class DrawerView extends PureComponent {
type={'rounded-normal'}
onPress={this.onSend}
containerStyle={[styles.button, styles.leftButton]}
testID={'drawer-send-button'}
>
<View style={styles.buttonContent}>
<MaterialIcon
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,11 +608,11 @@ export function getClosableNavigationOptions(title, backButtonText, navigation)
...fontStyles.normal
},
headerLeft: Device.isIos() ? (
<TouchableOpacity onPress={navigationPop} style={styles.closeButton}>
<TouchableOpacity onPress={navigationPop} style={styles.closeButton} testID={'nav-ios-back'}>
<Text style={styles.closeButtonText}>{backButtonText}</Text>
</TouchableOpacity>
) : (
<TouchableOpacity onPress={navigationPop} style={styles.backButton}>
<TouchableOpacity onPress={navigationPop} style={styles.backButton} testID={'nav-android-back'}>
<IonicIcon name={'md-arrow-back'} size={24} style={styles.backIcon} />
</TouchableOpacity>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ exports[`NetworkList should render correctly 1`] = `
"flex": 1,
}
}
testID="other-networks-scroll"
>
<View>
<TouchableOpacity
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/NetworkList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class NetworkList extends PureComponent {
{strings('networks.title')}
</Text>
</View>
<ScrollView style={styles.networksWrapper}>
<ScrollView style={styles.networksWrapper} testID={'other-networks-scroll'}>
{this.renderMainnet()}
<View style={styles.otherNetworksHeader}>
<Text style={styles.otherNetworksText} testID={'other-network-name'}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ exports[`Browser should render correctly 1`] = `
"marginTop": 7,
}
}
testID="cancel-url-button"
testID="ios-cancel-url-button"
>
<Text
style={
Expand Down
9 changes: 7 additions & 2 deletions app/components/Views/BrowserTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1419,12 +1419,17 @@ export const BrowserTab = props => {
onPress={() => (!autocompleteValue ? setShowUrlModal(false) : setAutocompleteValue(''))}
style={styles.iconCloseButton}
>
<MaterialIcon name="close" size={20} style={[styles.icon, styles.iconClose]} />
<MaterialIcon
name="close"
size={20}
style={[styles.icon, styles.iconClose]}
testID={'android-cancel-url-button'}
/>
</TouchableOpacity>
) : (
<TouchableOpacity
style={styles.cancelButton}
testID={'cancel-url-button'}
testID={'ios-cancel-url-button'}
onPress={toggleUrlModal}
>
<Text style={styles.cancelButtonText}>{strings('browser.cancel')}</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ exports[`NetworksSettings should render correctly 1`] = `
</View>
</View>
</TouchableOpacity>
<View>
<View
testID="rpc-networks"
>
<Text
style={
Object {
Expand Down
2 changes: 1 addition & 1 deletion app/components/Views/Settings/NetworksSettings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class NetworksSettings extends PureComponent {
const { frequentRpcList } = this.props;
if (frequentRpcList.length > 0) {
return (
<View>
<View testID={'rpc-networks'}>
<Text style={styles.sectionLabel}>{strings('app_settings.network_rpc_networks')}</Text>
{this.renderRpcNetworks()}
</View>
Expand Down
48 changes: 19 additions & 29 deletions e2e/add-custom-rpc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,30 +129,21 @@ describe('Custom RPC Tests', () => {
await TestHelpers.tap('open-networks-button');
// Check that networks list is visible
await TestHelpers.checkIfVisible('networks-list');
// Swipe down on networks list
await TestHelpers.swipe('networks-list', 'up');
// Check that our network is added
await TestHelpers.checkIfElementHasString('other-network-name', 'xDai');

// iOS change networks tests
if (device.getPlatform() === 'ios') {
// Change to Rinkeby Network
await TestHelpers.tapByText(RINKEBY);
// Check that we are on correct network
await TestHelpers.checkIfElementHasString('network-name', RINKEBY);
// Tap to prompt network list
await TestHelpers.tap('open-networks-button');
// Check that networks list is visible
await TestHelpers.checkIfVisible('networks-list');
// Swipe down on networks list
await TestHelpers.swipe('networks-list', 'up');
// Change to back to xDai Network
await TestHelpers.tapByText('xDai');
} else {
// Close list
await TestHelpers.tapByText('Close');
}

// Change to Rinkeby Network
await TestHelpers.tapByText(RINKEBY);
// Check that we are on correct network
await TestHelpers.checkIfElementHasString('network-name', RINKEBY);
// Tap to prompt network list
await TestHelpers.tap('open-networks-button');
// Check that networks list is visible
await TestHelpers.checkIfVisible('networks-list');
// Swipe up on networks list
await TestHelpers.swipe('other-networks-scroll', 'up', 'fast');
await TestHelpers.delay(1000);
// Change to back to xDai Network
await TestHelpers.tapByText('xDai');
// Check that we are on the wallet screen
await TestHelpers.checkIfVisible('wallet-screen');
// Check that we are on correct network
Expand All @@ -171,22 +162,21 @@ describe('Custom RPC Tests', () => {
// Check that we are on the networks screen
await TestHelpers.checkIfVisible('networks-screen');
// Tap on xDai to remove network
await element(by.text('xDai')).longPress();
// Tap remove
await TestHelpers.tapAndLongPressAtIndex('rpc-networks', 0);
//Remove xDAI and verify removed on wallet view
//Tap remove
await TestHelpers.tapByText('Remove');

// Go back to wallet screen
if (device.getPlatform() === 'ios') {
// Tap on back arrow
await TestHelpers.tapAtPoint('networks-screen', { x: 25, y: -22 });
await TestHelpers.tap('nav-ios-back');
// Tap close
await TestHelpers.tapByText('Close');
} else {
// Go Back for android
await device.pressBack();
await device.pressBack();
await TestHelpers.tap('nav-android-back');
await TestHelpers.tap('nav-android-back');
}

// Check that we are on the wallet screen
await TestHelpers.checkIfExists('wallet-screen');
// Check that we are on Mainnet
Expand Down
51 changes: 33 additions & 18 deletions e2e/addressbook-tests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import TestHelpers from './helpers';

const INVALID_ADDRESS = '0xB8B4EE5B1b693971eB60bDa15211570df2dB221L';
const TETHER_ADDRESS = '0xdac17f958d2ee523a2206206994597c13d831ec7';
const MYTH_ADDRESS = '0x1FDb169Ef12954F20A15852980e1F0C122BfC1D6';
const MEMO = 'Test adding ENS';
const PASSWORD = '12345678';
Expand Down Expand Up @@ -84,28 +85,39 @@ describe('Addressbook Tests', () => {
it('should go to send view', async () => {
// Check that we are on the wallet screen
await TestHelpers.checkIfVisible('wallet-screen');
// Tap on ETH asset
await TestHelpers.waitAndTap('eth-logo');
// Check that we are on the token overview screen
await TestHelpers.checkIfVisible('token-asset-overview');
// Open Drawer
await TestHelpers.tap('hamburger-menu-button-wallet');
// Check that the drawer is visbile
await TestHelpers.checkIfVisible('drawer-screen');
// Tap on Send button
await TestHelpers.tapByText('SEND');
await TestHelpers.tap('drawer-send-button');
// Check that we are on the send screen
await TestHelpers.checkIfVisible('send-screen');
// Make sure view with my accounts visible
await TestHelpers.checkIfExists('my-accounts-button');
});

it('should input a valid address to send to', async () => {
// Input incorrect address
// Input incorrect address Currently commented out until https://github.com/MetaMask/metamask-mobile/issues/2533 is fixed
// if (device.getPlatform() === 'android') {
// await TestHelpers.replaceTextInField('txn-to-address-input', INVALID_ADDRESS);
// await element(by.id('txn-to-address-input')).tapReturnKey();
// } else {
// await TestHelpers.typeTextAndHideKeyboard('txn-to-address-input', INVALID_ADDRESS);
// }
// // Check that the error is displayed
// await TestHelpers.checkIfVisible('address-error');
//Input token address to test for error
if (device.getPlatform() === 'android') {
await TestHelpers.replaceTextInField('txn-to-address-input', INVALID_ADDRESS);
await element(by.id('txn-to-address-input')).tapReturnKey();
await TestHelpers.replaceTextInField('txn-to-address-input', TETHER_ADDRESS);
} else {
await TestHelpers.typeTextAndHideKeyboard('txn-to-address-input', INVALID_ADDRESS);
await TestHelpers.typeTextAndHideKeyboard('txn-to-address-input', TETHER_ADDRESS);
}
// Check that the error is displayed
await TestHelpers.checkIfVisible('address-error');
// Tap x to remove address
await TestHelpers.tap('clear-address-button');
await TestHelpers.delay(1000);
// Input valid myth address
if (device.getPlatform() === 'android') {
await TestHelpers.replaceTextInField('txn-to-address-input', MYTH_ADDRESS);
Expand Down Expand Up @@ -142,8 +154,6 @@ describe('Addressbook Tests', () => {
it('should go to settings then select contacts', async () => {
// Tap on cancel button
await TestHelpers.tap('send-cancel-button');
// Tap on back button to proceed to wallet view
await TestHelpers.tap('asset-back-button');
// Check that we are on the wallet screen
await TestHelpers.checkIfVisible('wallet-screen');
// Open Drawer
Expand Down Expand Up @@ -186,11 +196,10 @@ describe('Addressbook Tests', () => {
await TestHelpers.replaceTextInField('contact-memo-input', MEMO);
// Tap add contact button
if (device.getPlatform() === 'android') {
await TestHelpers.tapByText('Add contact');
await TestHelpers.delay(1000);
await TestHelpers.tapByText('Add contact');
} else {
await TestHelpers.tap('contact-add-contact-button');
await TestHelpers.delay(700);
await TestHelpers.tap('contact-add-contact-button');
} else {
await TestHelpers.tap('contact-add-contact-button');
}
// Check that we are on the contacts screen
Expand All @@ -208,6 +217,9 @@ describe('Addressbook Tests', () => {
await TestHelpers.replaceTextInField('contact-name-input', 'Moon');
// Tap on Edit contact button
await TestHelpers.tapByText('Edit contact');
if (device.getPlatform() === 'ios') {
await TestHelpers.tapByText('Edit contact');
}
// Check that we are on the contacts screen
await TestHelpers.checkIfVisible('contacts-screen');
// Check that Ibrahim address is saved in the address book
Expand All @@ -223,8 +235,11 @@ describe('Addressbook Tests', () => {
await TestHelpers.tapByText('Edit');
// Tap on Delete
await TestHelpers.tapByText('Delete');
// Tap on Delete
await TestHelpers.tapByText('Delete');
if (device.getPlatform() === 'ios') {
await TestHelpers.tapByText('Delete', 1);
} else {
await TestHelpers.tapByText('Delete');
}
// Ensure Moon is not visible
await TestHelpers.checkIfElementWithTextIsNotVisible('Moon');
});
Expand All @@ -234,7 +249,7 @@ describe('Addressbook Tests', () => {
await TestHelpers.tap('title-back-arrow-button');
// tap to get out of settings view
if (device.getPlatform() === 'android') {
await device.pressBack();
await TestHelpers.tap('nav-android-back');
} else {
await TestHelpers.tapByText('Close');
}
Expand Down
55 changes: 33 additions & 22 deletions e2e/browser-tests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TestHelpers from './helpers';

const ENS_Example = 'https://brunobarbieri.eth';
const ENS_TLD = 'https://inbox.mailchain.xyz';
const UNISWAP = 'https://uniswap.eth';
const UNISWAP = 'https://uniswap.exchange';
const PASSWORD = '12345678';

describe('Browser Tests', () => {
Expand Down Expand Up @@ -95,42 +95,46 @@ describe('Browser Tests', () => {
});

it('should go to first explore tab and navigate back to homepage', async () => {
// Tap on first category
if (device.getPlatform() === 'android') {
// This can only be done on Android since we removed option for iOS due to Appstore
if (!device.getPlatform() === 'android') {
// Tap on first category
await TestHelpers.tapAtPoint('browser-screen', { x: 100, y: 425 });
} else {
await TestHelpers.tapAtPoint('browser-screen', { x: 100, y: 450 });
// Tap on first option
await TestHelpers.tapAtPoint('browser-screen', { x: 80, y: 100 });
// Tap back button
await TestHelpers.waitAndTap('go-back-button');
// Tap back button
await TestHelpers.waitAndTap('go-back-button');
// Wait for page to load
await TestHelpers.delay(1000);
// Check that we are on the browser screen
await TestHelpers.checkIfVisible('browser-screen');
}
// Tap on first option
await TestHelpers.tapAtPoint('browser-screen', { x: 80, y: 100 });
// Tap back button
await TestHelpers.waitAndTap('go-back-button');
// Tap back button
await TestHelpers.waitAndTap('go-back-button');
// Wait for page to load
await TestHelpers.delay(1000);
// Check that we are on the browser screen
await TestHelpers.checkIfVisible('browser-screen');
});

it('should go to uniswap', async () => {
// Tap on home on bottom navbar
await TestHelpers.tap('home-button');
// await TestHelpers.tap('home-button');
// Wait for page to load
await TestHelpers.delay(1000);
await TestHelpers.delay(3000);
// Tap on search in bottom navbar
await TestHelpers.tap('search-button');
// Navigate to URL
if (device.getPlatform() === 'ios') {
await TestHelpers.clearField('url-input');
await TestHelpers.typeTextAndHideKeyboard('url-input', UNISWAP);
await TestHelpers.delay(2000);
} else {
await TestHelpers.tap('android-cancel-url-button');
await TestHelpers.replaceTextInField('url-input', UNISWAP);
await element(by.id('url-input')).tapReturnKey();
}
// Wait for page to load
await TestHelpers.delay(5000);
// Check that the dapp title is correct
await TestHelpers.checkIfElementWithTextIsVisible('uniswap.eth', 0);
if (device.getPlatform() === 'android') {
// Check that the dapp title is correct
await TestHelpers.checkIfElementWithTextIsVisible('app.uniswap.org', 0);
}
// Tap on CANCEL button
await TestHelpers.tap('connect-cancel-button');

Expand All @@ -139,7 +143,11 @@ describe('Browser Tests', () => {
// Wait for page to load
await TestHelpers.delay(3000);
await TestHelpers.tap('connect-cancel-button');

// Android has weird behavior where the URL modal stays open, so this closes it
// Close URL modal
if (device.getPlatform() === 'android') {
await device.pressBack();
}
// Check that we are still on the browser screen
await TestHelpers.checkIfVisible('browser-screen');
});
Expand All @@ -166,7 +174,10 @@ describe('Browser Tests', () => {
await TestHelpers.checkIfVisible('browser-screen');
// Tap on Favorites tab
if (device.getPlatform() === 'ios') {
await TestHelpers.tapAtPoint('browser-screen', { x: 274, y: 227 });
// Tap on options
await TestHelpers.waitAndTap('options-button');
// Open new tab
await TestHelpers.tapByText('New tab');
await TestHelpers.tapAtPoint('browser-screen', { x: 174, y: 281 });
await TestHelpers.delay(1500);
} else {
Expand Down Expand Up @@ -220,7 +231,7 @@ describe('Browser Tests', () => {
await TestHelpers.checkIfVisible('browser-screen');
// Tap on empowr from search results
if (device.getPlatform() === 'ios') {
await TestHelpers.tapAtPoint('browser-screen', { x: 20, y: 245 });
await TestHelpers.tapAtPoint('browser-screen', { x: 60, y: 270 });
} else {
await TestHelpers.tapAtPoint('browser-screen', { x: 56, y: 284 });
await TestHelpers.delay(700);
Expand Down
Loading

0 comments on commit 2a634ae

Please sign in to comment.