conversational_development_index_spec.rb 1.63 KB
Newer Older
1 2
require 'spec_helper'

3
describe 'Conversational Development Index' do
4
  before do
5
    sign_in(create(:admin))
6 7
  end

8 9 10 11 12 13 14 15 16 17
  it 'has dismissable intro callout', :js do
    visit instance_statistics_conversational_development_index_index_path

    expect(page).to have_content 'Introducing Your Conversational Development Index'

    find('.js-close-callout').click

    expect(page).not_to have_content 'Introducing Your Conversational Development Index'
  end

18
  context 'when usage ping is disabled' do
19
    before do
20
      stub_application_setting(usage_ping_enabled: false)
21
    end
22

23
    it 'shows empty state' do
24
      visit instance_statistics_conversational_development_index_index_path
25 26 27

      expect(page).to have_content('Usage ping is not enabled')
    end
28 29 30 31 32 33

    it 'hides the intro callout' do
      visit instance_statistics_conversational_development_index_index_path

      expect(page).not_to have_content 'Introducing Your Conversational Development Index'
    end
34 35 36 37 38 39
  end

  context 'when there is no data to display' do
    it 'shows empty state' do
      stub_application_setting(usage_ping_enabled: true)

40
      visit instance_statistics_conversational_development_index_index_path
41 42 43 44 45 46 47 48 49 50

      expect(page).to have_content('Data is still calculating')
    end
  end

  context 'when there is data to display' do
    it 'shows numbers for each metric' do
      stub_application_setting(usage_ping_enabled: true)
      create(:conversational_development_index_metric)

51
      visit instance_statistics_conversational_development_index_index_path
52 53 54 55 56 57 58

      expect(page).to have_content(
        'Issues created per active user 1.2 You 9.3 Lead 13.3%'
      )
    end
  end
end