Skip to content

Commit

Permalink
🎨feat: ethereum-wallet-mock package
Browse files Browse the repository at this point in the history
  • Loading branch information
matstyler committed Apr 18, 2024
1 parent 2519a8b commit af123ce
Show file tree
Hide file tree
Showing 33 changed files with 515 additions and 397 deletions.
45 changes: 30 additions & 15 deletions examples/new-dawn/test/e2e/00_mock.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
import { MetaMaskMock, testWithMetaMaskMock } from '@synthetixio/synpress'
import {
EthereumWalletMock,
testWithEthereumWalletMock,
} from "@synthetixio/synpress";

const test = testWithMetaMaskMock
const test = testWithEthereumWalletMock;

const { expect } = test
const { expect } = test;

test('should mock MetaMask in the Test Dapp', async ({ page }) => {
await page.goto('/')
test("should mock MetaMask in the Test Dapp", async ({ page, walletMock }) => {
expect(await walletMock.getAllAccounts()).toHaveLength(1);

await expect(page.locator('#accounts')).toHaveText('0xd73b04b0e696b0945283defa3eee453814758f1a')
await page.locator("#connectButton").click();

await page.locator('#getAccounts').click()
await expect(page.locator('#getAccountsResult')).toHaveText('0xd73b04b0e696b0945283defa3eee453814758f1a')
})
await expect(page.locator("#accounts")).toHaveText(
"0xd73b04b0e696b0945283defa3eee453814758f1a"
);

test('should add new account using MetaMask mock', async ({ page }) => {
const metamask = new MetaMaskMock(page)
await page.locator("#getAccounts").click();
await expect(page.locator("#getAccountsResult")).toHaveText(
"0xd73b04b0e696b0945283defa3eee453814758f1a"
);
});

metamask.importWallet('candy maple cake sugar pudding cream honey rich smooth crumble sweet treat')
await metamask.addNewAccount()
test("should add new account using MetaMask mock", async ({ page }) => {
const walletMock = new EthereumWalletMock(page);

await expect(page.locator('#accounts')).toHaveText('0xd73b04b0e696b0945283defa3eee453814758f1a')
})
await walletMock.importWallet(
"candy maple cake sugar pudding cream honey rich smooth crumble sweet treat"
);
await walletMock.addNewAccount();

await page.locator("#connectButton").click();

await expect(page.locator("#accounts")).toHaveText(
"0x6503D95e3F20389EE9496b277ABfFDb8eCCD2cc5,0xd73b04b0e696b0945283defa3eee453814758f1a"
);
});
46 changes: 23 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"types:check": "tsc --noEmit"
},
"dependencies": {
"@synthetixio/ethereum-wallet-mock": "0.0.1-alpha.3",
"@synthetixio/synpress-core": "0.0.1-alpha.3",
"@synthetixio/synpress-fixtures": "0.0.1-alpha.3",
"@synthetixio/synpress-metamask": "0.0.1-alpha.3",
"@synthetixio/synpress-metamask-mock": "0.0.1-alpha.3"
"@synthetixio/synpress-metamask": "0.0.1-alpha.3"
},
"devDependencies": {
"@synthetixio/synpress-tsconfig": "0.0.1-alpha.3",
Expand Down
26 changes: 18 additions & 8 deletions release/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import { defineWalletSetup } from '@synthetixio/synpress-core'
import { getExtensionId, testWithSynpress } from '@synthetixio/synpress-fixtures'
import { MetaMask, homePageSelectors, unlockForFixture } from '@synthetixio/synpress-metamask'
import { MetaMaskMock, testWithMetaMaskMock } from '@synthetixio/synpress-metamask-mock'
import { defineWalletSetup } from "@synthetixio/synpress-core";
import {
getExtensionId,
testWithSynpress,
} from "@synthetixio/synpress-fixtures";
import {
MetaMask,
homePageSelectors,
unlockForFixture,
} from "@synthetixio/synpress-metamask";
import {
EthereumWalletMock,
testWithEthereumWalletMock,
} from "@synthetixio/ethereum-wallet-mock";

export {
// Framework fixtures
testWithSynpress,
testWithMetaMaskMock,
testWithEthereumWalletMock,
// API
MetaMask,
MetaMaskMock,
EthereumWalletMock,
// Helpers
defineWalletSetup,
getExtensionId,
unlockForFixture,
homePageSelectors
}
homePageSelectors,
};
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@synthetixio/synpress-metamask-mock",
"name": "@synthetixio/ethereum-wallet-mock",
"version": "0.0.1-alpha.3",
"type": "module",
"exports": {
Expand Down
File renamed without changes.
Loading

0 comments on commit af123ce

Please sign in to comment.