Skip to content

Commit

Permalink
Fabo/new e2e flow (#110)
Browse files Browse the repository at this point in the history
* new e2e flow

* changelog

* updated security critical deps

* remove workspace

* forgot to checkout the repo

* correct cache key && cache app deps

* install deps for e2e tets

* update chromedriver

* use npm in machine

* don't use yarn in machine on ci

* correct screenshot settings

* remove experimental flags

* working tests

* fixed test

* old lunie still serves with https

* switch lunie to feature branch

* fixed missing network and updated lunie

* linted

* fixed build script

* use yarn.lock as cache key

* use script from package.json

* merge develop

* use local url in tests

* fix tests by importing the correct account instead of creating one

* switch to working e2e extension branch

* fix tests

* wait for element to be present

* skip moving to portfolio

* switched to latest branches

* switch submodule to master

* switched to master branch fro lunie

* force master checkout

* security update
  • Loading branch information
faboweb authored and colw committed Nov 18, 2019
1 parent a725e02 commit c04dd93
Show file tree
Hide file tree
Showing 15 changed files with 189 additions and 99 deletions.
86 changes: 65 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
version: 2.1

aliases:
# Define paths and never think about them again
- &WORKSPACE /tmp/lunie

# reusable commands
commands:
yarn-install:
description: '[YARN] update and install'
steps:
- restore_cache:
keys:
- v4-dependencies-root-{{ checksum "package.json" }}
- v4-dependencies-root-{{ checksum "yarn.lock" }}
- v4-dependencies-root-

- run: yarn install
- save_cache:
paths:
- yarn.lock
- node_modules
key: v4-dependencies-root-{{ checksum "package.json" }}
key: v4-dependencies-root-{{ checksum "yarn.lock" }}
npm-install-app:
description: '[NPM] update and install'
steps:
- restore_cache:
keys:
- v1-dependencies-app-root-{{ checksum "lunie/yarn.lock" }}
- v1-dependencies-app-root-

- run: cd lunie && npm install
- save_cache:
paths:
- lunie/node_modules
key: v1-dependencies-app-root-{{ checksum "lunie/yarn.lock" }}

jobs:
pendingUpdated:
Expand Down Expand Up @@ -83,34 +92,69 @@ jobs:
exit 0
testE2E:
docker:
# Primary container image where all steps run.
- image: circleci/node:10.15.3-browsers
# Secondary container image on common network which runs the testnet
- image: lunieio/testnet:v0.34.3
machine: true
steps:
- add_ssh_keys:
fingerprints:
- "65:5f:43:fd:be:48:c8:45:d5:39:ef:86:14:d6:e1:12"
- checkout
- attach_workspace:
at: *WORKSPACE
- yarn-install
- setup_remote_docker
- run: npm install
- run:
name: Build
name: Add GitHub to known hosts
command: |
npm run initiate-submodule
npm run test:e2e:build
cd lunie
yarn certificates
mkdir -p ~/.ssh
touch ~/.ssh/known_hosts
ssh-keygen -R github.com
ssh-keyscan github.com >> ~/.ssh/known_hosts
- run:
name: checkout backend
command: |
git clone git@github.com:luniehq/lunie-backend.git
cd lunie-backend
git checkout origin/develop
- run:
name: Use NVM
command: |
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo ' [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"' >> $BASH_ENV
- run:
name: Install node version
command: |
nvm install v10.13.0
nvm alias default v10.13.0
- run:
name: Install Chrome
command: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get -y install google-chrome-stable
- run:
name: Run testnet
command: |
cd lunie-backend
docker-compose up --build -d
- run:
# needs to be done in CI to be sure it is build once we start the tests
name: Build Extension
command: |
npm run initiate-submodule
npm run test:e2e:build
environment:
VUE_APP_GRAPHQL_URL: http://127.0.0.1:4000 # Browserstack tunneling doesn't work with "localhost"
- npm-install-app
- run:
# needs to be done in CI to be sure it is build once we start the tests
name: Build App
command: |
cd lunie
npm run test:e2e:build
environment:
NETWORK: local-cosmos-hub-testnet
VUE_APP_GRAPHQL_URL: http://127.0.0.1:4000 # Browserstack tunneling doesn't work with "localhost"
- run:
name: Test
command: npm run test:e2e:start-lunie & yarn test:e2e
command: npm run test:e2e:start-lunie & npm run test:e2e
no_output_timeout: 120
- store_artifacts:
path: ./screenshots
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/lunie
/test/unit/coverage
/output
/screenshots
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "lunie"]
path = lunie
url = https://github.com/luniehq/lunie.git
branch = develop
branch = master
11 changes: 3 additions & 8 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ const stargate =
(dev ? `https://localhost:9071` : `https://stargate.lunie.io`)

export default {
name: `Lunie`,
development: dev,
google_analytics_uid: process.env.GOOGLE_ANALYTICS_UID || '',
sentry_dsn: process.env.SENTRY_DSN || '',
default_gas_price: dev ? 1e-9 : 2.5e-8, // recommended from Cosmos Docs
version: process.env.RELEASE,
google_analytics_uid: process.env.GOOGLE_ANALYTICS_UID || '', // needs to be configured in webpack.config.js
sentry_dsn: process.env.SENTRY_DSN || '', // needs to be configured in webpack.config.js
stargate,

// Ledger
CosmosAppTestModeAllowed: false
lunieLink: dev ? `http://localhost:9080` : `https://app.lunie.io`
}
2 changes: 1 addition & 1 deletion lunie
Submodule lunie updated 253 files
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
"build": "cross-env NODE_ENV=production webpack --hide-modules && node ./scripts/remove-localhost.js",
"build:dev": "cross-env NODE_ENV=development webpack --hide-modules",
"build-zip": "node scripts/build-zip.js",
"initiate-submodule": "git submodule init && git submodule update && cd lunie",
"initiate-submodule": "git submodule init && git submodule update && cd lunie && git checkout origin/master",
"watch": "npm run build -- --watch",
"watch:dev": "cross-env HMR=true npm run build:dev -- --watch",
"test:unit": "jest --coverage",
"test": "npm run lint && npm run test:unit",
"test:e2e:build": "npm run build:dev && node ./scripts/add-pem-key.js && cd ./lunie && yarn install && npm run test:e2e:build",
"test:e2e:build": "npm run build:dev && node ./scripts/add-pem-key.js",
"test:e2e:build:lunie": "cd ./lunie && yarn install && npm run test:e2e:build",
"test:e2e:start-lunie": "cd ./lunie && npm run serve:dist",
"test:e2e": "nightwatch --config ./test/e2e/nightwatch.conf.js",
"test:coverage": "live-server test/unit/coverage/lcov-report",
Expand Down Expand Up @@ -101,7 +102,7 @@
"eslint-plugin-vue": "^5.2.2",
"file-loader": "^1.1.11",
"husky": "^2.4.0",
"jest": "^24.8.0",
"jest": "^24.9.0",
"lint-prepush": "^0.4.1",
"live-server": "^1.2.1",
"mini-css-extract-plugin": "^0.4.4",
Expand All @@ -120,5 +121,8 @@
"webpack": "^4.20.2",
"webpack-cli": "^3.1.2",
"webpack-extension-reloader": "^1.1.0"
},
"resolutions": {
"handlebars": ">=4.5.2"
}
}
}
1 change: 1 addition & 0 deletions pending/fabo_e2e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Fixed] [#110](https://github.com/cosmos/lunie/pull/110) Fix e2e tests by using the lunie-backend docker-compose to run the stack @faboweb
1 change: 1 addition & 0 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const extensionHost = location.origin
const whitelisted = ['https://app.lunie.io', extensionHost]
if (process.env.NODE_ENV === 'development') {
whitelisted.push('https://localhost')
whitelisted.push('http://localhost')
}

const signRequestQueue = new SignRequestQueue()
Expand Down
3 changes: 2 additions & 1 deletion src/components/SessionAccounts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<script>
import AccountList from 'common/AccountList'
import SessionFrame from 'common/SessionFrame'
import config from 'config'
export default {
name: `session-accounts`,
components: {
Expand All @@ -41,7 +42,7 @@ export default {
methods: {
goToLunie() {
window.open(
'https://app.lunie.io/#/extension',
`${config.lunieLink}/#/extension`,
'_blank',
'noreferrer noopener'
)
Expand Down
1 change: 1 addition & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"content_scripts": [
{
"matches": [
"http://localhost/*",
"https://localhost/*",
"https://lunie.io/*",
"https://app.lunie.io/*",
Expand Down
7 changes: 4 additions & 3 deletions test/e2e/nightwatch.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ module.exports = {
default: {
screenshots: {
enabled: true,
path: './screenshots'
on_failure: true,
on_error: true,
path: 'screenshots'
},
filter: ['*.spec.js'],
globals: {
Expand All @@ -36,7 +38,6 @@ module.exports = {
}
},
globals: {
EXTENSION_ID: 'cklkpejioojjeiigffappdlcmnonmjek',
lunieLink: 'https://localhost:9080/?experimental=true//'
EXTENSION_ID: 'cklkpejioojjeiigffappdlcmnonmjek'
}
}
34 changes: 17 additions & 17 deletions test/e2e/transaction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ const formData = require('./formData.json')
module.exports = {
'Send Transaction': function(browser) {
browser
// Import funded account
.pause(500)
.url(`chrome-extension://${globals.EXTENSION_ID}/popup/popup.html`)
.waitForElementVisible('a[href="#/create"]')
.click('a[href="#/create"]')
.waitForElementVisible('.tm-li-session-title')
.click('a[href="#/recover"]')
.pause(500)
// Seed
.waitForElementVisible('h2.session-title')
.setValue(
"textarea[placeholder='Must be exactly 24 words']",
formData.seedPhrase
)
.click('div.session-footer button')
.pause(500)
// Name
.waitForElementVisible('h2.session-title')
.setValue(
"input[placeholder='Must be at least 3 characters']",
"input[placeholder='Must have at least 3 characters']",
formData.name
)
.click('div.session-footer button')
Expand All @@ -27,12 +33,6 @@ module.exports = {
.setValue("input[placeholder='Enter password again']", formData.password)
.click('div.session-footer button')
.pause(500)
// Seed
.waitForElementVisible('h2.session-title')
.click('div.field-checkbox-input label')
.pause(500)
.click('div.session-footer button')
.pause(500)
// Assert
.assert.containsText(
'body',
Expand All @@ -41,22 +41,22 @@ module.exports = {

// Send transaction on Lunie to extension
.execute(function() {
window.open('https://localhost:9080/extension')
window.open('http://localhost:9080/#/extension')
})
.pause(500)

// Switch to Localhost
.windowHandles(function(result) {
browser
.switchWindow(result.value[1])
.pause(5000)
.assert.urlContains('https://localhost:9080/extension')
.waitForElementVisible('li.account button')
.click('li.account button')
.pause(300)
// .assert.urlContains('http://localhost:9080/#/extension')
.waitForElementVisible('.account-button')
.click('.account-button')
.waitForElementNotPresent('.session')

// Perform a token send
.click('a[href="/portfolio"]')
// .click('a[href="/portfolio"]') // this doesn't work and we are at portfolio already
.click('.send-button')
.setValue(
"input[placeholder='Address']",
Expand Down
4 changes: 4 additions & 0 deletions test/unit/components/SessionAccounts.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { shallowMount } from '@vue/test-utils'
import SessionAccounts from 'components/SessionAccounts.vue'

jest.mock('config', () => ({
lunieLink: 'https://app.lunie.io'
}))

describe(`SessionAccounts`, () => {
let $store, wrapper

Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const config = {
common: resolve('lunie/src/components/common'),
transactions: resolve('lunie/src/components/transactions'),
modules: resolve('lunie/src/vuex/modules'),
'src/config': resolve('config.js'),
config: resolve('config.js'),
src: resolve('lunie/src'),
scripts: resolve('lunie/src/scripts')
},
Expand Down
Loading

0 comments on commit c04dd93

Please sign in to comment.