From 7e7ca9faf1f8270d54f7731747db0d44c928492c Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Thu, 6 Sep 2018 12:43:14 +0000 Subject: Resolve "Remove usage ping payload from Cohorts, add to Settings" --- .../instance_statistics/cohorts_controller_spec.rb | 14 +++++++++++++ spec/features/admin/admin_settings_spec.rb | 9 +++++++++ spec/features/instance_statistics/cohorts_spec.rb | 8 -------- .../conversational_development_index_spec.rb | 10 +++++++++- .../instance_statistics/instance_statistics.rb | 23 ++++++++++++++++++++++ 5 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 spec/features/instance_statistics/instance_statistics.rb (limited to 'spec') diff --git a/spec/controllers/instance_statistics/cohorts_controller_spec.rb b/spec/controllers/instance_statistics/cohorts_controller_spec.rb index e4eedede93a..596d3c7abe5 100644 --- a/spec/controllers/instance_statistics/cohorts_controller_spec.rb +++ b/spec/controllers/instance_statistics/cohorts_controller_spec.rb @@ -3,5 +3,19 @@ require 'spec_helper' describe InstanceStatistics::CohortsController do + let(:user) { create(:user) } + + before do + sign_in(user) + end + it_behaves_like 'instance statistics availability' + + it 'renders a 404 when the usage ping is disabled' do + stub_application_setting(usage_ping_enabled: false) + + get :index + + expect(response).to have_gitlab_http_status(:not_found) + end end diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index a3229fe1741..3c65b5898b4 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -336,6 +336,15 @@ describe 'Admin updates settings' do expect(find_field('ED25519 SSH keys').value).to eq(forbidden) end + it 'loads usage ping payload on click', :js do + expect(page).to have_button 'Preview payload' + + find('.js-usage-ping-payload-trigger').click + + expect(page).to have_selector '.js-usage-ping-payload' + expect(page).to have_button 'Hide payload' + end + def check_all_events page.check('Active') page.check('Push') diff --git a/spec/features/instance_statistics/cohorts_spec.rb b/spec/features/instance_statistics/cohorts_spec.rb index 573f8600be1..81fc5eff980 100644 --- a/spec/features/instance_statistics/cohorts_spec.rb +++ b/spec/features/instance_statistics/cohorts_spec.rb @@ -12,12 +12,4 @@ describe 'Cohorts page' do expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0") end - - it 'shows usage data', :js do - visit instance_statistics_cohorts_path - - wait_for_requests - - expect(find('.js-syntax-highlight').text).not_to eq('') - end end diff --git a/spec/features/instance_statistics/conversational_development_index_spec.rb b/spec/features/instance_statistics/conversational_development_index_spec.rb index a6c16b6a2a3..d8be554d734 100644 --- a/spec/features/instance_statistics/conversational_development_index_spec.rb +++ b/spec/features/instance_statistics/conversational_development_index_spec.rb @@ -16,13 +16,21 @@ describe 'Conversational Development Index' do end context 'when usage ping is disabled' do - it 'shows empty state' do + before do stub_application_setting(usage_ping_enabled: false) + end + it 'shows empty state' do visit instance_statistics_conversational_development_index_index_path expect(page).to have_content('Usage ping is not enabled') end + + 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 end context 'when there is no data to display' do diff --git a/spec/features/instance_statistics/instance_statistics.rb b/spec/features/instance_statistics/instance_statistics.rb new file mode 100644 index 00000000000..d03e6e68075 --- /dev/null +++ b/spec/features/instance_statistics/instance_statistics.rb @@ -0,0 +1,23 @@ +require 'rails_helper' + +describe 'Cohorts page', :js do + before do + sign_in(create(:admin)) + end + + it 'hides cohorts nav button when usage ping is disabled' do + stub_application_setting(usage_ping_enabled: false) + + visit instance_statistics_root_path + + expect(find('.nav-sidebar')).not_to have_content('Cohorts') + end + + it 'shows cohorts nav button when usage ping is enabled' do + stub_application_setting(usage_ping_enabled: true) + + visit instance_statistics_root_path + + expect(find('.nav-sidebar')).to have_content('Cohorts') + end +end -- cgit v1.2.3