From 931da551fd73279486360ec4b8042bfcec7c4910 Mon Sep 17 00:00:00 2001 From: Shane Jonas Date: Wed, 9 Oct 2024 15:14:29 -0400 Subject: [PATCH 1/3] fix: get wallet_getSession/revokeSession passing --- test/e2e/run-api-specs-multichain.ts | 29 ++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/test/e2e/run-api-specs-multichain.ts b/test/e2e/run-api-specs-multichain.ts index d0150e45d267..8c2e20ed8b28 100644 --- a/test/e2e/run-api-specs-multichain.ts +++ b/test/e2e/run-api-specs-multichain.ts @@ -6,7 +6,7 @@ import { MetaMaskOpenRPCDocument, } from '@metamask/api-specs'; -import { MethodObject, OpenrpcDocument } from '@open-rpc/meta-schema'; +import { ContentDescriptorObject, MethodObject, OpenrpcDocument } from '@open-rpc/meta-schema'; import JsonSchemaFakerRule from '@open-rpc/test-coverage/build/rules/json-schema-faker-rule'; import ExamplesRule from '@open-rpc/test-coverage/build/rules/examples-rule'; import { Call, IOptions } from '@open-rpc/test-coverage/build/coverage'; @@ -173,6 +173,22 @@ async function main() { ); server.start(); + const getSession = doc.methods.find( + (m) => (m as MethodObject).name === 'wallet_getSession', + ); + (getSession as MethodObject).examples = [ + { + name: 'wallet_getSessionExample', + description: 'Example of a provider authorization request.', + params: [], + result: { + name: 'wallet_getSessionResultExample', + value: { + sessionScopes: {}, + }, + }, + }, + ]; const testCoverageResults = await testCoverage({ openrpcDocument: doc, @@ -180,13 +196,10 @@ async function main() { reporters: ['console-streaming'], skip: ['wallet_invokeMethod'], rules: [ - // new ExamplesRule({ - // skip: [], - // only: [ - // 'wallet_getSession', - // 'wallet_revokeSession' - // ], - // }), + new ExamplesRule({ + skip: [], + only: ['wallet_getSession', 'wallet_revokeSession'], + }), new MultichainAuthorizationConfirmation({ driver, }), From 2282c93ff124d969cadb267a047813145c91b7ff Mon Sep 17 00:00:00 2001 From: Jiexi Luan Date: Wed, 9 Oct 2024 14:14:40 -0700 Subject: [PATCH 2/3] lint --- test/e2e/api-specs/ConfirmationRejectionRule.ts | 1 - test/e2e/run-api-specs-multichain.ts | 13 +++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/test/e2e/api-specs/ConfirmationRejectionRule.ts b/test/e2e/api-specs/ConfirmationRejectionRule.ts index 20b77b022a5a..7e8085fb97b2 100644 --- a/test/e2e/api-specs/ConfirmationRejectionRule.ts +++ b/test/e2e/api-specs/ConfirmationRejectionRule.ts @@ -113,7 +113,6 @@ export class ConfirmationsRejectRule implements Rule { await this.driver.executeScript( `window.ethereum.request(${switchEthereumChainRequest})`, ); - } } catch (e) { console.log(e); diff --git a/test/e2e/run-api-specs-multichain.ts b/test/e2e/run-api-specs-multichain.ts index 8c2e20ed8b28..9f56e65eb29d 100644 --- a/test/e2e/run-api-specs-multichain.ts +++ b/test/e2e/run-api-specs-multichain.ts @@ -6,10 +6,10 @@ import { MetaMaskOpenRPCDocument, } from '@metamask/api-specs'; -import { ContentDescriptorObject, MethodObject, OpenrpcDocument } from '@open-rpc/meta-schema'; +import { MethodObject, OpenrpcDocument } from '@open-rpc/meta-schema'; import JsonSchemaFakerRule from '@open-rpc/test-coverage/build/rules/json-schema-faker-rule'; import ExamplesRule from '@open-rpc/test-coverage/build/rules/examples-rule'; -import { Call, IOptions } from '@open-rpc/test-coverage/build/coverage'; +import { IOptions } from '@open-rpc/test-coverage/build/coverage'; import { ScopeString } from '../../app/scripts/lib/multichain-api/scope'; import { Driver, PAGES } from './webdriver/driver'; @@ -25,7 +25,6 @@ import { unlockWallet, DAPP_URL, ACCOUNT_1, - Fixtures, } from './helpers'; import { MultichainAuthorizationConfirmation } from './api-specs/MultichainAuthorizationConfirmation'; import transformOpenRPCDocument from './api-specs/transform'; @@ -45,7 +44,13 @@ async function main() { disableGanache: true, title: 'api-specs coverage', }, - async ({ driver, extensionId }: any) => { + async ({ + driver, + extensionId, + }: { + driver: Driver; + extensionId: string; + }) => { await unlockWallet(driver); // Navigate to extension home screen From e3df8b462e0bac716bb4e1dc189b37ce40554b31 Mon Sep 17 00:00:00 2001 From: Jiexi Luan Date: Wed, 9 Oct 2024 14:30:39 -0700 Subject: [PATCH 3/3] fix run-api-specs-multichain withFixtures handler typing --- test/e2e/helpers.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/helpers.js b/test/e2e/helpers.js index a9580b641349..5497fdb23cb6 100644 --- a/test/e2e/helpers.js +++ b/test/e2e/helpers.js @@ -50,6 +50,7 @@ const convertETHToHexGwei = (eth) => convertToHexValue(eth * 10 ** 18); * @property {Bundler} bundlerServer - The bundler server. * @property {mockttp.Mockttp} mockServer - The mock server. * @property {object} manifestFlags - Flags to add to the manifest in order to change things at runtime. + * @property {string} extensionId - the ID that the extension can be found at via externally_connectable. */ /**