From 732f9cc4f6d026037799bf8bd6cac4544129aa78 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Tue, 6 Nov 2018 12:35:24 -0500 Subject: [PATCH 01/20] get started with page validator --- .../components/governance/LiProposal.vue | 6 -- .../components/governance/PageProposal.vue | 97 +++++++++++++++++++ .../components/staking/PageValidator.vue | 3 +- app/src/renderer/routes.js | 11 ++- 4 files changed, 105 insertions(+), 12 deletions(-) create mode 100644 app/src/renderer/components/governance/PageProposal.vue diff --git a/app/src/renderer/components/governance/LiProposal.vue b/app/src/renderer/components/governance/LiProposal.vue index 0dd7231638..d109bed031 100644 --- a/app/src/renderer/components/governance/LiProposal.vue +++ b/app/src/renderer/components/governance/LiProposal.vue @@ -17,12 +17,6 @@ export default { statusColor() { if (this.proposal.proposal_status === `Rejected`) return `red` else if (this.proposal.proposal_status === `Passed`) return `green` - }, - // TODO redirect to proposal page - proposalLink() { - return { - name: `` - } } }, props: [`proposal`] diff --git a/app/src/renderer/components/governance/PageProposal.vue b/app/src/renderer/components/governance/PageProposal.vue new file mode 100644 index 0000000000..d4e512928c --- /dev/null +++ b/app/src/renderer/components/governance/PageProposal.vue @@ -0,0 +1,97 @@ + + + diff --git a/app/src/renderer/components/staking/PageValidator.vue b/app/src/renderer/components/staking/PageValidator.vue index f973ebfdd1..c3861045f6 100644 --- a/app/src/renderer/components/staking/PageValidator.vue +++ b/app/src/renderer/components/staking/PageValidator.vue @@ -452,6 +452,7 @@ export default { display inline-block font-size h1 line-height h1 + font-weight 400 padding 0 0.5rem 0.5rem 0 &__address @@ -519,7 +520,7 @@ export default { align-items center display flex flex-direction column - width 6rem + width 6.3rem &:not(:last-child) margin-right 1rem diff --git a/app/src/renderer/routes.js b/app/src/renderer/routes.js index c8bd7cee69..34cb062643 100644 --- a/app/src/renderer/routes.js +++ b/app/src/renderer/routes.js @@ -23,11 +23,12 @@ export default [ }, { path: `proposals/new`, component: governance(`ProposalsNewText`) }, // TODO: enable once PageProposal is finished - // { - // path: `proposals/:proposal`, - // name: `proposal`, - // component: governance(`Proposal`) - // }, + { + path: `proposals/:proposalId`, + name: `proposal`, + component: require(`./components/governance/PageProposal`).default, + props: true + }, // STAKE { From 5f1109181e0531c6e4b078529dcb05327dda9d81 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Tue, 6 Nov 2018 15:33:05 -0500 Subject: [PATCH 02/20] displaying all the data on page proposal --- .../components/governance/PageProposal.vue | 131 +++++++++++++++--- .../components/staking/PageValidator.vue | 3 + 2 files changed, 118 insertions(+), 16 deletions(-) diff --git a/app/src/renderer/components/governance/PageProposal.vue b/app/src/renderer/components/governance/PageProposal.vue index d4e512928c..9035a00cd8 100644 --- a/app/src/renderer/components/governance/PageProposal.vue +++ b/app/src/renderer/components/governance/PageProposal.vue @@ -7,20 +7,48 @@ tm-page(data-title='Proposal') tm-data-error(v-if="!proposal") template(v-else) - .validator-profile__header.validator-profile__section + .validator-profile__header.validator-profile__section.proposal .column.validator-profile__header__info .row.validator-profile__header__name - .column + .top.column div.validator-profile__status-and-title span.validator-profile__status(v-bind:class="statusColor" v-tooltip.top="status") .validator-profile__header__name__title {{ proposal.title }} - div {{ proposal.proposal_id }} .column.validator-profile__header__actions - tm-btn#delegation-btn(value="Vote" color="primary" @click.native="onDelegation") + tm-btn(v-if="button === 'vote'" value="Vote" color="primary" @click.native="vote") + tm-btn(v-if="button === 'deposit'" value="Deposit" color="primary" @click.native="deposit") + tm-btn(v-if="!button" disabled value="Deposit / Vote" color="primary") + + .row.description + p This {{ proposalType }} proposal ({{ `#` + proposal.proposal_id }}) was submitted at block {{ submitBlock }} and voting started at {{ voteBlock }}. + + .row.validator-profile__header__data.votes + dl.colored_dl + dt Deposit + dd {{ proposal.total_deposit[0].amount + ` ` + proposal.total_deposit[0].denom }} + .validator-profile__header__data__break + dl.colored_dl + dt Yes + dd {{ proposal.tally_result.yes }} / {{ yesPercentage }} + dl.colored_dl + dt No + dd {{ proposal.tally_result.no }} / {{ noPercentage }} + dl.colored_dl + dt No with Veto + dd {{ proposal.tally_result.no_with_veto }} / {{ noWithVetoPercentage }} + dl.colored_dl + dt Abstain + dd {{ proposal.tally_result.abstain }} / {{ abstainPercentage }} + + .validator-profile__details.validator-profile__section + .column + .row + text-block(:content="proposal.description") + diff --git a/app/src/renderer/components/staking/PageValidator.vue b/app/src/renderer/components/staking/PageValidator.vue index c3861045f6..58d8f67bfa 100644 --- a/app/src/renderer/components/staking/PageValidator.vue +++ b/app/src/renderer/components/staking/PageValidator.vue @@ -486,6 +486,9 @@ export default { &.green background var(--success) + &.blue + background var(--primary) + &__status-and-title align-items center display flex From 2a6b2b92e86958f445adf3711b20cbef1c53c366 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Wed, 7 Nov 2018 09:22:05 -0500 Subject: [PATCH 03/20] hooked up page proposal with li proposal and router --- .../renderer/components/common/TmBalance.vue | 4 +- .../components/governance/LiProposal.vue | 37 ++++++++++++++++--- .../components/governance/TableProposals.vue | 6 +++ .../components/staking/PageValidator.vue | 2 +- app/src/renderer/routes.js | 7 ++-- 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/app/src/renderer/components/common/TmBalance.vue b/app/src/renderer/components/common/TmBalance.vue index 63a29a817b..4e11640f07 100644 --- a/app/src/renderer/components/common/TmBalance.vue +++ b/app/src/renderer/components/common/TmBalance.vue @@ -130,5 +130,7 @@ export default { &.tab-selected border-bottom 2px solid var(--tertiary) - color var(--bright) + + a + color var(--bright) diff --git a/app/src/renderer/components/governance/LiProposal.vue b/app/src/renderer/components/governance/LiProposal.vue index d109bed031..5e6549d5b2 100644 --- a/app/src/renderer/components/governance/LiProposal.vue +++ b/app/src/renderer/components/governance/LiProposal.vue @@ -1,9 +1,11 @@ diff --git a/test/unit/specs/components/staking/PageProposal.spec.js b/test/unit/specs/components/staking/PageProposal.spec.js new file mode 100644 index 0000000000..cf60c12239 --- /dev/null +++ b/test/unit/specs/components/staking/PageProposal.spec.js @@ -0,0 +1,31 @@ +import setup from "../../../helpers/vuex-setup" +import PageProposal from "renderer/components/governance/PageProposal" +import lcdClientMock from "renderer/connectors/lcdClientMock.js" +import { createLocalVue, mount } from "@vue/test-utils" + +const proposal = lcdClientMock.state.proposals[0] + +describe(`PageProposal`, () => { + let wrapper, store + let { mount } = setup() + + beforeEach(() => { + let instance = mount(PageProposal, { + propsData: { + proposal + } + }) + wrapper = instance.wrapper + wrapper.update() + }) + + it(`has the expected html structure`, async () => { + // after importing the @tendermint/ui components from modules + // the perfect scroll plugin needs a $nextTick and a wrapper.update + // to work properly in the tests (snapshots weren't matching) + // this has occured across multiple tests + await wrapper.vm.$nextTick() + wrapper.update() + expect(wrapper.vm.$el).toMatchSnapshot() + }) +}) diff --git a/test/unit/specs/components/staking/__snapshots__/PageProposal.spec.js.snap b/test/unit/specs/components/staking/__snapshots__/PageProposal.spec.js.snap new file mode 100644 index 0000000000..db97aa4678 --- /dev/null +++ b/test/unit/specs/components/staking/__snapshots__/PageProposal.spec.js.snap @@ -0,0 +1,279 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`PageProposal has the expected html structure 1`] = ` +
+
+
+
+ + +
+
+
+
+ +
+
+

+ Total Steak +

+

+ 0.0000… +

+
+
+

+ Available Steak +

+

+ 0.0000… +

+
+ + +
+
+
+ Address Not Found +
+
+ + check + + + Copied + +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+ Proposal Title +
+
+
+
+ + + +
+
+
+

+ This text proposal (#1) was submitted at block #120 and voting started at block #135. +

+
+
+
+
+ Deposit +
+
+ 100 stake +
+
+
+
+
+ Yes +
+
+ 500 / 0% +
+
+
+
+ No +
+
+ 25 / 0% +
+
+
+
+ No with Veto +
+
+ 10 / 0% +
+
+
+
+ Abstain +
+
+ 56 / 0% +
+
+
+
+
+
+
+
+
+

+ Proposal description +

+ + +
+
+
+
+
+
+
+
+
+
+
+
+`; From 909cdfe71e7044f00a9e50a7a05c92e902bd6971 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Thu, 8 Nov 2018 12:21:33 -0500 Subject: [PATCH 10/20] page proposal tests --- .../components/governance/PageProposal.vue | 70 ++++++++------ .../components/staking/PageProposal.spec.js | 92 ++++++++++++++++++- 2 files changed, 131 insertions(+), 31 deletions(-) diff --git a/app/src/renderer/components/governance/PageProposal.vue b/app/src/renderer/components/governance/PageProposal.vue index 27b8b7b543..93266253e3 100644 --- a/app/src/renderer/components/governance/PageProposal.vue +++ b/app/src/renderer/components/governance/PageProposal.vue @@ -12,12 +12,12 @@ tm-page(data-title='Proposal') .row.validator-profile__header__name .top.column div.validator-profile__status-and-title - span.validator-profile__status(v-bind:class="statusColor" v-tooltip.top="status") + span.validator-profile__status(v-bind:class="status.color" v-tooltip.top="status.message") .validator-profile__header__name__title {{ proposal.title }} .column.validator-profile__header__actions - tm-btn(v-if="button === 'vote'" value="Vote" color="primary" @click.native="vote") - tm-btn(v-if="button === 'deposit'" value="Deposit" color="primary" @click.native="deposit") - tm-btn(v-if="!button" disabled value="Deposit / Vote" color="primary") + tm-btn(v-if="status.button === 'vote'" value="Vote" color="primary") + tm-btn(v-if="status.button === 'deposit'" value="Deposit" color="primary") + tm-btn(v-if="!status.button" disabled value="Deposit / Vote" color="primary") .row.description p This {{ proposalType }} proposal ({{ `#` + proposal.proposal_id }}) was submitted at block {{ submitBlock }} and voting started at {{ voteBlock }}. @@ -77,33 +77,43 @@ export default { return `block #` + num.prettyInt(this.proposal.voting_start_block) } }, - button() { - if (this.proposal.proposal_status === `Passed`) return null - - if (this.proposal.proposal_status === `Rejected`) return null - - if (this.proposal.proposal_status === `Active`) return `vote` - - if (this.proposal.proposal_status === `Pending`) return `deposit` - }, status() { - if (this.proposal.proposal_status === `Passed`) - return `This proposal has passed` - - if (this.proposal.proposal_status === `Rejected`) - return `This proposal has been rejected and voting is closed` - - if (this.proposal.proposal_status === `Active`) - return `Voting for this proposal is open` - - if (this.proposal.proposal_status === `Pending`) - return `Deposits are open for this proposal` - }, - statusColor() { - if (this.proposal.proposal_status === `Passed`) return `green` - if (this.proposal.proposal_status === `Rejected`) return `red` - if (this.proposal.proposal_status === `Active`) return `blue` - if (this.proposal.proposal_status === `Pending`) return `yellow` + switch (this.proposal.proposal_status) { + case `Passed`: + return { + button: null, + message: `This proposal has passed`, + color: `green` + } + break + case `Rejected`: + return { + button: null, + message: `This proposal has been rejected and voting is closed`, + color: `red` + } + break + case `Active`: + return { + button: `vote`, + message: `Voting for this proposal is open`, + color: `blue` + } + break + case `Pending`: + return { + button: `deposit`, + message: `Deposits are open for this proposal`, + color: `yellow` + } + break + default: + return { + button: null, + message: `There was an error determining the status of this proposal`, + color: `grey` + } + } }, totalVotes() { return ( diff --git a/test/unit/specs/components/staking/PageProposal.spec.js b/test/unit/specs/components/staking/PageProposal.spec.js index cf60c12239..b73591a2b1 100644 --- a/test/unit/specs/components/staking/PageProposal.spec.js +++ b/test/unit/specs/components/staking/PageProposal.spec.js @@ -3,7 +3,7 @@ import PageProposal from "renderer/components/governance/PageProposal" import lcdClientMock from "renderer/connectors/lcdClientMock.js" import { createLocalVue, mount } from "@vue/test-utils" -const proposal = lcdClientMock.state.proposals[0] +let proposal = lcdClientMock.state.proposals[0] describe(`PageProposal`, () => { let wrapper, store @@ -28,4 +28,94 @@ describe(`PageProposal`, () => { wrapper.update() expect(wrapper.vm.$el).toMatchSnapshot() }) + + it(`should return the block number`, () => { + expect(wrapper.vm.voteBlock).toBe(`block #135`) + }) + + it(`should return the end of the sentence`, () => { + proposal.submit_block = `135` + let { wrapper } = mount(PageProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.voteBlock).toBe(`the same block`) + }) + + it(`should return status info for passed proposals`, () => { + proposal.proposal_status = `Passed` + let { wrapper } = mount(PageProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: null, + message: `This proposal has passed`, + color: `green` + }) + }) + + it(`should return status info for rejected proposals`, () => { + proposal.proposal_status = `Rejected` + let { wrapper } = mount(PageProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: null, + message: `This proposal has been rejected and voting is closed`, + color: `red` + }) + }) + + it(`should return status info for active proposals`, () => { + proposal.proposal_status = `Active` + let { wrapper } = mount(PageProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: `vote`, + message: `Voting for this proposal is open`, + color: `blue` + }) + }) + + it(`should return status info for pending proposals`, () => { + proposal.proposal_status = `Pending` + let { wrapper } = mount(PageProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: `deposit`, + message: `Deposits are open for this proposal`, + color: `yellow` + }) + }) + + it(`should return an error message when proposal status is unknown`, () => { + proposal.proposal_status = undefined + let { wrapper } = mount(PageProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: null, + message: `There was an error determining the status of this proposal`, + color: `grey` + }) + }) }) From 26f26c5a76ffa3a6b94408e6fe6e1e07e5abd3d7 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Thu, 8 Nov 2018 12:50:46 -0500 Subject: [PATCH 11/20] lint --- test/unit/specs/components/staking/PageProposal.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/unit/specs/components/staking/PageProposal.spec.js b/test/unit/specs/components/staking/PageProposal.spec.js index b73591a2b1..c8689fb605 100644 --- a/test/unit/specs/components/staking/PageProposal.spec.js +++ b/test/unit/specs/components/staking/PageProposal.spec.js @@ -1,12 +1,11 @@ import setup from "../../../helpers/vuex-setup" import PageProposal from "renderer/components/governance/PageProposal" import lcdClientMock from "renderer/connectors/lcdClientMock.js" -import { createLocalVue, mount } from "@vue/test-utils" let proposal = lcdClientMock.state.proposals[0] describe(`PageProposal`, () => { - let wrapper, store + let wrapper let { mount } = setup() beforeEach(() => { From 5c4f6cb45209377bcb239aec96fa688e0b232ca3 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Thu, 8 Nov 2018 13:35:12 -0500 Subject: [PATCH 12/20] =?UTF-8?q?fixed=20e2e=20test=20=F0=9F=98=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/renderer/components/staking/PageValidator.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/renderer/components/staking/PageValidator.vue b/app/src/renderer/components/staking/PageValidator.vue index 4ca1d9b9d7..16d2dcf53e 100644 --- a/app/src/renderer/components/staking/PageValidator.vue +++ b/app/src/renderer/components/staking/PageValidator.vue @@ -523,7 +523,7 @@ export default { align-items center display flex flex-direction column - width 6.3rem + width 6rem &:not(:last-child) margin-right 1rem From 22eced1d921c7c2901f4b3447f4935e20a841115 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Thu, 8 Nov 2018 14:13:10 -0500 Subject: [PATCH 13/20] reduced code duplication and cleaned up tests --- .../components/governance/LiProposal.vue | 49 +++++++--- .../components/governance/PageProposal.vue | 40 +------- .../components/governance/LiProposal.spec.js | 91 ++++++++++++++++++- .../__snapshots__/LiProposal.spec.js.snap | 7 +- .../components/staking/PageProposal.spec.js | 86 ++---------------- 5 files changed, 137 insertions(+), 136 deletions(-) diff --git a/app/src/renderer/components/governance/LiProposal.vue b/app/src/renderer/components/governance/LiProposal.vue index 193bf39558..d972124954 100644 --- a/app/src/renderer/components/governance/LiProposal.vue +++ b/app/src/renderer/components/governance/LiProposal.vue @@ -2,7 +2,7 @@ tr.li-proposal.li-validator td.li-proposal__value h2 - router-link(:to="{ name: 'Proposal', params: { proposalId, proposal }}") {{ proposal.title }} + router-link(:to="{ name: 'Proposal', params: { proposalId, proposal, status }}") {{ proposal.title }} span.validator-profile__status(v-bind:class="statusColor" v-tooltip.top="status") p {{ description }} td {{ submitBlock }} @@ -24,17 +24,42 @@ export default { if (this.proposal.proposal_status === `Pending`) return `yellow` }, status() { - if (this.proposal.proposal_status === `Passed`) - return `This proposal has passed` - - if (this.proposal.proposal_status === `Rejected`) - return `This proposal has been rejected and voting is closed` - - if (this.proposal.proposal_status === `Active`) - return `Voting for this proposal is open` - - if (this.proposal.proposal_status === `Pending`) - return `Deposits are open for this proposal` + switch (this.proposal.proposal_status) { + case `Passed`: + return { + button: null, + message: `This proposal has passed`, + color: `green` + } + break + case `Rejected`: + return { + button: null, + message: `This proposal has been rejected and voting is closed`, + color: `red` + } + break + case `Active`: + return { + button: `vote`, + message: `Voting for this proposal is open`, + color: `blue` + } + break + case `Pending`: + return { + button: `deposit`, + message: `Deposits are open for this proposal`, + color: `yellow` + } + break + default: + return { + button: null, + message: `There was an error determining the status of this proposal`, + color: `grey` + } + } }, description() { return this.proposal.description.substring(0, 100) diff --git a/app/src/renderer/components/governance/PageProposal.vue b/app/src/renderer/components/governance/PageProposal.vue index 93266253e3..1aa7fe83e9 100644 --- a/app/src/renderer/components/governance/PageProposal.vue +++ b/app/src/renderer/components/governance/PageProposal.vue @@ -54,7 +54,7 @@ import FieldVote from "common/TmFieldVote" import TextBlock from "common/TextBlock" export default { name: `page-proposal`, - props: [`proposal`], + props: [`proposal`, `status`], components: { TmBalance, TmBtn, @@ -77,44 +77,6 @@ export default { return `block #` + num.prettyInt(this.proposal.voting_start_block) } }, - status() { - switch (this.proposal.proposal_status) { - case `Passed`: - return { - button: null, - message: `This proposal has passed`, - color: `green` - } - break - case `Rejected`: - return { - button: null, - message: `This proposal has been rejected and voting is closed`, - color: `red` - } - break - case `Active`: - return { - button: `vote`, - message: `Voting for this proposal is open`, - color: `blue` - } - break - case `Pending`: - return { - button: `deposit`, - message: `Deposits are open for this proposal`, - color: `yellow` - } - break - default: - return { - button: null, - message: `There was an error determining the status of this proposal`, - color: `grey` - } - } - }, totalVotes() { return ( this.proposal.tally_result.yes + diff --git a/test/unit/specs/components/governance/LiProposal.spec.js b/test/unit/specs/components/governance/LiProposal.spec.js index 6b98dc973a..c8e464c68d 100644 --- a/test/unit/specs/components/governance/LiProposal.spec.js +++ b/test/unit/specs/components/governance/LiProposal.spec.js @@ -1,18 +1,99 @@ -import { shallow } from "@vue/test-utils" +import setup from "../../../helpers/vuex-setup" import lcdClientMock from "renderer/connectors/lcdClientMock.js" import LiProposal from "renderer/components/governance/LiProposal" +let proposal = lcdClientMock.state.proposals[0] + describe(`LiProposal`, () => { let wrapper - const propsData = { - proposal: lcdClientMock.state.proposals[0] - } + let { mount } = setup() beforeEach(() => { - wrapper = shallow(LiProposal, { propsData }) + let instance = mount(LiProposal, { + propsData: { + proposal + } + }) + wrapper = instance.wrapper + wrapper.update() }) it(`has the expected html structure`, () => { expect(wrapper.vm.$el).toMatchSnapshot() }) + + it(`should return status info for passed proposals`, () => { + proposal.proposal_status = `Passed` + let { wrapper } = mount(LiProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: null, + message: `This proposal has passed`, + color: `green` + }) + }) + + it(`should return status info for rejected proposals`, () => { + proposal.proposal_status = `Rejected` + let { wrapper } = mount(LiProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: null, + message: `This proposal has been rejected and voting is closed`, + color: `red` + }) + }) + + it(`should return status info for active proposals`, () => { + proposal.proposal_status = `Active` + let { wrapper } = mount(LiProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: `vote`, + message: `Voting for this proposal is open`, + color: `blue` + }) + }) + + it(`should return status info for pending proposals`, () => { + proposal.proposal_status = `Pending` + let { wrapper } = mount(LiProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: `deposit`, + message: `Deposits are open for this proposal`, + color: `yellow` + }) + }) + + it(`should return an error message when proposal status is unknown`, () => { + proposal.proposal_status = undefined + let { wrapper } = mount(LiProposal, { + propsData: { + proposal + } + }) + wrapper.update() + expect(wrapper.vm.status).toEqual({ + button: null, + message: `There was an error determining the status of this proposal`, + color: `grey` + }) + }) }) diff --git a/test/unit/specs/components/governance/__snapshots__/LiProposal.spec.js.snap b/test/unit/specs/components/governance/__snapshots__/LiProposal.spec.js.snap index 132e88f685..a56fb21afe 100644 --- a/test/unit/specs/components/governance/__snapshots__/LiProposal.spec.js.snap +++ b/test/unit/specs/components/governance/__snapshots__/LiProposal.spec.js.snap @@ -8,11 +8,12 @@ exports[`LiProposal has the expected html structure 1`] = ` class="li-proposal__value" >

- Proposal Title - +

{ let wrapper @@ -11,7 +16,8 @@ describe(`PageProposal`, () => { beforeEach(() => { let instance = mount(PageProposal, { propsData: { - proposal + proposal, + status } }) wrapper = instance.wrapper @@ -36,85 +42,11 @@ describe(`PageProposal`, () => { proposal.submit_block = `135` let { wrapper } = mount(PageProposal, { propsData: { - proposal + proposal, + status } }) wrapper.update() expect(wrapper.vm.voteBlock).toBe(`the same block`) }) - - it(`should return status info for passed proposals`, () => { - proposal.proposal_status = `Passed` - let { wrapper } = mount(PageProposal, { - propsData: { - proposal - } - }) - wrapper.update() - expect(wrapper.vm.status).toEqual({ - button: null, - message: `This proposal has passed`, - color: `green` - }) - }) - - it(`should return status info for rejected proposals`, () => { - proposal.proposal_status = `Rejected` - let { wrapper } = mount(PageProposal, { - propsData: { - proposal - } - }) - wrapper.update() - expect(wrapper.vm.status).toEqual({ - button: null, - message: `This proposal has been rejected and voting is closed`, - color: `red` - }) - }) - - it(`should return status info for active proposals`, () => { - proposal.proposal_status = `Active` - let { wrapper } = mount(PageProposal, { - propsData: { - proposal - } - }) - wrapper.update() - expect(wrapper.vm.status).toEqual({ - button: `vote`, - message: `Voting for this proposal is open`, - color: `blue` - }) - }) - - it(`should return status info for pending proposals`, () => { - proposal.proposal_status = `Pending` - let { wrapper } = mount(PageProposal, { - propsData: { - proposal - } - }) - wrapper.update() - expect(wrapper.vm.status).toEqual({ - button: `deposit`, - message: `Deposits are open for this proposal`, - color: `yellow` - }) - }) - - it(`should return an error message when proposal status is unknown`, () => { - proposal.proposal_status = undefined - let { wrapper } = mount(PageProposal, { - propsData: { - proposal - } - }) - wrapper.update() - expect(wrapper.vm.status).toEqual({ - button: null, - message: `There was an error determining the status of this proposal`, - color: `grey` - }) - }) }) From 74443d1add06e15ffd0a5c0252bc768a8f20d243 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Thu, 8 Nov 2018 14:29:10 -0500 Subject: [PATCH 14/20] clean up tests --- app/src/renderer/components/governance/LiProposal.vue | 10 ++-------- .../governance/__snapshots__/LiProposal.spec.js.snap | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/src/renderer/components/governance/LiProposal.vue b/app/src/renderer/components/governance/LiProposal.vue index d972124954..63855f76db 100644 --- a/app/src/renderer/components/governance/LiProposal.vue +++ b/app/src/renderer/components/governance/LiProposal.vue @@ -3,7 +3,7 @@ tr.li-proposal.li-validator td.li-proposal__value h2 router-link(:to="{ name: 'Proposal', params: { proposalId, proposal, status }}") {{ proposal.title }} - span.validator-profile__status(v-bind:class="statusColor" v-tooltip.top="status") + span.validator-profile__status(v-bind:class="status.color" v-tooltip.top="status.message") p {{ description }} td {{ submitBlock }} td.li-proposal__value.yes {{ proposal.tally_result.yes }} @@ -17,12 +17,6 @@ import num from "scripts/num" export default { name: `li-proposal`, computed: { - statusColor() { - if (this.proposal.proposal_status === `Passed`) return `green` - if (this.proposal.proposal_status === `Rejected`) return `red` - if (this.proposal.proposal_status === `Active`) return `blue` - if (this.proposal.proposal_status === `Pending`) return `yellow` - }, status() { switch (this.proposal.proposal_status) { case `Passed`: @@ -62,7 +56,7 @@ export default { } }, description() { - return this.proposal.description.substring(0, 100) + return this.proposal.description.substring(0, 100) + `…` }, submitBlock() { return `#` + num.prettyInt(this.proposal.submit_block) diff --git a/test/unit/specs/components/governance/__snapshots__/LiProposal.spec.js.snap b/test/unit/specs/components/governance/__snapshots__/LiProposal.spec.js.snap index a56fb21afe..7a951ccac2 100644 --- a/test/unit/specs/components/governance/__snapshots__/LiProposal.spec.js.snap +++ b/test/unit/specs/components/governance/__snapshots__/LiProposal.spec.js.snap @@ -19,7 +19,7 @@ exports[`LiProposal has the expected html structure 1`] = ` class="validator-profile__status green" />

- Proposal description + Proposal description…

From 34ab41a002bc379f71241efc0963ff6edb545744 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Thu, 8 Nov 2018 14:31:51 -0500 Subject: [PATCH 15/20] update the good ol' snapperoos --- .../governance/__snapshots__/TabProposals.spec.js.snap | 6 +++--- .../__snapshots__/TableProposals.spec.js.snap | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/unit/specs/components/governance/__snapshots__/TabProposals.spec.js.snap b/test/unit/specs/components/governance/__snapshots__/TabProposals.spec.js.snap index 7924c2d2d8..672e034421 100644 --- a/test/unit/specs/components/governance/__snapshots__/TabProposals.spec.js.snap +++ b/test/unit/specs/components/governance/__snapshots__/TabProposals.spec.js.snap @@ -31,9 +31,9 @@ exports[`TabProposals has the expected html structure 1`] = `

Custom text proposal

- +

- custom text proposal description + custom text proposal description…

@@ -59,7 +59,7 @@ exports[`TabProposals has the expected html structure 1`] = `

- Proposal description + Proposal description…

diff --git a/test/unit/specs/components/governance/__snapshots__/TableProposals.spec.js.snap b/test/unit/specs/components/governance/__snapshots__/TableProposals.spec.js.snap index db9bc5bfd5..5e312d35aa 100644 --- a/test/unit/specs/components/governance/__snapshots__/TableProposals.spec.js.snap +++ b/test/unit/specs/components/governance/__snapshots__/TableProposals.spec.js.snap @@ -31,9 +31,9 @@ exports[`TableProposals has the expected html structure 1`] = `

Custom text proposal

- +

- custom text proposal description + custom text proposal description…

@@ -59,7 +59,7 @@ exports[`TableProposals has the expected html structure 1`] = `

- Proposal description + Proposal description…

@@ -162,10 +162,10 @@ exports[`TableProposals should filter the proposals 1`] = `

- custom text proposal description + custom text proposal description…

From 8ab024e6f788a50d12f2dc31a9b4fe650127eb09 Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Thu, 8 Nov 2018 15:23:26 -0500 Subject: [PATCH 16/20] removed switch, fixed tests, snap snaps --- .../components/governance/LiProposal.vue | 82 ++++++++++--------- .../components/governance/LiProposal.spec.js | 15 ---- .../__snapshots__/LiProposal.spec.js.snap | 8 +- .../__snapshots__/TabProposals.spec.js.snap | 31 +------ .../__snapshots__/TableProposals.spec.js.snap | 77 +---------------- 5 files changed, 54 insertions(+), 159 deletions(-) diff --git a/app/src/renderer/components/governance/LiProposal.vue b/app/src/renderer/components/governance/LiProposal.vue index 63855f76db..98898a6766 100644 --- a/app/src/renderer/components/governance/LiProposal.vue +++ b/app/src/renderer/components/governance/LiProposal.vue @@ -1,9 +1,9 @@