Skip to content

Commit e63fcf1

Browse files
Refactoring ethereum-on.spec.js to use fixtures (#10778)
1 parent b1dcbce commit e63fcf1

File tree

5 files changed

+60
-209
lines changed

5 files changed

+60
-209
lines changed

test/e2e/ethereum-on.spec.js

Lines changed: 0 additions & 201 deletions
This file was deleted.

test/e2e/run-all.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ retry concurrently --kill-others \
6161
--success first \
6262
'mocha test/e2e/send-edit.spec'
6363

64-
retry concurrently --kill-others \
65-
--names 'dapp,e2e' \
66-
--prefix '[{time}][{name}]' \
67-
--success first \
68-
'yarn dapp' \
69-
'mocha test/e2e/ethereum-on.spec'
70-
7164
retry concurrently --kill-others \
7265
--names 'dapp,e2e' \
7366
--prefix '[{time}][{name}]' \

test/e2e/tests/personal-sign.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('Personal sign', function () {
1616
await withFixtures(
1717
{
1818
dapp: true,
19-
fixtures: 'personal-sign',
19+
fixtures: 'connected-state',
2020
ganacheOptions,
2121
title: this.test.title,
2222
},
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const { strict: assert } = require('assert');
2+
const { By, Key } = require('selenium-webdriver');
3+
const { withFixtures, regularDelayMs } = require('../helpers');
4+
5+
describe('MetaMask', function () {
6+
it('provider should inform dapp when switching networks', async function () {
7+
const ganacheOptions = {
8+
accounts: [
9+
{
10+
secretKey:
11+
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
12+
balance: 25000000000000000000,
13+
},
14+
],
15+
};
16+
await withFixtures(
17+
{
18+
dapp: true,
19+
fixtures: 'connected-state',
20+
ganacheOptions,
21+
title: this.test.title,
22+
},
23+
async ({ driver }) => {
24+
await driver.navigate();
25+
const passwordField = await driver.findElement(By.css('#password'));
26+
await passwordField.sendKeys('correct horse battery staple');
27+
await passwordField.sendKeys(Key.ENTER);
28+
29+
await driver.openNewPage('http://127.0.0.1:8080/');
30+
const networkDiv = await driver.findElement(By.css('#network'));
31+
const chainIdDiv = await driver.findElement(By.css('#chainId'));
32+
await driver.delay(regularDelayMs);
33+
assert.equal(await networkDiv.getText(), '1337');
34+
assert.equal(await chainIdDiv.getText(), '0x539');
35+
36+
const windowHandles = await driver.getAllWindowHandles();
37+
await driver.switchToWindow(windowHandles[0]);
38+
39+
await driver.clickElement(By.css('.network-display'));
40+
await driver.clickElement(
41+
By.xpath(`//span[contains(text(), 'Ropsten')]`),
42+
);
43+
await driver.delay(regularDelayMs);
44+
45+
await driver.switchToWindowWithTitle('E2E Test Dapp', windowHandles);
46+
const switchedNetworkDiv = await driver.findElement(By.css('#network'));
47+
const switchedChainIdDiv = await driver.findElement(By.css('#chainId'));
48+
const accountsDiv = await driver.findElement(By.css('#accounts'));
49+
50+
assert.equal(await switchedNetworkDiv.getText(), '3');
51+
assert.equal(await switchedChainIdDiv.getText(), '0x3');
52+
assert.equal(
53+
await accountsDiv.getText(),
54+
'0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
55+
);
56+
},
57+
);
58+
});
59+
});

0 commit comments

Comments
 (0)