From 0f005a1663f82d46485a13840cbdff5c07eead48 Mon Sep 17 00:00:00 2001 From: Fabian Date: Fri, 22 Dec 2017 13:41:21 +0100 Subject: [PATCH 1/8] PageDelegate production ready --- .../renderer/components/staking/LiDelegate.vue | 5 ++--- .../renderer/components/staking/PageDelegate.vue | 15 ++++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/renderer/components/staking/LiDelegate.vue b/app/src/renderer/components/staking/LiDelegate.vue index 6b548d31a7..7fa271a893 100644 --- a/app/src/renderer/components/staking/LiDelegate.vue +++ b/app/src/renderer/components/staking/LiDelegate.vue @@ -7,9 +7,8 @@ transition(name='ts-li-delegate'): div(:class='styles') template i.fa.fa-check-square-o(v-if='inCart' @click='rm(delegate)') i.fa.fa-square-o(v-else @click='add(delegate)') - router-link(v-if="config.devMode" :to="{ name: 'delegate', params: { delegate: delegate.id }}") + router-link(:to="{ name: 'delegate', params: { delegate: delegate.id }}") | {{ delegate.id }} - a(v-else) {{ delegate.id }} .value {{ delegate.country ? delegate.country : 'n/a' }} .value.voting_power.num.bar span {{ num.prettyInt(delegate.voting_power) }} @@ -36,7 +35,7 @@ export default { Btn }, computed: { - ...mapGetters(['shoppingCart', 'delegates', 'config']), + ...mapGetters(['shoppingCart', 'delegates']), styles () { let value = 'li-delegate' if (this.inCart) value += ' li-delegate-active ' diff --git a/app/src/renderer/components/staking/PageDelegate.vue b/app/src/renderer/components/staking/PageDelegate.vue index 7f506b7556..f7ba895a0d 100644 --- a/app/src/renderer/components/staking/PageDelegate.vue +++ b/app/src/renderer/components/staking/PageDelegate.vue @@ -8,17 +8,18 @@ page(icon="storage" :title="delegate.keybaseID") a(v-if='inCart' @click.native='rm(delegate.id)') i.material-icons delete .label Remove - a(v-else @click.native='add(delegate.id)') + a(v-else-if="config.devMode" @click.native='add(delegate.id)') i.material-icons add .label Add part(title="Delegate Description") - text-block(:content="delegate.description") + list-item(dt='Name' :dd='delegate.description.moniker') + text-block(v-if="delegate.description.website" :content="delegate.description.details") part(title="Delegate Details") list-item(dt='Public Key' :dd='delegate.id') - list-item(dt='Country' :dd='delegate.country') - list-item(dt='Start Date' :dd='delegate.startDate') - part(title="Delegate Stake") + list-item(dt='Country' :dd='delegate.country || "n/a"') + list-item(dt='Start Date' :dd='delegate.startDate || "n/a"') + part(title="Delegate Stake" v-if="config.devMode") list-item(dt='Voting Power' :dd='delegate.voting_power + " ATOM"') list-item(dt='Shares' :dd='delegate.shares + " ATOM"') list-item(dt='Commission' @@ -29,7 +30,7 @@ page(icon="storage" :title="delegate.keybaseID") :dd='(delegate.commissionMaxRate * 100).toFixed(2) + "%"') part(title="External") - list-item(dt="Website" :dd="delegate.url" :href="delegate.url") + list-item(dt="Website" :dd="delegate.description.website" :href="delegate.description.website") diff --git a/test/unit/specs/PageDelegate.spec.js b/test/unit/specs/PageDelegate.spec.js new file mode 100644 index 0000000000..6d9a5b601d --- /dev/null +++ b/test/unit/specs/PageDelegate.spec.js @@ -0,0 +1,45 @@ +import setup from '../helpers/vuex-setup' +import PageDelegate from 'renderer/components/staking/PageDelegate' + +describe('PageDelegate', () => { + let wrapper, store, router + let {mount} = setup() + + beforeEach(() => { + let instance = mount(PageDelegate) + wrapper = instance.wrapper + store = instance.store + router = instance.router + + store.commit('addDelegate', { + pub_key: { + type: 'ed25519', + data: 'pubkeyX' + }, + voting_power: 10000, + shares: 5000, + description: { + description: 'descriptionX', + keybaseID: 'keybaseX', + country: 'US' + } + }) + router.push('/staking/delegates/pubkeyX') + }) + + it('has the expected html structure', () => { + expect(wrapper.vm.$el).toMatchSnapshot() + }) + + it('should add/remove candidate to cart', () => { + expect(wrapper.vm.inCart).toBe(false) + wrapper.vm.add(wrapper.vm.delegate) + expect(wrapper.vm.inCart).toBe(true) + wrapper.vm.rm('pubkeyX') + expect(wrapper.vm.inCart).toBe(false) + }) + + it('should show the correct country name', () => { + expect(wrapper.html()).toContain('United States') + }) +}) diff --git a/test/unit/specs/__snapshots__/PageDelegate.spec.js.snap b/test/unit/specs/__snapshots__/PageDelegate.spec.js.snap new file mode 100644 index 0000000000..d0fe7a9142 --- /dev/null +++ b/test/unit/specs/__snapshots__/PageDelegate.spec.js.snap @@ -0,0 +1,498 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PageDelegate has the expected html structure 1`] = ` +
+
+
+
+
+
+ keybaseX +
+
+
+
+ +
+
+
+ + + +
+
+
+
+
+
+
+
+ Delegate Description +
+ +
+
+
+
+
+
+ +
+
+
+ Name +
+
+ +
+
+
+
+ +
+
+
+
+
+
+
+
+ Delegate Details +
+ +
+
+
+
+
+
+ +
+
+
+ Public Key +
+
+ pubkeyX +
+
+
+
+
+
+
+ +
+
+
+ Country +
+
+ United States +
+
+
+
+
+
+
+ +
+
+
+ Start Date +
+
+ n/a +
+
+
+
+
+
+
+
+
+
+
+
+ Delegate Stake +
+ +
+
+
+
+
+
+ +
+
+
+ Voting Power +
+
+ 10000 ATOM +
+
+
+
+
+
+
+ +
+
+
+ Shares +
+
+ 5000 ATOM +
+
+
+
+
+
+
+ +
+
+
+ Commission +
+
+ NaN% +
+
+
+
+
+
+
+ +
+
+
+ Max Commission +
+
+ NaN% +
+
+
+
+
+
+
+ +
+
+
+ Max Commission Increase +
+
+ NaN% +
+
+
+
+
+
+
+
+
+
+
+
+ External +
+ +
+
+
+
+
+
+ +
+
+
+ Website +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`; From c4665714b0385ba195e1a871a6340de8fe577541 Mon Sep 17 00:00:00 2001 From: Fabian Date: Wed, 27 Dec 2017 16:20:22 +0100 Subject: [PATCH 4/8] added more codecov to PageDelegates --- test/unit/specs/PageDelegates.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/unit/specs/PageDelegates.spec.js b/test/unit/specs/PageDelegates.spec.js index b7a91cb999..09e84691c4 100644 --- a/test/unit/specs/PageDelegates.spec.js +++ b/test/unit/specs/PageDelegates.spec.js @@ -10,6 +10,7 @@ describe('PageDelegates', () => { wrapper = instance.wrapper store = instance.store + store.state.user.address = 'abc' store.commit('addDelegate', { pub_key: { type: 'ed25519', From e722f2b2afa201d018715921591f3e02b497b80d Mon Sep 17 00:00:00 2001 From: Fabian Date: Wed, 27 Dec 2017 17:30:40 +0100 Subject: [PATCH 5/8] linted --- app/src/renderer/components/staking/PageDelegate.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/renderer/components/staking/PageDelegate.vue b/app/src/renderer/components/staking/PageDelegate.vue index 2962feba39..e9e9f9886e 100644 --- a/app/src/renderer/components/staking/PageDelegate.vue +++ b/app/src/renderer/components/staking/PageDelegate.vue @@ -66,7 +66,7 @@ export default { return this.shoppingCart.find(c => c.id === this.delegate.id) !== undefined }, country () { - return this.delegate.country ? this.countryName(this.delegate.country) : "n/a" + return this.delegate.country ? this.countryName(this.delegate.country) : 'n/a' } }, methods: { From 61ba03ceb0acff2167947ea1f197bf2fb26dc197 Mon Sep 17 00:00:00 2001 From: Peng Zhong Date: Thu, 28 Dec 2017 12:12:35 +0900 Subject: [PATCH 6/8] move moniker to title area, change Shares -> Bonded Atoms --- app/src/renderer/components/staking/PageDelegate.vue | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/renderer/components/staking/PageDelegate.vue b/app/src/renderer/components/staking/PageDelegate.vue index e9e9f9886e..8838e89e48 100644 --- a/app/src/renderer/components/staking/PageDelegate.vue +++ b/app/src/renderer/components/staking/PageDelegate.vue @@ -1,5 +1,5 @@