Skip to content

Commit

Permalink
Fabo/e2e integration (#3068)
Browse files Browse the repository at this point in the history
* Send modal use GraphQL API

* ActionModal api updates

* Delegation modal updates

* Delegation rewards

* Modal Deposit, Withdraw, Vote, Propose API updates

* Small fixes

* Remove modalContext

* fixed sendModal

* some more fixes

* Linting

* Remove send module

* Case insensitive search

- Name for clarity
- Do not display loading indicators

* Use uatom in transaction

* Undelegation modal

* Single denom balance and other updates

* Fix denom conversion

* Fix validators filter

* Move function

* Fix spacing problem

* Remove unnecessary code

* Disable unstake button when no deligations

* modal propose test

* modal vote tests

* modal deposit tests

* snapshots

* Minor, but not working, actionmodal test updates

* Fixed recursive error

* Lint

* fixed tests

* delegation modals working

* fixed withdraw modal

* cleanup

* remove denom conversion from sendModal

* Snapshots

* Update ActionManager test data

* remove view denom conversion for API requests

* fix e2e tests

* correct check for e2e balance

* correct default graphql url

* correct VUE_APP_GRAPHQL_URL for e2e

* working subscriptions

* changelog

* only query on successful transactions

* linted

* try fixing e2e tests

* timeout waiting for API to be up

* fix wrong e2e api up query

* comment

* log repsonse for API check for debugging

* use browserstack friendly host for e2e tests

* linted

* log errors

* disable production build to test faster

* switch to local testing

* set network via env

* remove lunie-backend

* reenable production build

* use browserstack again

* use docker caching

* disable docker-layer-caching as not supported in free tier

* typo

* typo

* typo

* use npm instead of yarn in e2e test

* typo

* switch back to local

* try working docker-compose command

* add check for database to be ready in e2e tests

* comments

* temporary skip build step to debug ci faster

* log console for debugging

* update lunie-api docker image manually

* typo

* do not rebuild dockers

* use debug branch

* cleanup

* cleanup

* shrink api up errors

* fixed error in overview query

* remove logs again

* e2e should be always insecure more

* switched to browserstack

* linted
  • Loading branch information
faboweb authored and colw committed Oct 31, 2019
1 parent 120e749 commit acb0e8b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 20 deletions.
10 changes: 2 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,18 @@ jobs:
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
npm run start -- -d
- run:
# needs to be done in CI to be sure it is build once we start the tests
name: Build for E2E test
command: npm run test:e2e:build
environment:
VUE_APP_GRAPHQL_URL: http://127.0.0.1:4000 # Browserstack tunneling doesn't work with "localhost"
NETWORK: local-cosmos-hub-testnet # Connect directly to the testnet
- run:
name: Test
command: npm run serve:dist & npm run test:e2e:browserstack
Expand Down
1 change: 1 addition & 0 deletions src/components/common/TmBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export default {
},
query: UserTransactionAdded,
result() {
// query if successful or not as even an unsuccessful tx costs fees
this.$apollo.queries.overview.refetch()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vuex/modules/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default () => {
const state = {
developmentMode: config.development, // can't be set in browser
experimentalMode: config.development, // development mode, can be set from browser
insecureMode: false, // show the local signer
insecureMode: config.e2e || false, // show the local signer
signedIn: false,
sessionType: null, // local, explore, ledger, extension
pauseHistory: false,
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/browserstack.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const nightwatch_config = {
src_folders: ["tests/e2e"],
globals_path: "./globals.js",
output_folder: "./output",
launch_url: "http://127.0.0.1:9080?network=local-cosmos-hub-testnet",
launch_url: "http://127.0.0.1:9080",

selenium: {
start_process: false,
Expand Down
45 changes: 37 additions & 8 deletions tests/e2e/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ const axios = require("axios")
const chai = require("chai")
chai.use(require("chai-string"))

const HOST = "localhost"
const HOST = "127.0.0.1"

module.exports = {
// controls the timeout time for async hooks. Expects the done() callback to be invoked within this time
// or an error is thrown
asyncHookTimeout: 30000,

async before() {
await schemaAvailable()
await apiUp()
},

Expand Down Expand Up @@ -69,23 +70,51 @@ module.exports = {
}

async function apiUp() {
const start = new Date().getTime()
// we need to wait until the testnet is up and the account has money
let apiUp = false
while (!apiUp) {
if (new Date().getTime() - start > 90000) {
throw new Error("Timed out waiting for API to be up.")
}
try {
const { data } = await axios.post(`http://${HOST}:4000`, {
operationName: null,
query: `{\n balance(networkId: "local-cosmos-hub-testnet", address: "cosmos1ek9cd8ewgxg9w5xllq9um0uf4aaxaruvcw4v9e", denom: "STAKE") {\n denom\n amount\n }\n}\n`,
variables: {}
// test if the test account was funded as we need the account to have funds in the tests
const response = await axios.post(`http://${HOST}:4000`, {
query: `{overview(networkId: "local-cosmos-hub-testnet", address:"cosmos1ek9cd8ewgxg9w5xllq9um0uf4aaxaruvcw4v9e") {totalStake}}`
})
if (data.data.balance.amount === 0) {
if (response.data.errors) {
throw new Error(JSON.stringify(response.data.errors))
}
if (response.data.data.overview.totalStake === 0) {
continue
}
apiUp = true
} catch (err) {
console.log(err)
console.log("Failed to check API", err)
await new Promise(resolve => setTimeout(resolve, 1000))
console.log("Waiting for API to be up")
}
}
}

async function schemaAvailable() {
const start = new Date().getTime()
// we need to wait until the database is up and has the expected shema
let databaseUp = false
while (!databaseUp) {
if (new Date().getTime() - start > 90000) {
throw new Error("Timed out waiting for database to be up.")
}
try {
// test if the database has the expected schema by probing one setup table
await axios.post(`http://${HOST}:8080/v1/graphql`, {
query: `{maintenance { message }}`
})
databaseUp = true
} catch (err) {
console.log("Failed to check database", err.message)
await new Promise(resolve => setTimeout(resolve, 1000))
console.log("Waiting for node to be up")
console.log("Waiting for database to be up")
}
}
}
2 changes: 1 addition & 1 deletion tests/e2e/local-chrome.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const nightwatch_config = {
globals_path: "./globals.js",
disable_colors: false,
test_workers: false,
launch_url: "http://localhost:9080?network=local-cosmos-hub-testnet",
launch_url: "http://localhost:9080",
webdriver: {
start_process: true,
port: 9515,
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/signin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function signIn(browser) {

function prepare(browser) {
browser.resizeWindow(400, 1024) // force mobile screen to be able to click some out of screen buttons
browser.url(browser.launch_url + "&insecure=true")
browser.url(browser.launch_url)
browser.waitForElementVisible(`body`)
browser.waitForElementVisible(`#app-content`)
signOut(browser)
Expand Down

0 comments on commit acb0e8b

Please sign in to comment.