forked from MetaMask/metamask-extension
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
withFixtures
helper and simple-send test (MetaMask#7862)
The `withFixtures` helper will instantiate ganache, a web driver, and a fixture server initialized with the given set of fixtures. It is meant to facilitating writing small, isolated e2e tests. The first example test has been added: simple-send. It ensures that the user can send 1 ETH to another account. These new e2e tests will run during the normal e2e test run. Closes MetaMask#6548
- Loading branch information
Showing
6 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,40 @@ | ||
const path = require('path') | ||
const Ganache = require('./ganache') | ||
const FixtureServer = require('./fixture-server') | ||
const { buildWebDriver } = require('./webdriver') | ||
|
||
const tinyDelayMs = 200 | ||
const regularDelayMs = tinyDelayMs * 2 | ||
const largeDelayMs = regularDelayMs * 2 | ||
|
||
async function withFixtures (options, callback) { | ||
const { fixtures, ganacheOptions, driverOptions } = options | ||
const fixtureServer = new FixtureServer() | ||
const ganacheServer = new Ganache() | ||
|
||
let webDriver | ||
try { | ||
await ganacheServer.start(ganacheOptions) | ||
await fixtureServer.start() | ||
await fixtureServer.loadState(path.join(__dirname, 'fixtures', fixtures)) | ||
const { driver } = await buildWebDriver(driverOptions) | ||
webDriver = driver | ||
|
||
await callback({ | ||
driver, | ||
}) | ||
} finally { | ||
await fixtureServer.stop() | ||
await ganacheServer.quit() | ||
if (webDriver) { | ||
await webDriver.quit() | ||
} | ||
} | ||
} | ||
|
||
module.exports = { | ||
tinyDelayMs, | ||
regularDelayMs, | ||
largeDelayMs, | ||
withFixtures, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { By, Key } = require('selenium-webdriver') | ||
const { withFixtures } = require('../helpers') | ||
|
||
describe('MetaMask Browser Extension', function () { | ||
it('can send a simple transaction from one account to another', async () => { | ||
const ganacheOptions = { | ||
accounts: [ | ||
{ | ||
secretKey: '0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC', | ||
balance: 25000000000000000000, | ||
}, | ||
], | ||
} | ||
await withFixtures({ fixtures: 'imported-account', ganacheOptions }, async ({ driver }) => { | ||
const passwordField = await driver.findElement(By.css('#password')) | ||
await passwordField.sendKeys('correct horse battery staple') | ||
await passwordField.sendKeys(Key.ENTER) | ||
await driver.clickElement(By.css('[data-testid="transaction-view-send"]')) | ||
const recipientAddressField = await driver.findElement(By.css('[data-testid="ens-input"]')) | ||
await recipientAddressField.sendKeys('0x985c30949c92df7a0bd42e0f3e3d539ece98db24') | ||
const amountField = await driver.findElement(By.css('.unit-input__input')) | ||
await amountField.sendKeys('1') | ||
await driver.clickElement(By.css('[data-testid="page-container-footer-next"]')) | ||
await driver.clickElement(By.css('[data-testid="page-container-footer-next"]')) | ||
await driver.findElement(By.css('.transaction-list-item')) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters