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: Enable Fixtures in E2E some tests tagged "Regression" #7402

Merged
merged 2 commits into from
Oct 10, 2023
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 bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ workflows:
curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@$APK_PATH" -F 'data={"custom_id": "'$CUSTOM_ID'"}' | jq -j '.app_url' | envman add --key BROWSERSTACK_APP_URL
APK_PATH_FOR_APP_LIVE=$PROJECT_LOCATION/app/build/outputs/apk/qa/release/"$CUSTOM_ID".apk
mv "$APK_PATH" "$APK_PATH_FOR_APP_LIVE"
curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$APK_PATH_FOR_APP_LIVE" -F 'data={"custom_id": "'$CUSTOM_ID'"}'
curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$APK_PATH_FOR_APP_LIVE" -F 'data={"custom_id": "'$CUSTOM_ID'"}'
curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X GET https://api-cloud.browserstack.com/app-automate/recent_apps | jq > browserstack_uploaded_apps.json
- deploy-to-bitrise-io@2.2.3:
is_always_run: false
Expand Down Expand Up @@ -757,7 +757,7 @@ workflows:
IPA_PATH_FOR_APP_LIVE=ios/build/output/"$CUSTOM_ID".ipa
curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-automate/upload" -F "file=@$IPA_PATH" -F 'data={"custom_id": "'$CUSTOM_ID'"}' | jq -j '.app_url' | envman add --key BROWSERSTACK_APP_URL
mv "$IPA_PATH" "$IPA_PATH_FOR_APP_LIVE"
curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$IPA_PATH_FOR_APP_LIVE" -F 'data={"custom_id": "'$CUSTOM_ID'"}'
curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X POST "https://api-cloud.browserstack.com/app-live/upload" -F "file=@$IPA_PATH_FOR_APP_LIVE" -F 'data={"custom_id": "'$CUSTOM_ID'"}'
curl -u "$BROWSERSTACK_USERNAME:$BROWSERSTACK_ACCESS_KEY" -X GET https://api-cloud.browserstack.com/app-automate/recent_apps | jq > browserstack_uploaded_apps.json
- deploy-to-bitrise-io@2.2.3:
is_always_run: false
Expand Down
5 changes: 5 additions & 0 deletions e2e/pages/modals/ConnectedAccountsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ export default class ConnectedAccountsModal {
static async isNotVisible() {
await TestHelpers.checkIfNotVisible(CONNECTED_ACCOUNTS_MODAL_CONTAINER);
}

static async scrollToBottomOfModal() {
await TestHelpers.swipe(CONNECTED_ACCOUNTS_MODAL_CONTAINER, 'down', 'slow');
await TestHelpers.delay(1000);
}
}
33 changes: 26 additions & 7 deletions e2e/specs/add-custom-rpc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,41 @@ import SettingsView from '../pages/Drawer/Settings/SettingsView';
import NetworkListModal from '../pages/modals/NetworkListModal';
import NetworkEducationModal from '../pages/modals/NetworkEducationModal';

import { CreateNewWallet } from '../viewHelper';
import { loginToApp } from '../viewHelper';
import TabBarComponent from '../pages/TabBarComponent';

import FixtureBuilder from '../fixtures/fixture-builder';
import {
loadFixture,
startFixtureServer,
stopFixtureServer,
} from '../fixtures/fixture-helper';
import { getFixturesServerPort } from '../utils';
import FixtureServer from '../fixtures/fixture-server';

const fixtureServer = new FixtureServer();
const GORELI = 'Goerli Test Network';
const XDAI_URL = 'https://rpc.gnosischain.com';
const MAINNET = 'Ethereum Main Network';

describe(Regression('Custom RPC Tests'), () => {
beforeAll(async () => {
await TestHelpers.reverseServerPort();
const fixture = new FixtureBuilder().build();
await startFixtureServer(fixtureServer);
await loadFixture(fixtureServer, { fixture });
await device.launchApp({
delete: true,
launchArgs: { fixtureServerPort: `${getFixturesServerPort()}` },
});
await loginToApp();
});

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

it('should create new wallet', async () => {
await CreateNewWallet();
afterAll(async () => {
await stopFixtureServer(fixtureServer);
});

it('should go to settings then networks', async () => {
Expand Down Expand Up @@ -70,8 +91,6 @@ describe(Regression('Custom RPC Tests'), () => {
});

it('should switch to Goreli then dismiss the network education modal', async () => {
await NetworkListModal.isVisible();
await NetworkListModal.tapTestNetworkSwitch();
await NetworkListModal.isTestNetworkToggleOn();
await NetworkListModal.changeNetwork(GORELI);

Expand Down
150 changes: 69 additions & 81 deletions e2e/specs/permission-system-delete-wallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,104 +11,92 @@ import WalletView from '../pages/WalletView';
import Browser from '../pages/Drawer/Browser';
import SettingsView from '../pages/Drawer/Settings/SettingsView';

import { BROWSER_SCREEN_ID } from '../../wdio/screen-objects/testIDs/BrowserScreen/BrowserScreen.testIds';

import TabBarComponent from '../pages/TabBarComponent';

import SkipAccountSecurityModal from '../pages/modals/SkipAccountSecurityModal';
import ConnectedAccountsModal from '../pages/modals/ConnectedAccountsModal';
import ConnectModal from '../pages/modals/ConnectModal';
import DeleteWalletModal from '../pages/modals/DeleteWalletModal';
import SecurityAndPrivacyView from '../pages/Drawer/Settings/SecurityAndPrivacy/SecurityAndPrivacyView';
import NetworkListModal from '../pages/modals/NetworkListModal';

import {
importWalletWithRecoveryPhrase,
testDappConnectButtonCooridinates,
} from '../viewHelper';
import { loginToApp } from '../viewHelper';
import FixtureBuilder from '../fixtures/fixture-builder';
import { withFixtures } from '../fixtures/fixture-helper';
import MetaMetricsOptIn from '../pages/Onboarding/MetaMetricsOptInView';
import ProtectYourWalletModal from '../pages/modals/ProtectYourWalletModal';

const TEST_DAPP = 'https://metamask.github.io/test-dapp/';
const PASSWORD = '12345678';
describe(
Regression('Permission System: Deleting wallet after connecting to a dapp'),
() => {
beforeEach(() => {
beforeAll(async () => {
jest.setTimeout(150000);
await TestHelpers.reverseServerPort();
});

it('should import wallet and go to the wallet view', async () => {
await importWalletWithRecoveryPhrase();
});

it('should navigate to browser', async () => {
await TabBarComponent.tapBrowser();
await Browser.isVisible();
});

it('should connect to the test dapp', async () => {
await TestHelpers.delay(3000);
// Tap on search in bottom navbar
await Browser.tapUrlInputBox();
await Browser.navigateToURL(TEST_DAPP);
await TestHelpers.delay(3000);
await TestHelpers.tapAtPoint(
BROWSER_SCREEN_ID,
testDappConnectButtonCooridinates,
it('should no longer be connected to the dapp after deleting and creating a new wallet', async () => {
await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
restartDevice: true,
},
async () => {
await loginToApp();

//validate connection to test dapp
await TabBarComponent.tapBrowser();
await Browser.isVisible();
await Browser.navigateToTestDApp();
await Browser.tapNetworkAvatarButtonOnBrowserWhileAccountIsConnectedToDapp();
await ConnectedAccountsModal.isVisible();
await NetworkListModal.isNotVisible();
await ConnectedAccountsModal.scrollToBottomOfModal();

//go to settings then security & privacy
await TabBarComponent.tapSettings();
await SettingsView.tapSecurityAndPrivacy();
await SecurityAndPrivacyView.scrollToChangePasswordView();
await SecurityAndPrivacyView.isChangePasswordSectionVisible();
await SecurityAndPrivacyView.scrollToDeleteWalletButton();
await SecurityAndPrivacyView.tapDeleteWalletButton();

//Delete wallet
await DeleteWalletModal.tapIUnderstandButton();
await DeleteWalletModal.typeDeleteInInputBox();
await DeleteWalletModal.tapDeleteMyWalletButton();
await TestHelpers.delay(2000);
await OnboardingView.isVisible();
await OnboardingView.deleteWalletToastisNotVisible();
await OnboardingView.tapCreateWallet();

//Create new wallet
await MetaMetricsOptIn.isVisible();
await MetaMetricsOptIn.tapAgreeButton();
await CreatePasswordView.isVisible();
await CreatePasswordView.enterPassword(PASSWORD);
await CreatePasswordView.reEnterPassword(PASSWORD);
await CreatePasswordView.tapIUnderstandCheckBox();
await CreatePasswordView.tapCreatePasswordButton();
await ProtectYourWalletView.isVisible();
await ProtectYourWalletView.tapOnRemindMeLaterButton();
await SkipAccountSecurityModal.tapIUnderstandCheckBox();
await SkipAccountSecurityModal.tapSkipButton();
await WalletView.isVisible();
await ProtectYourWalletModal.tapRemindMeLaterButton();
await SkipAccountSecurityModal.tapIUnderstandCheckBox();
await SkipAccountSecurityModal.tapSkipButton();

//should no longer be connected to the dapp
await TabBarComponent.tapBrowser();
await Browser.isVisible();
await Browser.tapNetworkAvatarButtonOnBrowser();
await ConnectedAccountsModal.isNotVisible();
await NetworkListModal.isVisible();
},
);
await ConnectModal.isVisible();
await ConnectModal.tapConnectButton();
});
it('should go to settings then security & privacy', async () => {
await TestHelpers.delay(3500); // need a better way to wait until the toast message disappear

await TabBarComponent.tapSettings();
await SettingsView.tapSecurityAndPrivacy();
});

it('should delete wallet from settings and privacy view', async () => {
await SecurityAndPrivacyView.scrollToChangePasswordView();
await SecurityAndPrivacyView.isChangePasswordSectionVisible();
await SecurityAndPrivacyView.scrollToDeleteWalletButton();
await SecurityAndPrivacyView.tapDeleteWalletButton();
});

it('should delete wallet', async () => {
await DeleteWalletModal.tapIUnderstandButton();
await DeleteWalletModal.typeDeleteInInputBox();
await DeleteWalletModal.tapDeleteMyWalletButton();
await TestHelpers.delay(2000);
await OnboardingView.isVisible();
});

it('should create new wallet', async () => {
await OnboardingView.deleteWalletToastisNotVisible();
await OnboardingView.tapCreateWallet();

await CreatePasswordView.isVisible();
await CreatePasswordView.enterPassword(PASSWORD);
await CreatePasswordView.reEnterPassword(PASSWORD);
await CreatePasswordView.tapIUnderstandCheckBox();
await CreatePasswordView.tapCreatePasswordButton();
});

it('Should skip backup check', async () => {
await ProtectYourWalletView.isVisible();
await ProtectYourWalletView.tapOnRemindMeLaterButton();

await SkipAccountSecurityModal.tapIUnderstandCheckBox();
await SkipAccountSecurityModal.tapSkipButton();
await WalletView.isVisible();
});

it('should go to browser', async () => {
await TabBarComponent.tapBrowser();
await Browser.isVisible();
});

it('should no longer be connected to the dapp', async () => {
await Browser.tapNetworkAvatarButtonOnBrowser();
await ConnectedAccountsModal.isNotVisible();
await NetworkListModal.isVisible();
});
},
);
67 changes: 30 additions & 37 deletions e2e/specs/permission-system-revoke-single-account.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,40 @@ import TabBarComponent from '../pages/TabBarComponent';

import NetworkListModal from '../pages/modals/NetworkListModal';
import ConnectedAccountsModal from '../pages/modals/ConnectedAccountsModal';
import ConnectModal from '../pages/modals/ConnectModal';

import { CreateNewWallet } from '../viewHelper';
import FixtureBuilder from '../fixtures/fixture-builder';
import { withFixtures } from '../fixtures/fixture-helper';
import { loginToApp } from '../viewHelper';

describe(Regression('Revoke Single Account after connecting to a dapp'), () => {
beforeEach(() => {
beforeAll(async () => {
jest.setTimeout(150000);
await TestHelpers.reverseServerPort();
});

it('should create new wallet', async () => {
await CreateNewWallet();
});

it('should navigate to browser', async () => {
await TabBarComponent.tapBrowser();
// Check that we are on the browser screen
await Browser.isVisible();
});

it('should connect to the test dapp', async () => {
await Browser.goToTestDappAndTapConnectButton();

await ConnectModal.tapConnectButton();

await ConnectModal.isNotVisible();
});

it('should revoke accounts', async () => {
await TestHelpers.delay(3000);
await Browser.tapNetworkAvatarButtonOnBrowserWhileAccountIsConnectedToDapp();
// await Browser.tapNetworkAvatarButtonOnBrowser();
await ConnectedAccountsModal.tapPermissionsButton();
await ConnectedAccountsModal.tapDisconnectAllButton();
await Browser.isAccountToastVisible('Account 1');

await TestHelpers.delay(5500);
});

it('should no longer be connected to the dapp', async () => {
await Browser.tapNetworkAvatarButtonOnBrowser();
await ConnectedAccountsModal.isNotVisible();
await NetworkListModal.isVisible();
it('should no longer be connected to the dapp after deleting and creating a new wallet', async () => {
await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
restartDevice: true,
},
async () => {
await loginToApp();
await TabBarComponent.tapBrowser();
await Browser.isVisible();
await Browser.navigateToTestDApp();
await Browser.tapNetworkAvatarButtonOnBrowserWhileAccountIsConnectedToDapp();
await ConnectedAccountsModal.tapPermissionsButton();
await ConnectedAccountsModal.tapDisconnectAllButton();
await Browser.isAccountToastVisible('Account 1');

await TestHelpers.delay(5500);
await Browser.tapNetworkAvatarButtonOnBrowser();
await ConnectedAccountsModal.isNotVisible();
await NetworkListModal.isVisible();
},
);
});
});