Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

chore: update metamask version #209

Merged
merged 3 commits into from
Dec 12, 2022
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
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export * from "./setup";
export { DapeteerJestConfig } from "./jest/global";

// default constants
export const RECOMMENDED_METAMASK_VERSION = "v10.20.0";
export const RECOMMENDED_METAMASK_VERSION = "v10.23.0";
1 change: 1 addition & 0 deletions src/snap/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export const installSnap =
}

const result = await installAction;
await installPage.waitForTimeout(1000);
await installPage.close({ runBeforeUnload: true });
if (!(snapIdOrLocation in result.snaps)) {
throw new Error("Failed to install snap");
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ export type Dappeteer = {
opts?: {
customSteps?: InstallStep[];
version?: string;
},
installationSnapUrl?: string
installationSnapUrl?: string;
}
) => Promise<string>;
/**
* Accepts snap_confirm dialog
Expand Down
3 changes: 1 addition & 2 deletions test/constant.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Provider, Server } from "ganache";

import Web3 from "web3";
import { Dappeteer, DappeteerPage } from "../src";
import { Dappeteer, DappeteerPage, DappeteerBrowser } from "../src";

import { DappeteerBrowser } from "../src/browser";
import { Snaps, TestContract } from "./deploy";

export type InjectableContext = Readonly<{
Expand Down
50 changes: 29 additions & 21 deletions test/flask/snaps.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from "chai";
import { DappeteerPage, Dappeteer } from "../../src";
import { EXAMPLE_WEBSITE, TestContext } from "../constant";
import { TestContext } from "../constant";
import { Snaps } from "../deploy";

describe("snaps", function () {
Expand All @@ -12,28 +12,34 @@ describe("snaps", function () {
metaMaskPage = this.metaMaskPage;
});

beforeEach(function (this: TestContext) {
//skip those tests for non flask metamask
if (!this.browser.isMetaMaskFlask()) {
this.skip();
}
});
describe("Snaps Installation", () => {
beforeEach(function (this: TestContext) {
//skip those tests for non flask metamask
if (!this.browser.isMetaMaskFlask()) {
this.skip();
}
});

it("should install base snap from local server", async function (this: TestContext) {
await metaMask.snaps.installSnap(this.snapServers[Snaps.BASE_SNAP]);
});
it("should install base snap from local server", async function (this: TestContext) {
await metaMask.snaps.installSnap(this.snapServers[Snaps.BASE_SNAP]);
});

it("should install permissions snap local server", async function (this: TestContext) {
await metaMask.snaps.installSnap(this.snapServers[Snaps.PERMISSIONS_SNAP]);
});
it("should install permissions snap local server", async function (this: TestContext) {
await metaMask.snaps.installSnap(
this.snapServers[Snaps.PERMISSIONS_SNAP]
);
});

it("should install keys snap from local server", async function (this: TestContext) {
await metaMask.snaps.installSnap(this.snapServers[Snaps.KEYS_SNAP]);
it("should install keys snap from local server", async function (this: TestContext) {
await metaMask.snaps.installSnap(this.snapServers[Snaps.KEYS_SNAP]);
});
});

describe("should test snap methods", function () {
const installationSnapUrl = "https://google.com/";
let testPage: DappeteerPage;
let snapId: string;
let permissionSnapId: string;

beforeEach(function (this: TestContext) {
//skip those tests for non flask metamask
Expand All @@ -47,10 +53,16 @@ describe("snaps", function () {
this.skip();
}
snapId = await metaMask.snaps.installSnap(
this.snapServers[Snaps.METHODS_SNAP]
this.snapServers[Snaps.METHODS_SNAP],
{ installationSnapUrl }
);
permissionSnapId = await metaMask.snaps.installSnap(
this.snapServers[Snaps.PERMISSIONS_SNAP],
{ installationSnapUrl }
);

testPage = await metaMaskPage.browser().newPage();
await testPage.goto(EXAMPLE_WEBSITE);
await testPage.goto(installationSnapUrl);
return testPage;
});

Expand Down Expand Up @@ -78,10 +90,6 @@ describe("snaps", function () {
});

it("should return all notifications", async function (this: TestContext) {
const permissionSnapId = await metaMask.snaps.installSnap(
this.snapServers[Snaps.PERMISSIONS_SNAP]
);

const emitter = await metaMask.snaps.getNotificationEmitter();
const notificationPromise = emitter.waitForNotification();

Expand Down