Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add withFixtures helper and simple-send test #7862

Merged
merged 1 commit into from
Jan 20, 2020
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
31 changes: 31 additions & 0 deletions test/e2e/helpers.js
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,
}
2 changes: 2 additions & 0 deletions test/e2e/run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ set -o pipefail

export PATH="$PATH:./node_modules/.bin"

mocha --no-timeouts test/e2e/tests/*.spec.js

concurrently --kill-others \
--names 'dapp,e2e' \
--prefix '[{time}][{name}]' \
Expand Down
28 changes: 28 additions & 0 deletions test/e2e/tests/simple-send.spec.js
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'))
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export default class TransactionViewBalance extends PureComponent {
})
history.push(SEND_ROUTE)
}}
data-testid="transaction-view-send"
>
{ t('send') }
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default class PageContainerFooter extends Component {
large={buttonSizeLarge}
className="page-container__footer-button"
onClick={e => onCancel(e)}
data-testid="page-container-footer-cancel"
>
{ cancelText || this.context.t('cancel') }
</Button>
Expand All @@ -56,6 +57,7 @@ export default class PageContainerFooter extends Component {
className="page-container__footer-button"
disabled={disabled}
onClick={e => onSubmit(e)}
data-testid="page-container-footer-next"
>
{ submitText || this.context.t('next') }
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default class EnsInput extends Component {
onPaste={this.onPaste}
value={selectedAddress || input}
autoFocus
data-testid="ens-input"
/>
<div
className={c('ens-input__wrapper__action-icon', {
Expand Down