require 'features_helper'

describe 'Provenance Governance' do
  let!(:chain) { create(:provenance_chain) }
  let!(:proposal) { create(:provenance_governance_proposal, chain: chain, total_deposit: [{ 'denom': 'nhash', 'amount': '51200000' }]) }
  let!(:below_threshold_proposal) { create(:provenance_governance_proposal, ext_id: 28, title: 'Prop with < 10 percent deposits', chain: chain, total_deposit: [{ 'denom': 'nhash', 'amount': '51199999' }]) }

  it 'Visiting Provenance Governance Index as not signed in user' do
    visit "/provenance/chains/#{chain.slug}/governance"

    expect(page).to have_content(chain.name)
    expect(page).to have_content(proposal.title)
    expect(page).not_to have_content(below_threshold_proposal.title)
  end

  it 'visiting Provenance Governance View as not signed in user' do
    visit "/provenance/chains/#{chain.slug}/governance/proposals/#{proposal.ext_id}"

    expect(page).to have_content(chain.name)
    expect(page).to have_content(proposal.title)
    expect(page).to have_content('33.4%')
  end
end
