diff --git a/test/e2e/flask/multichain-api/get-session.spec.ts b/test/e2e/flask/multichain-api/get-session.spec.ts index e1a43a20de7c..becc818a7b1e 100644 --- a/test/e2e/flask/multichain-api/get-session.spec.ts +++ b/test/e2e/flask/multichain-api/get-session.spec.ts @@ -1,13 +1,14 @@ +import { strict as assert } from 'assert'; import _ from 'lodash'; import { withFixtures } from '../../helpers'; import { Driver } from '../../webdriver/driver'; import FixtureBuilder from '../../fixture-builder'; import { DEFAULT_FIXTURE_ACCOUNT } from '../../constants'; import { - DEFAULT_OPTIONS, + DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS, getExpectedSessionScope, getSessionScopes, - openDappAndConnectWallet, + openMultichainDappAndConnectWalletWithExternallyConnectable, } from './testHelpers'; describe('Multichain API', function () { @@ -17,7 +18,7 @@ describe('Multichain API', function () { { title: this.test?.fullTitle(), fixtures: new FixtureBuilder().withPopularNetworks().build(), - ...DEFAULT_OPTIONS, + ...DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS, }, async ({ driver, @@ -26,12 +27,14 @@ describe('Multichain API', function () { driver: Driver; extensionId: string; }) => { - await openDappAndConnectWallet(driver, extensionId); + await openMultichainDappAndConnectWalletWithExternallyConnectable(driver, extensionId); const parsedResult = await getSessionScopes(driver); - if (!_.isEqual(parsedResult.sessionScopes, {})) { - throw new Error('Should receive empty session scopes'); - } + assert.deepStrictEqual( + parsedResult.sessionScopes, + {}, + 'Should receive empty session scopes', + ); }, ); }); @@ -46,7 +49,7 @@ describe('Multichain API', function () { .withPopularNetworks() .withPermissionControllerConnectedToTestDapp() .build(), - ...DEFAULT_OPTIONS, + ...DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS, }, async ({ driver, @@ -60,7 +63,7 @@ describe('Multichain API', function () { */ const DEFAULT_SCOPE = 'eip155:1337'; - await openDappAndConnectWallet(driver, extensionId); + await openMultichainDappAndConnectWalletWithExternallyConnectable(driver, extensionId); const parsedResult = await getSessionScopes(driver); const sessionScope = parsedResult.sessionScopes[DEFAULT_SCOPE]; @@ -68,11 +71,11 @@ describe('Multichain API', function () { DEFAULT_FIXTURE_ACCOUNT, ]); - if (!_.isEqual(sessionScope, expectedSessionScope)) { - throw new Error( - `Should receive result that specifies expected session scopes for ${DEFAULT_SCOPE}`, - ); - } + assert.deepStrictEqual( + sessionScope, + expectedSessionScope, + `Should receive result that specifies expected session scopes for ${DEFAULT_SCOPE}`, + ); }, ); }); diff --git a/test/e2e/flask/multichain-api/testHelpers.ts b/test/e2e/flask/multichain-api/testHelpers.ts index b39d18165c82..4c5bd3e82e18 100644 --- a/test/e2e/flask/multichain-api/testHelpers.ts +++ b/test/e2e/flask/multichain-api/testHelpers.ts @@ -1,11 +1,12 @@ import * as path from 'path'; import { DAPP_URL, largeDelayMs, openDapp, unlockWallet } from '../../helpers'; import { Driver } from '../../webdriver/driver'; +import { KnownRpcMethods, KnownNotifications } from '@metamask/multichain'; /** * Default options for setting up Multichain E2E test environment */ -export const DEFAULT_OPTIONS = { +export const DEFAULT_MULTICHAIN_TEST_DAPP_FIXTURE_OPTIONS = { dapp: true, dappPaths: [ path.join( @@ -25,7 +26,7 @@ export const DEFAULT_OPTIONS = { * @param {Driver} driver - E2E test driver {@link Driver}, wrapping the Selenium WebDriver. * @param extensionId - Extension identifier for web dapp to interact with wallet extension. */ -export async function openDappAndConnectWallet( +export async function openMultichainDappAndConnectWalletWithExternallyConnectable( driver: Driver, extensionId: string, ): Promise { @@ -67,47 +68,7 @@ export async function getSessionScopes( * @returns the expected session scope. */ export const getExpectedSessionScope = (scope: string, accounts: string[]) => ({ - methods: [ - 'personal_sign', - 'eth_signTypedData_v4', - 'wallet_watchAsset', - 'eth_sendTransaction', - 'eth_decrypt', - 'eth_getEncryptionPublicKey', - 'web3_clientVersion', - 'eth_subscribe', - 'eth_unsubscribe', - 'eth_blockNumber', - 'eth_call', - 'eth_chainId', - 'eth_estimateGas', - 'eth_feeHistory', - 'eth_gasPrice', - 'eth_getBalance', - 'eth_getBlockByHash', - 'eth_getBlockByNumber', - 'eth_getBlockTransactionCountByHash', - 'eth_getBlockTransactionCountByNumber', - 'eth_getCode', - 'eth_getFilterChanges', - 'eth_getFilterLogs', - 'eth_getLogs', - 'eth_getProof', - 'eth_getStorageAt', - 'eth_getTransactionByBlockHashAndIndex', - 'eth_getTransactionByBlockNumberAndIndex', - 'eth_getTransactionByHash', - 'eth_getTransactionCount', - 'eth_getTransactionReceipt', - 'eth_getUncleCountByBlockHash', - 'eth_getUncleCountByBlockNumber', - 'eth_newBlockFilter', - 'eth_newFilter', - 'eth_newPendingTransactionFilter', - 'eth_sendRawTransaction', - 'eth_syncing', - 'eth_uninstallFilter', - ], - notifications: ['eth_subscription'], + methods: KnownRpcMethods.eip155, + notifications: KnownNotifications.eip155, accounts: accounts.map((acc) => `${scope}:${acc.toLowerCase()}`), });