Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detox: Upate dapp-initated-txn tests #1425

Merged
merged 2 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/components/Views/ApproveView/Approve/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,11 +717,11 @@ class Approve extends PureComponent {
confirmButtonMode={'confirm'}
>
<View>
<View style={styles.section}>
<View style={styles.section} testID={'approve-screen'}>
<View style={styles.websiteIconWrapper}>
<WebsiteIcon style={styles.icon} url={transaction.origin} title={host} />
</View>
<Text style={styles.title}>
<Text style={styles.title} testID={'allow-access'}>
{strings('spend_limit_edition.allow_to_access', { host, tokenSymbol })}
</Text>
<Text style={styles.explanation}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports[`Success should render correctly 1`] = `
"flexDirection": "column",
}
}
testID="approve-success-screen"
>
<View
style={
Expand Down Expand Up @@ -88,6 +89,7 @@ exports[`Success should render correctly 1`] = `
"opacity": 0.6,
}
}
testID="approve-success-close-button"
type="confirm"
>
Close
Expand Down
9 changes: 7 additions & 2 deletions app/components/Views/ApproveView/Success/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,20 @@ export default class Success extends PureComponent {
};

render = () => (
<SafeAreaView style={styles.root}>
<SafeAreaView style={styles.root} testID={'approve-success-screen'}>
<View style={styles.iconWrapper}>
<AntDesign name={'checkcircleo'} size={95} color={colors.green400} />
</View>
<Text style={styles.title}>{strings('spend_limit_edition.all_set')}</Text>
<Text style={styles.description}>{strings('spend_limit_edition.all_set_desc')}</Text>
<View style={styles.buttonsWrapper}>
<View style={styles.buttonsContainer}>
<StyledButton type="confirm" onPress={this.close} containerStyle={styles.close}>
<StyledButton
type="confirm"
onPress={this.close}
containerStyle={styles.close}
testID={'approve-success-close-button'}
>
{strings('spend_limit_edition.close')}
</StyledButton>
</View>
Expand Down
86 changes: 59 additions & 27 deletions e2e/dapp-initiated-txn.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const ROPSTEN_FAUCET = 'https://faucet.metamask.io';
const TEST_DAPP_URL = 'https://metamask.github.io/test-dapp/';
const TEST_DAPP_TITLE = 'E2E Test Dapp';
const ETH_FAUCET = 'Test Ether Faucet';
const DAPP_ACCESS = 'Allow metamask.github.io to access your TST?';

describe('Test Dapp Initiated Transactions', () => {
beforeEach(() => {
Expand Down Expand Up @@ -75,18 +76,19 @@ describe('Test Dapp Initiated Transactions', () => {
// Tap on Browser
await TestHelpers.tapByText('Browser');
// Wait for page to load
await TestHelpers.delay(1000);
await TestHelpers.delay(2000);
// Check that we are on the browser screen
await TestHelpers.checkIfVisible('browser-screen');
// Tap on search in bottom navbar
await TestHelpers.tap('search-button');
// Navigate to URL
if (device.getPlatform() === 'ios') {
await TestHelpers.typeTextAndHideKeyboard('url-input', ROPSTEN_FAUCET);
await TestHelpers.delay(8500);
} else {
await TestHelpers.replaceTextInField('url-input', ROPSTEN_FAUCET);
await element(by.id('url-input')).tapReturnKey();
await TestHelpers.delay(1500);
await TestHelpers.delay(8500);
}
// Check that we are still on the browser screen
await TestHelpers.checkIfVisible('browser-screen');
Expand All @@ -111,9 +113,9 @@ describe('Test Dapp Initiated Transactions', () => {
// Input Amount
await TestHelpers.replaceTextInField('amount-input', '0.000001');
// Tap on NEXT button
await TestHelpers.tapByText('NEXT');
await TestHelpers.tapByText('Next');
// Tap on CONFIRM button
await TestHelpers.tapByText('CONFIRM');
await TestHelpers.tapByText('Confirm');
// Wait for enable notifications alert to show up
if (device.getPlatform() === 'ios') {
// Check that we are on the browser screen
Expand Down Expand Up @@ -153,7 +155,7 @@ describe('Test Dapp Initiated Transactions', () => {
}
});

it('should navigate to test dapp repo to create and approve a token', async () => {
it('should navigate to test dapp repo to perform transactions', async () => {
// Open Drawer
await TestHelpers.tap('hamburger-menu-button-wallet');
// Check that the drawer is visbile
Expand All @@ -173,54 +175,84 @@ describe('Test Dapp Initiated Transactions', () => {
// Navigate to URL
if (device.getPlatform() === 'ios') {
await TestHelpers.typeTextAndHideKeyboard('url-input', TEST_DAPP_URL);
await TestHelpers.delay(3500);
} else {
await TestHelpers.replaceTextInField('url-input', TEST_DAPP_URL);
await element(by.id('url-input')).tapReturnKey();
await TestHelpers.delay(1500);
await TestHelpers.delay(3500);
}
// Tap on connect button to bring up connection request
if (device.getPlatform() === 'android') {
await TestHelpers.tapAtPoint('browser-screen', { x: 65, y: 114 });
await TestHelpers.delay(1000);
} else {
await TestHelpers.tapAtPoint('browser-screen', { x: 65, y: 120 });
}
// Give some time for connect request
await TestHelpers.delay(1000);
// Check that account approval is displayed with correct dapp name
await TestHelpers.checkIfHasText('dapp-name-title', TEST_DAPP_TITLE);
// Tap on CONNECT button
await TestHelpers.tapByText('CONNECT');
// Tap on Create Token
if (device.getPlatform() === 'android') {
await TestHelpers.tapAtPoint('browser-screen', { x: 20, y: 56 });
await TestHelpers.delay(1000);
// Give some time for account to be displayed
await TestHelpers.delay(2000);
// Tap on Create Token button
if (device.getPlatform() === 'ios') {
await TestHelpers.tapAtPoint('browser-screen', { x: 70, y: 297 });
} else {
await TestHelpers.tapAtPoint('browser-screen', { x: 23, y: 63 });
await TestHelpers.tapAtPoint('browser-screen', { x: 65, y: 289 });
await TestHelpers.delay(1000);
await TestHelpers.tapAtPoint('browser-screen', { x: 114, y: 290 });
await TestHelpers.delay(1000);
await TestHelpers.tapAtPoint('browser-screen', { x: 70, y: 315 });
await TestHelpers.delay(1000);
}
// Check that we are on the confirm transaction screen
await TestHelpers.checkIfVisible('confirm-transaction-screen');
// Tap Edit
await TestHelpers.tap('confirm-txn-edit-button');
// Tap on SLOW for transaction fee
await TestHelpers.tapByText('SLOW');
// Tap on NEXT button
await TestHelpers.tapByText('Next');
// Tap on CONFIRM button
await TestHelpers.tapByText('CONFIRM');
// Wait for enable notifications alert to show up
if (device.getPlatform() === 'ios') {
await TestHelpers.tapByText('Confirm');
// on iOS dismiss notification and on Android, wait some time for token to be created
if (device.getPlatform() === 'android') {
await TestHelpers.delay(5000);
} else {
// Check that we are on the browser screen
await TestHelpers.checkIfVisible('browser-screen');
// Wait for enable notifications alert to show up
await TestHelpers.delay(10000);
// Dismiss alert
await TestHelpers.tapAlertWithButton('No, thanks');
}
// Delay so that webpage shifts down after address gets added
if (device.getPlatform() === 'android') {
await TestHelpers.delay(10000);
}
// Tap on Approve Tokens button
if (device.getPlatform() === 'android') {
await TestHelpers.tapAtPoint('browser-screen', { x: 97, y: 67 });
await TestHelpers.tapAtPoint('browser-screen', { x: 300, y: 289 });
await TestHelpers.delay(1000);
await TestHelpers.tapAtPoint('browser-screen', { x: 341, y: 290 });
await TestHelpers.delay(1000);
await TestHelpers.tapAtPoint('browser-screen', { x: 350, y: 307 });
await TestHelpers.delay(1000);
} else {
await TestHelpers.tapAtPoint('browser-screen', { x: 100, y: 74 });
await TestHelpers.tapAtPoint('browser-screen', { x: 301, y: 298 });
}
// Check that we are on the approve screen
await TestHelpers.checkIfVisible('approve-screen');
// Check that title is correct
await TestHelpers.checkIfElementHasString('allow-access', DAPP_ACCESS);
// Tap on Approve button
if (device.getPlatform() === 'android') {
await TestHelpers.tapByText('Approve');
} else {
await TestHelpers.tapAtPoint('approve-screen', { x: 275, y: 620 });
}
// Check that we are on the confirm transaction screen
await TestHelpers.checkIfVisible('confirm-transaction-screen');
// Tap on CONFIRM button
await TestHelpers.tapByText('CONFIRM');
// Delay
await TestHelpers.delay(1000);
// Check that we are on the success screen
await TestHelpers.checkIfVisible('approve-success-screen');
// Close Success screen
await TestHelpers.tap('approve-success-close-button');
});

it('should log out', async () => {
Expand All @@ -232,7 +264,7 @@ describe('Test Dapp Initiated Transactions', () => {
await TestHelpers.tapByText('Log Out');
// Tap YES
await TestHelpers.tapAlertWithButton('YES');
// Check that we are on the wallet screen
// Check that we are on the login screen
await TestHelpers.checkIfVisible('login');
});
});