-
Notifications
You must be signed in to change notification settings - Fork 15
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
E2e tests #65
Open
rperez89
wants to merge
26
commits into
master
Choose a base branch
from
e2eTests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
E2e tests #65
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
b03540a
tests
rperez89 9a3a46e
change babel config
rperez89 41877ed
tests
rperez89 55e106f
split tests
rperez89 323c79a
split tests
94b23a0
split tests
rperez89 1759299
merge with master
rperez89 08b8ec3
percy integration
rperez89 8d680aa
circle ci config
rperez89 3c4d60f
circle ci config
rperez89 eb66288
circle ci config
rperez89 14ff728
circle ci config
rperez89 fa0fe12
change node version
rperez89 c6cd74e
change node version
rperez89 56655e0
change node version
rperez89 8f736b3
yml
rperez89 05680b4
yml
rperez89 f526e5f
yml
rperez89 2ec3ad5
add ipfs install
rperez89 a99ddc3
submodules
rperez89 c454ef8
remove cache
rperez89 b830880
change aragon cli version
rperez89 60f6666
rsync
rperez89 d6849ba
remove trash
rperez89 f2dc098
PR changes and remove percy
rperez89 3d6195e
use ENV variable for chrome path
rperez89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 +1,3 @@ | ||
{ | ||
"presets": ["es2015", "stage-2", "stage-3"] | ||
} | ||
"presets": ["@babel/preset-env"] | ||
} |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ jobs: | |
build: | ||
docker: | ||
# specify the version you desire here | ||
- image: circleci/node:8.15.1 | ||
- image: circleci/node:lts-browsers | ||
|
||
# Specify service dependencies here if necessary | ||
# CircleCI maintains a library of pre-built images | ||
|
@@ -20,11 +20,6 @@ jobs: | |
- checkout | ||
|
||
# Download and cache dependencies | ||
- restore_cache: | ||
keys: | ||
- redemptions-{{ checksum "package.json" }} | ||
# fallback to using the latest cache if no exact match is found | ||
# - redemptions- | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can add this back again and use restore_node_modules - *restore_node_modules |
||
- run: | ||
name: Install dependencies | ||
|
@@ -33,15 +28,21 @@ jobs: | |
- save_cache: | ||
paths: | ||
- node_modules | ||
key: redemptions-{{ checksum "package.json" }} | ||
key: redemptions-dependencies-{{ checksum "package.json" }} | ||
|
||
- run: sudo apt install rsync | ||
|
||
- run: | ||
name: Run tests | ||
command: npm run coverage | ||
|
||
- run: | ||
name: Report Coverage | ||
Command: npm run coveralls | ||
|
||
- run: | ||
name: Visual Tests | ||
command: npm run test:e2e | ||
|
||
workflows: | ||
version: 2 | ||
|
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
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,184 @@ | ||
import test from 'ava' | ||
import { startBackgroundProcess } from './util' | ||
const dappeteer = require('dappeteer') | ||
import puppeteer from 'puppeteer' | ||
const { percySnapshot } = require('@percy/puppeteer') | ||
|
||
test.before(async t => { | ||
const browser = await dappeteer.launch(puppeteer, { | ||
headless: false, | ||
defaultViewport: null, | ||
args: ['--start-maximized', '--no-sandbox', '--disable-setuid-sandbox', '--disable-web-security'], | ||
}) | ||
const page = await browser.newPage() | ||
const metamask = await dappeteer.getMetamask(browser) | ||
const { stdout, exit } = await startBackgroundProcess({ | ||
cmd: 'npm', | ||
args: ['run', 'start:template'], | ||
execaOpts: { | ||
cwd: `./`, | ||
}, | ||
readyOutput: 'Opening http://localhost:3000/#/' | ||
}) | ||
|
||
// hack so the wrapper has time to start | ||
await new Promise(resolve => setTimeout(resolve, 60 * 1000)) // TODO move to utils | ||
|
||
// finding the DAO address | ||
const daoAddress = stdout.match(/DAO address: (0x[a-fA-F0-9]{40})/)[1] | ||
|
||
const { stdoutScript, exitScript } = await startBackgroundProcess({ | ||
cmd: 'npm', | ||
args: ['run', 'deploy-tokens', daoAddress], | ||
execaOpts: { | ||
cwd: `./`, | ||
}, | ||
readyOutput: 'ETH 0x0000000000000000000000000000000000000000', | ||
}) | ||
await metamask.switchNetwork('localhost') | ||
await metamask.importPK('a8a54b2d8197bc0b19bb8a084031be71835580a01e70a45a13babd16c9bc1563') | ||
await metamask.switchAccount(2) | ||
|
||
t.context = { | ||
browser: browser, | ||
page: page, | ||
daoAddress: daoAddress, | ||
metamask: metamask, | ||
exit: exit, | ||
} | ||
}) | ||
|
||
test.serial('should display initial screen ', async t => { | ||
const redemptionsText = 'Redemptions' | ||
let addTokenText | ||
const url = `http://localhost:3000/#/${t.context.daoAddress}` | ||
await t.context.page.goto(url) | ||
await t.context.page.reload() | ||
await t.context.page.bringToFront() | ||
await t.context.page.waitForFunction( | ||
redemptionsText => document.querySelector('body').innerText.includes(redemptionsText), | ||
{}, | ||
redemptionsText | ||
) | ||
const RedemptionsAppSpan = await t.context.page.$x("//span[contains(text(), 'Redemptions')]") | ||
if (RedemptionsAppSpan.length > 0) { | ||
await RedemptionsAppSpan[0].click() | ||
await t.context.page.waitFor(3000) | ||
} else { | ||
throw new Error('Redemptions app not found') | ||
} | ||
|
||
const frame = await t.context.page.frames().find(f => f.name() === 'AppIFrame') | ||
const addTokenButton = await frame.$x("//button[contains(text(), 'Add token')]") | ||
if (addTokenButton.length > 0) { | ||
const button = addTokenButton[0] | ||
addTokenText = await frame.evaluate(button => button.textContent, button) | ||
} | ||
await percySnapshot(frame, 'Initial Screen') | ||
t.is(addTokenText, 'Add token') | ||
}) | ||
|
||
test.serial('should display add token side panel and create transaction', async t => { | ||
let addTokenText | ||
const frame = await t.context.page.frames().find(f => f.name() === 'AppIFrame') | ||
const addTokenButton = await frame.$x("//button[contains(text(), 'Add token')]") | ||
|
||
if (addTokenButton.length > 0) { | ||
await addTokenButton[0].click() | ||
await frame.type('input[name=address]', '0x0000000000000000000000000000000000000000', { delay: 20 }) | ||
await frame.waitForSelector('#SidePanelButton') | ||
const AddTokenSidePanelButton = await frame.$('#SidePanelButton') | ||
addTokenText = await frame.evaluate( | ||
AddTokenSidePanelButton => AddTokenSidePanelButton.textContent, | ||
AddTokenSidePanelButton | ||
) | ||
//Percy | ||
await percySnapshot(frame, 'Side Panel') | ||
await AddTokenSidePanelButton.click() | ||
await t.context.page.waitFor(4000) | ||
} else { | ||
throw new Error('Add token button not found') | ||
} | ||
t.is(addTokenText, 'Add token') | ||
}) | ||
|
||
test.serial('should confirm create transaction and vote', async t => { | ||
const createTransaction = await t.context.page.$x("//button[contains(text(), 'Create transaction')]") | ||
let viewVoteButton | ||
let viewVoteText | ||
const votingText = 'Voting' | ||
|
||
if (createTransaction.length > 0) { | ||
await createTransaction[0].click() | ||
await t.context.metamask.confirmTransaction() | ||
await t.context.page.waitFor(3000) | ||
await t.context.page.bringToFront() | ||
await t.context.page.waitForFunction( | ||
votingText => document.querySelector('body').innerText.includes(votingText), | ||
{}, | ||
votingText | ||
) | ||
const votingAppSpan = await t.context.page.$x("//span[contains(text(), 'Voting')]") | ||
|
||
if (votingAppSpan.length > 0) { | ||
await votingAppSpan[0].click() | ||
await t.context.page.waitFor(3000) | ||
const votingFrame = await t.context.page.frames().find(f => f.name() === 'AppIFrame') | ||
const viewVote = await votingFrame.$x("//button[contains(text(), 'View vote')]") | ||
|
||
if (viewVote.length > 0) { | ||
viewVoteButton = viewVote[0] | ||
viewVoteText = await votingFrame.evaluate(viewVoteButton => viewVoteButton.textContent, viewVoteButton) | ||
await viewVoteButton.click() | ||
await t.context.page.waitFor(3000) | ||
const voteYes = await votingFrame.$x("//button[contains(text(), 'Yes')]") | ||
if (voteYes.length > 0) { | ||
voteYes[0].click() | ||
await t.context.page.waitFor(3000) | ||
const createVotingTransaction = await t.context.page.$x("//button[contains(text(), 'Create transaction')]") | ||
|
||
if (createVotingTransaction.length > 0) { | ||
await createVotingTransaction[0].click() | ||
await t.context.metamask.confirmTransaction() | ||
await t.context.page.waitFor(3000) | ||
await t.context.page.bringToFront() | ||
} else { | ||
throw new Error('Create transaction not found') | ||
} | ||
} else { | ||
throw new Error('Vote Yes button not found') | ||
} | ||
} else { | ||
throw new Error('View vote button not found') | ||
} | ||
} else { | ||
throw new Error('Voting app not found') | ||
} | ||
} | ||
t.is(viewVoteText, 'View vote') | ||
}) | ||
|
||
test.serial('should add the token ', async t => { | ||
let RedemptionsListTitle | ||
let ETHDiv | ||
let ETHTitle | ||
let frame | ||
const RedemptionsAppSpan = await t.context.page.$x("//span[contains(text(), 'Redemptions')]") | ||
|
||
if (RedemptionsAppSpan.length > 0) { | ||
await RedemptionsAppSpan[0].click() | ||
await t.context.page.waitFor(3000) | ||
frame = await t.context.page.frames().find(f => f.name() === 'AppIFrame') | ||
RedemptionsListTitle = await frame.evaluate(el => el.innerHTML, await frame.$('#TokensTitle')) | ||
ETHDiv = await frame.waitForSelector('#ETHTitle') | ||
ETHTitle = await frame.evaluate(ETHDiv => ETHDiv.textContent, ETHDiv) | ||
|
||
} else { | ||
throw new Error('Redemptions app not found') | ||
} | ||
|
||
await percySnapshot(frame, 'Token List') | ||
t.is(RedemptionsListTitle, 'Tokens for redemption') | ||
t.is(ETHTitle, 'ETH') | ||
await t.context.exit() | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add restore_cache back again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is some kind of problem installing websocket when you have the restore_cache, we need to investigate it a little more