From 1fc458f7500d281573d6e756d4b3ad1e9e747930 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 13 Mar 2019 15:51:36 +0100 Subject: [PATCH 1/8] refactor tests, remove onboarding, fix error collection --- .../renderer/components/common/AnchorCopy.vue | 60 ---- .../renderer/components/common/Page404.vue | 39 +-- .../components/common/PagePreferences.vue | 57 ++-- .../renderer/components/common/TmField.vue | 261 +++++++++--------- .../renderer/components/common/TmLiCopy.vue | 49 ---- app/src/renderer/vuex/getters.js | 1 - app/src/renderer/vuex/modules/index.js | 1 - app/src/renderer/vuex/modules/onboarding.js | 41 --- app/src/renderer/vuex/modules/session.js | 6 +- .../specs/components/common/Page404.spec.js | 10 +- .../components/common/PagePreferences.spec.js | 58 ++-- .../components/common/ShortBech32.spec.js | 20 +- .../common/__snapshots__/Page404.spec.js.snap | 145 +++++----- .../PagePreferences.spec.js.snap | 15 +- .../__snapshots__/ShortBech32.spec.js.snap | 28 +- test/unit/specs/store/onboarding.spec.js | 42 --- 16 files changed, 340 insertions(+), 493 deletions(-) delete mode 100644 app/src/renderer/components/common/AnchorCopy.vue delete mode 100644 app/src/renderer/components/common/TmLiCopy.vue delete mode 100644 app/src/renderer/vuex/modules/onboarding.js delete mode 100644 test/unit/specs/store/onboarding.spec.js diff --git a/app/src/renderer/components/common/AnchorCopy.vue b/app/src/renderer/components/common/AnchorCopy.vue deleted file mode 100644 index 8385f7a9cb..0000000000 --- a/app/src/renderer/components/common/AnchorCopy.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - diff --git a/app/src/renderer/components/common/Page404.vue b/app/src/renderer/components/common/Page404.vue index fc360313ad..a9b9f4aaad 100644 --- a/app/src/renderer/components/common/Page404.vue +++ b/app/src/renderer/components/common/Page404.vue @@ -9,6 +9,11 @@ + + `; diff --git a/test/unit/specs/components/common/__snapshots__/PagePreferences.spec.js.snap b/test/unit/specs/components/common/__snapshots__/PagePreferences.spec.js.snap index 637acf6d16..a443b4fc4e 100644 --- a/test/unit/specs/components/common/__snapshots__/PagePreferences.spec.js.snap +++ b/test/unit/specs/components/common/__snapshots__/PagePreferences.spec.js.snap @@ -17,26 +17,17 @@ exports[`PagePreferences has the expected html structure if connected 1`] = ` - - - - + + diff --git a/test/unit/specs/components/common/__snapshots__/ShortBech32.spec.js.snap b/test/unit/specs/components/common/__snapshots__/ShortBech32.spec.js.snap index 94ba75b264..31421eaaa5 100644 --- a/test/unit/specs/components/common/__snapshots__/ShortBech32.spec.js.snap +++ b/test/unit/specs/components/common/__snapshots__/ShortBech32.spec.js.snap @@ -1,7 +1,29 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ShortBech32 has the expected html structure 1`] = ` -"
+exports[`ShortBech32 should show a short address 1`] = ` +
+
+ cosmosftw…6789 -
checkCopied
" + +
+ +
+ + check + + + Copied + +
+
`; diff --git a/test/unit/specs/store/onboarding.spec.js b/test/unit/specs/store/onboarding.spec.js deleted file mode 100644 index ca2568b956..0000000000 --- a/test/unit/specs/store/onboarding.spec.js +++ /dev/null @@ -1,42 +0,0 @@ -import setup from "../../helpers/vuex-setup" - -const instance = setup() - -describe(`Module: Onboarding`, () => { - let store, state - - beforeEach(() => { - store = instance.shallow().store - state = store.state.onboarding - }) - - it(`toggles onboarding active state`, () => { - expect(state.active).toBe(false) - store.commit(`setOnboardingActive`, false) - expect(state.active).toBe(false) - store.commit(`setOnboardingActive`, true) - expect(state.active).toBe(true) - }) - - it(`toggles onboarding state`, () => { - expect(state.state).toBe(0) - store.commit(`setOnboardingState`, 3) - expect(state.state).toBe(3) - store.commit(`setOnboardingState`, 0) - expect(state.state).toBe(0) - }) - - it(`loads the onboarding active state from localStorage`, () => { - store.commit(`setOnboardingActive`, false) - state.active = true - store.commit(`loadOnboarding`) - expect(state.active).toBe(false) - }) - - it(`loads the onboarding state from localStorage`, () => { - store.commit(`setOnboardingState`, 3) - state.state = 1 - store.commit(`loadOnboarding`) - expect(state.state).toBe(3) - }) -}) From 5f8b6229eb08470d69e87615e390f3db93324f70 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 13 Mar 2019 15:59:30 +0100 Subject: [PATCH 2/8] fixed tabs settings --- .../renderer/components/common/Page404.vue | 34 +-- .../components/common/PagePreferences.vue | 8 +- .../renderer/components/common/TmField.vue | 244 +++++++++--------- 3 files changed, 142 insertions(+), 144 deletions(-) diff --git a/app/src/renderer/components/common/Page404.vue b/app/src/renderer/components/common/Page404.vue index a9b9f4aaad..0d6821f92d 100644 --- a/app/src/renderer/components/common/Page404.vue +++ b/app/src/renderer/components/common/Page404.vue @@ -41,36 +41,36 @@ import TmPage from "common/TmPage" import TmPart from "common/TmPart" export default { - name: `page-404`, - components: { - TmPage, - TmPart - } + name: `page-404`, + components: { + TmPage, + TmPart + } } diff --git a/app/src/renderer/components/common/PagePreferences.vue b/app/src/renderer/components/common/PagePreferences.vue index ce561a86f3..29876086e6 100644 --- a/app/src/renderer/components/common/PagePreferences.vue +++ b/app/src/renderer/components/common/PagePreferences.vue @@ -36,7 +36,6 @@ - diff --git a/app/src/renderer/components/common/ToolBar.vue b/app/src/renderer/components/common/ToolBar.vue index c4adb1772a..b14dfbe95d 100644 --- a/app/src/renderer/components/common/ToolBar.vue +++ b/app/src/renderer/components/common/ToolBar.vue @@ -9,9 +9,6 @@ refresh - - settings - = timeout) { throw Error( `Timed out waiting for text. Expected ${text}, Showing ${(await elGetterFn().getText()) || - `nothing`}` + `nothing`}` ) } await sleep(100) @@ -85,7 +78,7 @@ module.exports = { if (Date.now() - start >= timeout) { throw Error( `Timed out waiting for value. Expected ${value}, Showing ${(await elGetterFn().getValue()) || - `nothing`}` + `nothing`}` ) } await sleep(100) diff --git a/test/e2e/preferences.js b/test/e2e/preferences.js deleted file mode 100644 index db98859672..0000000000 --- a/test/e2e/preferences.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict" - -const test = require(`tape-promise/tape`) -const { getApp, restart } = require(`./launch.js`) -const { navigateToPreferences, login } = require(`./common.js`) - -/* - * NOTE: don't use a global `let client = app.client` as the client object changes when restarting the app - */ - -test(`preferences`, async function(t) { - const { app } = await getApp(t) - const $ = (...args) => app.client.$(...args) - - await restart(app) - await login(app, `testkey`) - await navigateToPreferences(app) - - t.test(`shows preferences`, async function(t) { - t.ok(await $(`div*=Node IP`).waitForExist(), `shows Node IP`) - t.end() - }) - - t.end() -}) diff --git a/test/unit/specs/components/common/PagePreferences.spec.js b/test/unit/specs/components/common/PagePreferences.spec.js deleted file mode 100644 index ac562e1159..0000000000 --- a/test/unit/specs/components/common/PagePreferences.spec.js +++ /dev/null @@ -1,104 +0,0 @@ -import { shallowMount } from "@vue/test-utils" -import PagePreferences from "renderer/components/common/PagePreferences" - -jest.mock(`renderer/google-analytics.js`, () => () => { }) - -describe(`PagePreferences`, () => { - let wrapper, $store - - const getters = { - session: { - address: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`, - errorCollection: false, - experimentalMode: false - }, - mockedConnector: false, - nodeUrl: `http://localhost:9070` - } - - beforeEach(async () => { - $store = { - commit: jest.fn(), - dispatch: jest.fn(), - getters - } - - wrapper = shallowMount(PagePreferences, { - mocks: { - $store - } - }) - }) - - it(`has the expected html structure if connected`, async () => { - expect(wrapper.vm.$el).toMatchSnapshot() - expect(wrapper.vm.$el.outerHTML).toContain(`Node IP`) - expect(wrapper.vm.$el.outerHTML).toContain(`Automatically send`) - }) - describe(`should set error collection`, () => { - it(`when the user is in production or insecure mode`, async () => { - const errorCollection = false - const dispatch = jest.fn() - PagePreferences.methods.setErrorCollection.call({ - $store: { - dispatch - }, - session: { - address: `cosmos1address`, - experimentalMode: false - } - }) - expect(dispatch).toHaveBeenCalledWith(`setErrorCollection`, { - address: `cosmos1address`, - optin: !errorCollection - }) - }) - - it(`should not update error collection when user is on experimental mode`, async () => { - const errorCollection = false - const dispatch = jest.fn() - - PagePreferences.methods.setErrorCollection.call({ - $store: { - dispatch - }, - session: { - address: `cosmos1address`, - experimentalMode: true - } - }) - expect(dispatch).not.toHaveBeenCalledWith(`setErrorCollection`, { - address: `cosmos1address`, - optin: !errorCollection - }) - }) - - it(`should set an error when user tries to set error collection on experimental mode`, async () => { - wrapper = shallowMount(PagePreferences, { - mocks: { - $store: { - dispatch: jest.fn(), - getters: { - session: { - address: `cosmos15ky9du8a2wlstz6fpx3p4mqpjyrm5ctpesxxn9`, - errorCollection: false, - experimentalMode: true - }, - mockedConnector: false, - nodeUrl: `http://localhost:9070` - } - } - } - }) - - jest.useFakeTimers() - wrapper.vm.setErrorCollection() //old style to test timers - - expect(wrapper.vm.showError).toBe(true) - expect(wrapper.vm.$el.outerHTML).toContain(`Error collection is disabled during development.`) - - jest.runAllTimers() - expect(wrapper.vm.showError).toBe(false) - }) - }) -}) diff --git a/test/unit/specs/components/common/__snapshots__/PagePreferences.spec.js.snap b/test/unit/specs/components/common/__snapshots__/PagePreferences.spec.js.snap deleted file mode 100644 index a443b4fc4e..0000000000 --- a/test/unit/specs/components/common/__snapshots__/PagePreferences.spec.js.snap +++ /dev/null @@ -1,34 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`PagePreferences has the expected html structure if connected 1`] = ` - - - - - http://localhost:9070 - - - - - - - - - - -`; diff --git a/test/unit/specs/components/common/__snapshots__/ToolBar.spec.js.snap b/test/unit/specs/components/common/__snapshots__/ToolBar.spec.js.snap index 73b4c298c8..e17d236220 100644 --- a/test/unit/specs/components/common/__snapshots__/ToolBar.spec.js.snap +++ b/test/unit/specs/components/common/__snapshots__/ToolBar.spec.js.snap @@ -6,17 +6,6 @@ exports[`ToolBar has the expected html structure 1`] = ` > - - - settings - - - diff --git a/test/unit/specs/components/governance/__snapshots__/PageGovernance.spec.js.snap b/test/unit/specs/components/governance/__snapshots__/PageGovernance.spec.js.snap index 179af6b56b..071cf850e0 100644 --- a/test/unit/specs/components/governance/__snapshots__/PageGovernance.spec.js.snap +++ b/test/unit/specs/components/governance/__snapshots__/PageGovernance.spec.js.snap @@ -28,17 +28,6 @@ exports[`PageGovernance disables proposal creation if not connected 1`] = ` > - - - settings - - - @@ -150,17 +139,6 @@ exports[`PageGovernance has the expected html structure 1`] = ` > - - - settings - - -