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

test(3615): add new e2e test for initial dapp connection and non permitted flow #12488

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
29082aa
test: e2e scenario where the user connects an in app browser dapp by …
EtherWizard33 Nov 28, 2024
c2a528a
test: e2e scenario checking that the non permitted flow bottom sheet …
EtherWizard33 Nov 29, 2024
7d99fe4
test: add a few steps to the non-permitted network test, as a tempora…
EtherWizard33 Dec 2, 2024
6065766
test: add an assertion to the non-permitted network to confirm the ch…
EtherWizard33 Dec 2, 2024
c4c087b
refactor: split non-permitted flow e2e test into 3 smaller tests
EtherWizard33 Dec 2, 2024
7e11118
Merge branch 'main' into test-3615-e2e-scenario-for-initial-connectio…
EtherWizard33 Dec 3, 2024
d0fc352
test: e2e scenario when the user checks the checkbox to add a change …
EtherWizard33 Dec 3, 2024
96730fe
test: Add some delays to let the toast disappear before clicking the …
EtherWizard33 Dec 3, 2024
53481c1
test: remove delay since it didnt fix the ci fail on toast, instead, …
EtherWizard33 Dec 3, 2024
f0faa65
Merge branch 'main' into test-3615-e2e-scenario-for-initial-connectio…
EtherWizard33 Dec 4, 2024
38ccb1e
test: remove the focus test (fit)
EtherWizard33 Dec 4, 2024
4d60310
test: add delay after switching network, since the toast coming hides…
EtherWizard33 Dec 5, 2024
3a47013
Merge branch 'main' into test-3615-e2e-scenario-for-initial-connectio…
EtherWizard33 Dec 5, 2024
cecc51d
style: lint
EtherWizard33 Dec 5, 2024
f891c91
test: update the tag to use SmokeMultiChain
EtherWizard33 Dec 5, 2024
c8fd5d3
Merge branch 'main' into test-3615-e2e-scenario-for-initial-connectio…
EtherWizard33 Dec 5, 2024
99a5144
Merge branch 'main' into test-3615-e2e-scenario-for-initial-connectio…
EtherWizard33 Dec 5, 2024
03319d7
refactor: use less local constants
EtherWizard33 Dec 5, 2024
d558ebb
Merge branch 'main' into test-3615-e2e-scenario-for-initial-connectio…
EtherWizard33 Dec 6, 2024
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
16 changes: 14 additions & 2 deletions app/components/UI/PermissionsSummary/PermissionsSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { selectProviderConfig } from '../../../selectors/networkController';
import { useNetworkInfo } from '../../../selectors/selectedNetworkController';
import { ConnectedAccountsSelectorsIDs } from '../../../../e2e/selectors/Browser/ConnectedAccountModal.selectors';
import { PermissionSummaryBottomSheetSelectorsIDs } from '../../../../e2e/selectors/Browser/PermissionSummaryBottomSheet.selectors';
import { NetworkNonPemittedBottomSheetSelectorsIDs } from '../../../../e2e/selectors/Network/NetworkNonPemittedBottomSheet.selectors';

const PermissionsSummary = ({
currentPageInformation,
Expand Down Expand Up @@ -272,7 +273,10 @@ const PermissionsSummary = ({
function renderAccountPermissionsRequestInfoCard() {
return (
<TouchableOpacity onPress={handleEditAccountsButtonPress}>
<View style={styles.accountPermissionRequestInfoCard} testID={PermissionSummaryBottomSheetSelectorsIDs.CONTAINER}>
<View
style={styles.accountPermissionRequestInfoCard}
testID={PermissionSummaryBottomSheetSelectorsIDs.CONTAINER}
>
<Avatar
variant={AvatarVariant.Icon}
style={styles.walletIcon}
Expand Down Expand Up @@ -408,7 +412,12 @@ const PermissionsSummary = ({
<View style={styles.mainContainer}>
<View>
{renderHeader()}
<View style={styles.title} testID={PermissionSummaryBottomSheetSelectorsIDs.NETWORK_PERMISSIONS_CONTAINER}>
<View
style={styles.title}
testID={
PermissionSummaryBottomSheetSelectorsIDs.NETWORK_PERMISSIONS_CONTAINER
}
>
<TextComponent variant={TextVariant.HeadingSM}>
{isNonDappNetworkSwitch
? strings('permissions.title_add_network_permission')
Expand Down Expand Up @@ -482,6 +491,9 @@ const PermissionsSummary = ({
<Button
variant={ButtonVariants.Primary}
label={strings('permissions.add_this_network')}
testID={
NetworkNonPemittedBottomSheetSelectorsIDs.ADD_THIS_NETWORK_BUTTON
}
onPress={onAddNetwork}
size={ButtonSize.Lg}
style={{
Expand Down
30 changes: 30 additions & 0 deletions e2e/pages/Network/NetworkNonPemittedBottomSheet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {
NetworkListModalSelectorsIDs,
NetworkListModalSelectorsText,
} from '../../selectors/Network/NetworkListModal.selectors';
import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';
import {
NetworkNonPemittedBottomSheetSelectorsIDs,
NetworkNonPemittedBottomSheetSelectorsText,
} from '../../selectors/Network/NetworkNonPemittedBottomSheet.selectors';

class NetworkNonPemittedBottomSheet {
get addThisNetworkTitle() {
return Matchers.getElementByText(
NetworkNonPemittedBottomSheetSelectorsText.ADD_THIS_NETWORK_TITLE,
);
}

get addThisNetworkButton() {
return Matchers.getElementByID(
NetworkNonPemittedBottomSheetSelectorsIDs.ADD_THIS_NETWORK_BUTTON,
);
}

async tapAddThisNetworkButton() {
await Gestures.waitAndTap(this.addThisNetworkButton);
}
}

export default new NetworkNonPemittedBottomSheet();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import enContent from '../../../locales/languages/en.json';

export const NetworkNonPemittedBottomSheetSelectorsText = {
ADD_THIS_NETWORK_TITLE: enContent.permissions.title_add_network_permission,
};

export const NetworkNonPemittedBottomSheetSelectorsIDs = {
ADD_THIS_NETWORK_BUTTON: 'add-this-network-button',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { Regression } from '../../tags';
import { loginToApp } from '../../viewHelper';
import WalletView from '../../pages/wallet/WalletView';
import NetworkListModal from '../../pages/Network/NetworkListModal';
import NetworkEducationModal from '../../pages/Network/NetworkEducationModal';
import Assertions from '../../utils/Assertions';
import TestHelpers from '../../helpers';
import FixtureBuilder from '../../fixtures/fixture-builder';
import { stopFixtureServer, withFixtures } from '../../fixtures/fixture-helper';
import FixtureServer from '../../fixtures/fixture-server';
import { CustomNetworks } from '../../resources/networks.e2e';
import Browser from '../../pages/Browser/BrowserView';
import TabBarComponent from '../../pages/TabBarComponent';
import NetworkNonPemittedBottomSheet from '../../pages/Network/NetworkNonPemittedBottomSheet';

const fixtureServer = new FixtureServer();
const ETHEREUM = 'Ethereum Main Network';

describe(Regression('Connect to a Test Network'), () => {
beforeAll(async () => {
await TestHelpers.reverseServerPort();
});

beforeEach(() => {
jest.setTimeout(150000);
});

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

it('should switch to test Network then dismiss the network education modal', async () => {
await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.withChainPermission()
.build(),
restartDevice: true,
},
async () => {
await loginToApp();
await TabBarComponent.tapBrowser();
await Assertions.checkIfVisible(Browser.browserScreenID);
// TODO 1: connect to test dapp
await Browser.navigateToTestDApp();

await TabBarComponent.tapWallet();
await Assertions.checkIfVisible(WalletView.container);
await WalletView.tapNetworksButtonOnNavBar();
await NetworkListModal.scrollToBottomOfNetworkList();
await Assertions.checkIfVisible(NetworkListModal.networkScroll);
await Assertions.checkIfToggleIsOn(NetworkListModal.testNetToggle);
await NetworkListModal.changeNetworkTo(
CustomNetworks.Sepolia.providerConfig.nickname,
);
await Assertions.checkIfVisible(NetworkEducationModal.container);
await Assertions.checkIfElementToHaveText(
NetworkEducationModal.networkName,
CustomNetworks.Sepolia.providerConfig.nickname,
);
await NetworkEducationModal.tapGotItButton();
await Assertions.checkIfNotVisible(NetworkEducationModal.container);
await Assertions.checkIfVisible(WalletView.container);

const networkPicker = await WalletView.getNavbarNetworkPicker();
await Assertions.checkIfElementHasLabel(
networkPicker,
CustomNetworks.Sepolia.providerConfig.nickname,
);

await TabBarComponent.tapBrowser();
// await Assertions.checkIfVisible(Browser.browserScreenID);

await Assertions.checkIfVisible(
NetworkNonPemittedBottomSheet.addThisNetworkTitle,
);

await NetworkNonPemittedBottomSheet.tapAddThisNetworkButton();
// two steps that might come in handy
// await Assertions.checkIfVisible(WalletView.container);
// const networkPicker = await WalletView.getNavbarNetworkPicker();
},
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';
import TestHelpers from '../../helpers';
import { SmokeCore } from '../../tags';
import Browser from '../../pages/Browser/BrowserView';
import TabBarComponent from '../../pages/TabBarComponent';
import NetworkListModal from '../../pages/Network/NetworkListModal';
import TestDApp from '../../pages/Browser/TestDApp';
import ConnectedAccountsModal from '../../pages/Browser/ConnectedAccountsModal';
import FixtureBuilder from '../../fixtures/fixture-builder';
import { withFixtures } from '../../fixtures/fixture-helper';
import { loginToApp } from '../../viewHelper';
import Assertions from '../../utils/Assertions';
import ConnectBottomSheet from '../../pages/Browser/ConnectBottomSheet';

describe(SmokeCore('MultiChain Permissions System:'), () => {
beforeAll(async () => {
jest.setTimeout(150000);
await TestHelpers.reverseServerPort();
});

it('should grant initial permissions for one account and one chain', async () => {
await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder().withPermissionController().build(),
restartDevice: true,
},
async () => {
await loginToApp();
await TabBarComponent.tapBrowser();
await Assertions.checkIfVisible(Browser.browserScreenID);

await Browser.navigateToTestDApp();
await TestDApp.connect();
await ConnectBottomSheet.tapConnectButton();

await Browser.tapNetworkAvatarButtonOnBrowser();
await Assertions.checkIfVisible(ConnectedAccountsModal.title);
},
);
});
});
Loading