|
| 1 | +import { |
| 2 | + CHROME, |
| 3 | + DappDriver, |
| 4 | + HEADLESS, |
| 5 | + HeadlessWalletServer, |
| 6 | + PLAYWRIGHT, |
| 7 | +} from "@assert-equals/dappdriver"; |
| 8 | +import { Dapp } from "@assert-equals/dappdriver-examples-page-objects"; |
| 9 | +import { expect } from "chai"; |
| 10 | +import { TestDapp } from "@assert-equals/dappdriver-examples-test-dapp"; |
| 11 | +import dotenv from "dotenv"; |
| 12 | +dotenv.config({ path: "../../.env" }); |
| 13 | + |
| 14 | +(async function test(): Promise<void> { |
| 15 | + let server = new TestDapp(3000); |
| 16 | + await server.startServer(); |
| 17 | + const headlessWalletPort: number = 3001; |
| 18 | + const headlessWalletServer: HeadlessWalletServer = new HeadlessWalletServer({ |
| 19 | + mnemonic: process.env.DAPPDRIVER_SEED_PHRASE, |
| 20 | + port: headlessWalletPort, |
| 21 | + }); |
| 22 | + await headlessWalletServer.start(); |
| 23 | + let dapp: Dapp = await DappDriver.create<Dapp>( |
| 24 | + "http://localhost:3000/", |
| 25 | + PLAYWRIGHT, |
| 26 | + CHROME, |
| 27 | + Dapp, |
| 28 | + { |
| 29 | + extension: { |
| 30 | + wallet: HEADLESS, |
| 31 | + port: headlessWalletPort, |
| 32 | + }, |
| 33 | + } |
| 34 | + ); |
| 35 | + try { |
| 36 | + // await dapp.useProvider(); |
| 37 | + const actualAccount: string = await dapp.getAccounts(); |
| 38 | + const expectedAccount = "0xE18035BF8712672935FDB4e5e431b1a0183d2DFC"; |
| 39 | + expect(actualAccount).to.be.equal(expectedAccount); |
| 40 | + } finally { |
| 41 | + await DappDriver.dispose(); |
| 42 | + await server.shutdown(); |
| 43 | + await headlessWalletServer.stop(); |
| 44 | + } |
| 45 | +})(); |
0 commit comments