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

feat: added create solana account test #28866

Merged
merged 77 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
2c8211f
chore: solana changes to work locally
ulissesferreira Nov 11, 2024
17c2be1
feat: added mocks for solana snap on flask tests
javiergarciavera Dec 2, 2024
0d894c6
feat: added create solana account test
javiergarciavera Dec 3, 2024
1338d6e
feat: updated snapId to not run locally
javiergarciavera Dec 3, 2024
236603b
feat: create-account scenario working
javiergarciavera Dec 3, 2024
cccee7d
feat: added create/remove solana account
javiergarciavera Dec 3, 2024
2144433
feat: fixed tests
javiergarciavera Dec 3, 2024
7fd295c
feat: tests done
javiergarciavera Dec 5, 2024
54a195a
feat: rebase main
javiergarciavera Dec 5, 2024
a0e0313
feat: rebase
javiergarciavera Dec 5, 2024
7960ad6
feat: revert builds.yml
javiergarciavera Dec 5, 2024
9f81c4e
Merge branch 'main' into create-solana-account-e2e
danjm Dec 6, 2024
7834f81
feat: upgraded solana snap version
javiergarciavera Dec 10, 2024
4df5496
feat: rebase
javiergarciavera Dec 10, 2024
6ad09a4
feat: upgrade snap version
javiergarciavera Dec 10, 2024
b5b3f4f
feat: added solana to the flask build
javiergarciavera Dec 10, 2024
3ba9c0d
feat: fix lint
javiergarciavera Dec 10, 2024
a2c10f5
feat: fixed flakiness
javiergarciavera Dec 10, 2024
3ff0057
feat: updated policy
javiergarciavera Dec 10, 2024
faa7e9d
feat: fix lint
javiergarciavera Dec 10, 2024
ea3683f
feat: fixes conflicts
javiergarciavera Dec 10, 2024
625f83f
feat: fix conflict
javiergarciavera Dec 10, 2024
cae684d
feat: fixed conflicts on yarn.lock
javiergarciavera Dec 10, 2024
6dac98b
feat: fix flakiness waiting for a component
javiergarciavera Dec 10, 2024
8dddaef
feat: fix flakiness
javiergarciavera Dec 10, 2024
0c4d836
feat: fixed flakiness
javiergarciavera Dec 10, 2024
45f6a7f
feat: added beforeEach to make sure there is no data from previous tests
javiergarciavera Dec 10, 2024
ec0f28a
feat: adding logs for debugging
javiergarciavera Dec 10, 2024
869945e
feat: lint
javiergarciavera Dec 10, 2024
952170c
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 10, 2024
290bd40
feat: commit signedg
javiergarciavera Dec 10, 2024
87ac7ce
Merge branch 'create-solana-account-e2e' of github.com:MetaMask/metam…
javiergarciavera Dec 10, 2024
5bf1593
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 11, 2024
467e733
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 11, 2024
72cf25d
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 11, 2024
418aaf3
feat: some refactor and changes according to the PR reviews
javiergarciavera Dec 12, 2024
e5e101e
feat: fixed yarn conflicts
javiergarciavera Dec 12, 2024
e657fe5
Update test/e2e/helpers.js
javiergarciavera Dec 13, 2024
6554147
Update test/e2e/page-objects/pages/account-list-page.ts
javiergarciavera Dec 13, 2024
2c428df
Update test/e2e/flask/btc/create-btc-account.spec.ts
javiergarciavera Dec 13, 2024
b0773c0
Update test/e2e/flask/btc/create-btc-account.spec.ts
javiergarciavera Dec 13, 2024
88ba05a
Update test/e2e/flask/solana/create-solana-account.spec.ts
javiergarciavera Dec 13, 2024
633c78f
Update test/e2e/flask/solana/create-solana-account.spec.ts
javiergarciavera Dec 13, 2024
9a8fe8b
feat: some changes added
javiergarciavera Dec 13, 2024
073a260
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 16, 2024
969b9af
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 16, 2024
b7eceaa
feat: fix lint
javiergarciavera Dec 16, 2024
0036f99
feat: rebased
javiergarciavera Dec 16, 2024
4857e0a
feat: fix flakiness
javiergarciavera Dec 16, 2024
4f8ff1b
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 16, 2024
f73db41
feat: debugging
javiergarciavera Dec 16, 2024
8ddce56
feat: added pre/post test clean up
javiergarciavera Dec 16, 2024
349a482
feat: removing before/after
javiergarciavera Dec 16, 2024
265bd29
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 17, 2024
296027b
feat: added network picker availability tests
javiergarciavera Dec 17, 2024
6c8be2b
feat: code review fixes
javiergarciavera Dec 17, 2024
0b111d0
feat: rebase
javiergarciavera Dec 17, 2024
dc70ccf
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 18, 2024
d1579b7
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 18, 2024
114bc54
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 18, 2024
6697e3f
feat: added condition to avoid a known exception
javiergarciavera Dec 18, 2024
b76efdd
Merge branch 'create-solana-account-e2e' of github.com:MetaMask/metam…
javiergarciavera Dec 18, 2024
752649d
feat: rebased
javiergarciavera Dec 18, 2024
bb2406d
feat: remove .only
javiergarciavera Dec 18, 2024
27e9494
feat: skipped 2 scenarios due to this ticket https://consensyssoftwar…
javiergarciavera Dec 18, 2024
9f2c743
feat: added code improvement
javiergarciavera Dec 18, 2024
5b58f5a
feat: added ticket number in the test skipped
javiergarciavera Dec 18, 2024
f23b8cd
Merge branch 'main' of github.com:MetaMask/metamask-extension into cr…
javiergarciavera Dec 18, 2024
c6eed85
feat: reverted changes after rebasing
javiergarciavera Dec 18, 2024
ee2a9cb
feat: changed prefrom unlockWallet to loginWithBalanceValidation
javiergarciavera Dec 18, 2024
90bcff7
added tsdoc to addAccount function
javiergarciavera Dec 18, 2024
41a7b87
feat: lint fix
javiergarciavera Dec 18, 2024
c0d7e52
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 18, 2024
2dbb437
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 18, 2024
6f57668
Merge branch 'main' into create-solana-account-e2e
javiergarciavera Dec 19, 2024
b82bfe3
feat: fixed check number of available accounts
javiergarciavera Dec 19, 2024
72029fc
feat: changed call to wait
javiergarciavera Dec 19, 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
1 change: 1 addition & 0 deletions test/data/mock-state.json
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,7 @@
"watchEthereumAccountEnabled": false,
"bitcoinSupportEnabled": false,
"bitcoinTestnetSupportEnabled": false,
"solanaSupportEnabled": false,
"pendingApprovals": {
"testApprovalId": {
"id": "testApprovalId",
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export const DEFAULT_BTC_FEES_RATE = 0.00001; // BTC
/* Default BTC conversion rate to USD */
export const DEFAULT_BTC_CONVERSION_RATE = 62000; // USD

/* Default SOL conversion rate to USD */
export const DEFAULT_SOL_CONVERSION_RATE = 226; // USD

/* Default BTC transaction ID */
export const DEFAULT_BTC_TRANSACTION_ID =
'e4111a707317da67d49a71af4cbcf6c0546f900ca32c3842d2254e315d1fca18';
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/flask/btc/common-btc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Driver } from '../../webdriver/driver';
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
import AccountListPage from '../../page-objects/pages/account-list-page';
import HeaderNavbar from '../../page-objects/pages/header-navbar';
import { ACCOUNT_TYPE } from '../../page-objects/common';

const QUICKNODE_URL_REGEX = /^https:\/\/.*\.btc.*\.quiknode\.pro(\/|$)/u;

Expand Down Expand Up @@ -217,7 +218,7 @@ export async function withBtcAccountSnap(
await new HeaderNavbar(driver).openAccountMenu();
const accountListPage = new AccountListPage(driver);
await accountListPage.check_pageIsLoaded();
await accountListPage.addNewBtcAccount();
await accountListPage.addAccount(ACCOUNT_TYPE.Bitcoin, '');
await test(driver, mockServer);
},
);
Expand Down
25 changes: 15 additions & 10 deletions test/e2e/flask/btc/create-btc-account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import LoginPage from '../../page-objects/pages/login-page';
import PrivacySettings from '../../page-objects/pages/settings/privacy-settings';
import ResetPasswordPage from '../../page-objects/pages/reset-password-page';
import SettingsPage from '../../page-objects/pages/settings/settings-page';
import { ACCOUNT_TYPE } from '../../page-objects/common';
import { withBtcAccountSnap } from './common-btc';

describe('Create BTC Account', function (this: Suite) {
Expand Down Expand Up @@ -34,14 +35,12 @@ describe('Create BTC Account', function (this: Suite) {
await headerNavbar.openAccountMenu();
const accountListPage = new AccountListPage(driver);
await accountListPage.check_pageIsLoaded();
await accountListPage.addNewBtcAccount({
btcAccountCreationEnabled: false,
});

// check the number of available accounts is 2
await headerNavbar.openAccountMenu();
await accountListPage.check_pageIsLoaded();
await accountListPage.check_numberOfAvailableAccounts(2);
await accountListPage.openAddAccountModal();
assert.equal(
await accountListPage.isBtcAccountCreationButtonEnabled(),
false,
);
},
);
});
Expand Down Expand Up @@ -91,8 +90,14 @@ describe('Create BTC Account', function (this: Suite) {

// Recreate account and check that the address is the same
await headerNavbar.openAccountMenu();
await accountListPage.check_pageIsLoaded();
javiergarciavera marked this conversation as resolved.
Show resolved Hide resolved
await accountListPage.addNewBtcAccount();
await accountListPage.openAddAccountModal();
assert.equal(
await accountListPage.isBtcAccountCreationButtonEnabled(),
true,
);
await accountListPage.closeAccountModal();
await headerNavbar.openAccountMenu();
await accountListPage.addAccount(ACCOUNT_TYPE.Bitcoin, '');
await headerNavbar.check_accountLabel('Bitcoin Account');

await headerNavbar.openAccountMenu();
Expand Down Expand Up @@ -146,7 +151,7 @@ describe('Create BTC Account', function (this: Suite) {
await headerNavbar.check_pageIsLoaded();
await headerNavbar.openAccountMenu();
await accountListPage.check_pageIsLoaded();
await accountListPage.addNewBtcAccount();
await accountListPage.addAccount(ACCOUNT_TYPE.Bitcoin, '');
await headerNavbar.check_accountLabel('Bitcoin Account');

await headerNavbar.openAccountMenu();
Expand Down
71 changes: 71 additions & 0 deletions test/e2e/flask/solana/common-solana.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { Mockttp } from 'mockttp';
import { withFixtures } from '../../helpers';
import { Driver } from '../../webdriver/driver';
import HeaderNavbar from '../../page-objects/pages/header-navbar';
import AccountListPage from '../../page-objects/pages/account-list-page';
import FixtureBuilder from '../../fixture-builder';
import { ACCOUNT_TYPE } from '../../page-objects/common';
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';

const SOLANA_URL_REGEX = /^https:\/\/.*\.solana.*/u;

export enum SendFlowPlaceHolders {
AMOUNT = 'Enter amount to send',
RECIPIENT = 'Enter receiving address',
LOADING = 'Preparing transaction',
}

export async function mockSolanaBalanceQuote(mockServer: Mockttp) {
return await mockServer
.forPost(SOLANA_URL_REGEX)
.withJsonBodyIncluding({
method: 'getBalance',
})
.thenCallback(() => {
return {
statusCode: 200,
json: {
result: {
context: {
apiVersion: '2.0.15',
slot: 305352614,
},
value: 0,
},
},
};
});
}

export async function withSolanaAccountSnap(
{
title,
solanaSupportEnabled,
}: { title?: string; solanaSupportEnabled?: boolean },
test: (driver: Driver, mockServer: Mockttp) => Promise<void>,
) {
console.log('Starting withSolanaAccountSnap');
await withFixtures(
{
fixtures: new FixtureBuilder()
.withPreferencesControllerAndFeatureFlag({
solanaSupportEnabled: solanaSupportEnabled ?? true,
})
.build(),
title,
dapp: true,
testSpecificMock: async (mockServer: Mockttp) => {
console.log('Setting up test-specific mocks');
return [await mockSolanaBalanceQuote(mockServer)];
},
},
async ({ driver, mockServer }: { driver: Driver; mockServer: Mockttp }) => {
await loginWithBalanceValidation(driver);
const headerComponen = new HeaderNavbar(driver);
await headerComponen.openAccountMenu();
const accountListPage = new AccountListPage(driver);
await accountListPage.addAccount(ACCOUNT_TYPE.Solana, 'Solana 1');
await test(driver, mockServer);
},
);
}
62 changes: 62 additions & 0 deletions test/e2e/flask/solana/create-solana-account.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Suite } from 'mocha';
import HeaderNavbar from '../../page-objects/pages/header-navbar';
import AccountListPage from '../../page-objects/pages/account-list-page';
import { ACCOUNT_TYPE } from '../../page-objects/common';
import { withSolanaAccountSnap } from './common-solana';

// Scenarios skipped due to https://consensyssoftware.atlassian.net/browse/SOL-87
describe('Create Solana Account', function (this: Suite) {
it.skip('Creates 2 Solana accounts', async function () {
await withSolanaAccountSnap(
{ title: this.test?.fullTitle() },
async (driver) => {
// check that we have one Solana account
const headerNavbar = new HeaderNavbar(driver);
await headerNavbar.check_pageIsLoaded();
await headerNavbar.check_accountLabel('Solana 1');
await headerNavbar.openAccountMenu();
const accountListPage = new AccountListPage(driver);
await accountListPage.check_accountDisplayedInAccountList('Account 1');
await accountListPage.addAccount(ACCOUNT_TYPE.Solana, 'Solana 2');
await headerNavbar.check_accountLabel('Solana 2');
await headerNavbar.openAccountMenu();
await accountListPage.check_numberOfAvailableAccounts(3);
},
);
});
it('Creates a Solana account from the menu', async function () {
await withSolanaAccountSnap(
{ title: this.test?.fullTitle() },
async (driver) => {
const headerNavbar = new HeaderNavbar(driver);
await headerNavbar.check_pageIsLoaded();
await headerNavbar.check_accountLabel('Solana 1');
await headerNavbar.openAccountMenu();
const accountListPage = new AccountListPage(driver);
await accountListPage.check_accountDisplayedInAccountList('Account 1');
await accountListPage.check_accountDisplayedInAccountList('Solana 1');
},
);
});
});
it.skip('Removes Solana account after creating it', async function () {
await withSolanaAccountSnap(
{ title: this.test?.fullTitle() },
async (driver) => {
// check that we have one Solana account
const headerNavbar = new HeaderNavbar(driver);
await headerNavbar.check_accountLabel('Solana 1');
// check user can cancel the removal of the Solana account
await headerNavbar.openAccountMenu();
const accountListPage = new AccountListPage(driver);
await accountListPage.check_accountDisplayedInAccountList('Account 1');
await accountListPage.removeAccount('Solana 1', true);
await headerNavbar.check_accountLabel('Account 1');
await headerNavbar.openAccountMenu();
await accountListPage.check_accountDisplayedInAccountList('Account 1');
await accountListPage.check_accountIsNotDisplayedInAccountList(
'Solana 1',
);
},
);
});
24 changes: 24 additions & 0 deletions test/e2e/flask/solana/solana-eth-networks.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Suite } from 'mocha';
import HeaderNavbar from '../../page-objects/pages/header-navbar';
import AccountListPage from '../../page-objects/pages/account-list-page';
import { withSolanaAccountSnap } from './common-solana';

describe('Solana/Evm accounts', function (this: Suite) {
it('Network picker is disabled when Solana account is selected', async function () {
await withSolanaAccountSnap(
{ title: this.test?.fullTitle() },
async (driver) => {
const headerNavbar = new HeaderNavbar(driver);
await headerNavbar.check_pageIsLoaded();
await headerNavbar.check_accountLabel('Solana 1');
await headerNavbar.check_currentSelectedNetwork('Solana');
await headerNavbar.check_ifNetworkPickerClickable(false);
await headerNavbar.openAccountMenu();
const accountMenu = new AccountListPage(driver);
await accountMenu.switchToAccount('Account 1');
await headerNavbar.check_currentSelectedNetwork('Localhost 8545');
await headerNavbar.check_ifNetworkPickerClickable(true);
},
);
});
});
6 changes: 6 additions & 0 deletions test/e2e/page-objects/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ export type RawLocator =
| string
| { css?: string; text?: string }
| { tag: string; text: string };

export enum ACCOUNT_TYPE {
Ethereum,
Bitcoin,
Solana,
}
Loading
Loading