diff --git a/.circleci/config.yml b/.circleci/config.yml index 1643cc9b88..7403456d45 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/src/components/common/TmBalance.vue b/src/components/common/TmBalance.vue index c95eadd8c0..fb9baed1f0 100644 --- a/src/components/common/TmBalance.vue +++ b/src/components/common/TmBalance.vue @@ -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() } } diff --git a/src/vuex/modules/session.js b/src/vuex/modules/session.js index 103db757e5..6c2fca8b5f 100644 --- a/src/vuex/modules/session.js +++ b/src/vuex/modules/session.js @@ -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, diff --git a/tests/e2e/browserstack.conf.js b/tests/e2e/browserstack.conf.js index 3886530261..a0e4e80b39 100644 --- a/tests/e2e/browserstack.conf.js +++ b/tests/e2e/browserstack.conf.js @@ -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, diff --git a/tests/e2e/globals.js b/tests/e2e/globals.js index 50f5dc4b76..49a863274b 100644 --- a/tests/e2e/globals.js +++ b/tests/e2e/globals.js @@ -2,7 +2,7 @@ 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 @@ -10,6 +10,7 @@ module.exports = { asyncHookTimeout: 30000, async before() { + await schemaAvailable() await apiUp() }, @@ -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") } } } diff --git a/tests/e2e/local-chrome.conf.js b/tests/e2e/local-chrome.conf.js index a0d058b642..ab6cd95621 100644 --- a/tests/e2e/local-chrome.conf.js +++ b/tests/e2e/local-chrome.conf.js @@ -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, diff --git a/tests/e2e/signin.spec.js b/tests/e2e/signin.spec.js index f70bb4cc3d..2d429c07d9 100644 --- a/tests/e2e/signin.spec.js +++ b/tests/e2e/signin.spec.js @@ -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)