Skip to content

Commit

Permalink
Merge branch 'main' into marketing-consent-tracking-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jonybur authored Jan 20, 2025
2 parents b6b8170 + 3ec422a commit a107c34
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 6 deletions.
5 changes: 4 additions & 1 deletion app/components/UI/Navbar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,9 @@ export function getSendFlowTitle(
canGoBack ? (
// eslint-disable-next-line react/jsx-no-bind
<TouchableOpacity onPress={leftAction} style={styles.closeButton}>
<Text style={innerStyles.headerButtonText}>
<Text style={innerStyles.headerButtonText}
testID={SendViewSelectorsIDs.SEND_BACK_BUTTON}
>
{strings('transaction.back')}
</Text>
</TouchableOpacity>
Expand Down Expand Up @@ -715,6 +717,7 @@ export function getOnboardingNavbarOptions(
source={metamask_name}
style={innerStyles.metamaskName}
resizeMethod={'auto'}

/>
</View>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ exports[`Confirm should render correctly 1`] = `
"fontWeight": "400",
}
}
testID="send-back-button"
>
Back
</Text>
Expand Down
3 changes: 1 addition & 2 deletions app/util/networks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { ChainId, NetworkType, toHex } from '@metamask/controller-utils';
import { toLowerCaseEquals } from '../general';
import { fastSplit } from '../number';
import { regex } from '../../../app/util/regex';
import Device from '../../util/device';

/* eslint-disable */
const ethLogo = require('../../images/eth-logo-new.png');
Expand Down Expand Up @@ -499,4 +498,4 @@ export const isPermissionsSettingsV1Enabled =
process.env.MM_PERMISSIONS_SETTINGS_V1_ENABLED === 'true';

export const isPortfolioViewEnabled = () =>
Device.isIos() && process.env.PORTFOLIO_VIEW === 'true';
process.env.PORTFOLIO_VIEW === 'true';
14 changes: 14 additions & 0 deletions e2e/pages/Send/AmountView.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
AmountViewSelectorsIDs,
AmountViewSelectorsText
} from '../../selectors/SendFlow/AmountView.selectors';
import TestHelpers from '../../helpers';


class AmountView {
get currencySwitch() {
Expand All @@ -20,18 +22,30 @@ class AmountView {
: Matchers.getElementByLabel(AmountViewSelectorsIDs.NEXT_BUTTON);
}

get backButton() {
return Matchers.getElementByID(AmountViewSelectorsIDs.SEND_BACK_BUTTON);
}

get amountInputField() {
return Matchers.getElementByID(AmountViewSelectorsIDs.AMOUNT_INPUT);
}

async tapNextButton() {
await TestHelpers.delay(1000);
await Gestures.waitAndTap(this.nextButton);
}

async tapBackButton() {
await Gestures.waitAndTap(this.backButton);
}

async typeInTransactionAmount(amount) {
await TestHelpers.delay(1000);
device.getPlatform() === 'android'
? await Gestures.typeTextAndHideKeyboard(this.amountInputField, amount)
: await Gestures.replaceTextInField(this.amountInputField, amount);
await TestHelpers.delay(1000);

}

async tapCurrencySwitch() {
Expand Down
21 changes: 21 additions & 0 deletions e2e/pages/Send/SendView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import TestHelpers from '../../helpers';
import Gestures from '../../utils/Gestures';
import Matchers from '../../utils/Matchers';
import { SendViewSelectorsIDs } from '../../selectors/SendFlow/SendView.selectors';
import {AddAddressModalSelectorsIDs} from '../../selectors/SendFlow/AddAddressModal.selectors'
import Assertions from '../../utils/Assertions';


class SendView {
get cancelButton() {
Expand All @@ -20,9 +23,18 @@ class SendView {
);
}

get backButton() {
return Matchers.getElementByID(SendViewSelectorsIDs.SEND_BACK_BUTTON);
}

get addAddressButton() {
return Matchers.getElementByID(SendViewSelectorsIDs.ADD_ADDRESS_BUTTON);
}

get sendAddressConfirmation() {
return Matchers.getElementByID(AddAddressModalSelectorsIDs.ADD_ADDRESS_BUTTON);
}

get removeAddressButton() {
return Matchers.getElementByID(SendViewSelectorsIDs.ADDRESS_REMOVE_BUTTON);
}
Expand All @@ -42,6 +54,10 @@ class SendView {
await Gestures.waitAndTap(this.cancelButton);
}

async tapBackButton() {
await Gestures.TapAtIndex(this.backButton, 0);
}

async scrollToSavedAccount() {
await Gestures.swipe(this.CurrentAccountElement, 'up');
}
Expand Down Expand Up @@ -71,5 +87,10 @@ class SendView {
await Gestures.waitAndTap(this.removeAddressButton);
await TestHelpers.delay(1000);
}

async splitAddressText(){
const attributes = await (await this.sendAddressConfirmation).getAttributes();
return await attributes.label.split(' ');
}
}
export default new SendView();
10 changes: 9 additions & 1 deletion e2e/pages/wallet/TokenOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
TokenOverviewSelectorsIDs,
TokenOverviewSelectorsText
} from '../../selectors/wallet/TokenOverview.selectors';

import { WalletActionsBottomSheetSelectorsIDs } from '../../selectors/wallet/WalletActionsBottomSheet.selectors.js';
class TokenOverview {
get container() {
return Matchers.getElementByID(TokenOverviewSelectorsIDs.TOKEN_PRICE);
Expand All @@ -18,6 +18,10 @@ class TokenOverview {
return Matchers.getElementByID(TokenOverviewSelectorsIDs.SEND_BUTTON);
}

get actionSheetSendButton() {
return Matchers.getElementByID(WalletActionsBottomSheetSelectorsIDs.SEND_BUTTON);
}

get swapButton() {
return Matchers.getElementByID(TokenOverviewSelectorsIDs.SWAP_BUTTON);
}
Expand Down Expand Up @@ -58,6 +62,10 @@ class TokenOverview {
await Gestures.waitAndTap(this.sendButton);
}

async tapActionSheetSendButton() {
await Gestures.waitAndTap(this.actionSheetSendButton);
}

async tapSwapButton() {
await Gestures.waitAndTap(this.swapButton);
}
Expand Down
2 changes: 2 additions & 0 deletions e2e/selectors/SendFlow/AmountView.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export const AmountViewSelectorsIDs = {
FIAT_CONVERSION_WARNING_TEXT: 'amount-screen-fiat-conversion-warning-text',
TRANSACTION_AMOUNT_INPUT: 'txn-amount-input',
TRANSACTION_AMOUNT_CONVERSION_VALUE: 'txn-amount-conversion-value',
SEND_BACK_BUTTON: 'send-back-button'
};

export const AmountViewSelectorsText = {
SCREEN_TITLE: enContent.transaction.amount,
};

1 change: 1 addition & 0 deletions e2e/selectors/SendFlow/SendView.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const SendViewSelectorsIDs = {
ADDRESS_BOOK_NEXT_BUTTON: 'address-book-next-button',
ADDRESS_INPUT: 'txn-to-address-input',
SEND_CANCEL_BUTTON: 'send-cancel-button',
SEND_BACK_BUTTON: 'send-back-button',
ADD_ADDRESS_BUTTON: 'add-address-button-a',
CONTAINER_ID: 'send-screen',
};
4 changes: 4 additions & 0 deletions e2e/selectors/Transactions/ActivitiesView.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ export const ActivitiesViewSelectorsText = {
TITLE: enContent.transactions_view.title,

};

export const sentMessageTokenIDs = {
eth: ActivitiesViewSelectorsText.SENT_TOKENS_MESSAGE_TEXT(enContent.unit.eth)
};
90 changes: 90 additions & 0 deletions e2e/specs/wallet/edit-recipient-address.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
'use strict';
import { SmokeCore } from '../../tags';
import TestHelpers from '../../helpers';
import WalletView from '../../pages/wallet/WalletView';
import AmountView from '../../pages/Send/AmountView';
import SendView from '../../pages/Send/SendView';
import { loginToApp } from '../../viewHelper';
import TransactionConfirmationView from '../../pages/Send/TransactionConfirmView';
import TokenOverview from '../../pages/wallet/TokenOverview';
import Assertions from '../../utils/Assertions';
import TabBarComponent from '../../pages/wallet/TabBarComponent';
import {
defaultGanacheOptions,
stopFixtureServer,
withFixtures,
} from '../../fixtures/fixture-helper';
import FixtureServer from '../../fixtures/fixture-server';
import FixtureBuilder from '../../fixtures/fixture-builder';
import Gestures from '../../utils/Gestures';
import { ActivitiesViewSelectorsText, sentMessageTokenIDs } from '../../selectors/Transactions/ActivitiesView.selectors';
import { contractConfiguration } from '../../../app/util/test/smart-contracts';

const INCORRECT_SEND_ADDRESS = '0xebe6CcB6B55e1d094d9c58980Bc10Fed69932cAb';
const CORRECT_SEND_ADDRESS = '0x37cc5ef6bfe753aeaf81f945efe88134b238face';
const SHORTHAND_ADDRESS = '0x37Cc...FACE';
const fixtureServer = new FixtureServer();

describe(
SmokeCore('Send ETH to the correct address after editing the recipient'),
() => {
beforeEach(() => {
jest.setTimeout(200000);
});

afterAll(async () => {
await stopFixtureServer(fixtureServer);
});

it('should display correct send address after edit', async () => {
await withFixtures(
{
fixture: new FixtureBuilder().withGanacheNetwork().build(),
restartDevice: true,
ganacheOptions: defaultGanacheOptions,
},
async () => {
await loginToApp();
await Assertions.checkIfVisible(WalletView.container);
await TabBarComponent.tapActions();
await TokenOverview.tapActionSheetSendButton();
await SendView.inputAddress(INCORRECT_SEND_ADDRESS);

await SendView.tapNextButton();
await AmountView.typeInTransactionAmount('0.000001');

await AmountView.tapNextButton();

//Assert Address
const address = await SendView.splitAddressText();
await Assertions.checkIfTextMatches(address[0], INCORRECT_SEND_ADDRESS);

await SendView.tapBackButton();
await AmountView.tapBackButton();
await SendView.removeAddress();
await SendView.inputAddress(CORRECT_SEND_ADDRESS);
await SendView.tapNextButton();
await AmountView.typeInTransactionAmount('0.000001');

await AmountView.tapNextButton();

// Assert correct address
const correctAddress = await SendView.splitAddressText();
await Assertions.checkIfTextMatches(correctAddress[0], CORRECT_SEND_ADDRESS);

//Assert transactions send screen on IOS only due to android limitations
if (device.getPlatform() === 'ios') {
// Tap Send
await TransactionConfirmationView.tapConfirmButton();

// Transactions view to assert address remains consistent
await TabBarComponent.tapActivity();
await TestHelpers.delay(3000);
await TestHelpers.tapByText(ActivitiesViewSelectorsText.CONFIRM_TEXT);
await Assertions.checkIfTextIsDisplayed(`${SHORTHAND_ADDRESS}`);
}
},
);
});
},
);
1 change: 0 additions & 1 deletion e2e/utils/Assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class Assertions {
* @param {number} [timeout=TIMEOUT] - Timeout in milliseconds.
*/
static async checkIfElementHasLabel(elementId, label, timeout = TIMEOUT) {
// Rename me. The naming convention here is terrible.

return await waitFor(await elementId)
.toHaveLabel(label)
Expand Down
4 changes: 3 additions & 1 deletion e2e/utils/Gestures.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Gestures {
await element(by.text(new RegExp(`^/${textPattern} .*$/`))).tap();
}


/**
* Wait for an element to be visible and then tap it.
*
Expand Down Expand Up @@ -126,8 +127,9 @@ class Gestures {
* @param {Promise<Detox.IndexableNativeElement>} elementID - ID of the element to replace the text in
* @param {string} text - Text to replace the existing text in the element
*/
static async replaceTextInField(elementID, text) {
static async replaceTextInField(elementID, text, timeout = 10000) {
const element = await elementID;
await waitFor(element).toBeVisible().withTimeout(timeout);

await element.replaceText(text);
}
Expand Down

0 comments on commit a107c34

Please sign in to comment.