diff options
author | Reuben Pereira <rpereira@gitlab.com> | 2019-06-26 14:53:55 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-06-26 14:53:55 +0000 |
commit | b13cd6737a2cb175c1f4501c1c5e0d01c060fa39 (patch) | |
tree | f7eec0d426e9253418d8960e90f83516ab4d01bd /spec/features/projects | |
parent | 5b97ea3e6ae872a5c72695a425083affad2d1dfc (diff) | |
download | gitlab-ce-b13cd6737a2cb175c1f4501c1c5e0d01c060fa39.tar.gz |
Always display environment selector
On the metrics dashboard, always display the environment selector,
even if there is no data to display for that environment. This allows
the user to switch to the metrics dashboard of another environment.
Diffstat (limited to 'spec/features/projects')
-rw-r--r-- | spec/features/projects/environments/environment_metrics_spec.rb | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/spec/features/projects/environments/environment_metrics_spec.rb b/spec/features/projects/environments/environment_metrics_spec.rb index edbab14f7c1..b08ccdc2a7c 100644 --- a/spec/features/projects/environments/environment_metrics_spec.rb +++ b/spec/features/projects/environments/environment_metrics_spec.rb @@ -9,11 +9,11 @@ describe 'Environment > Metrics' do let(:build) { create(:ci_build, pipeline: pipeline) } let(:environment) { create(:environment, project: project) } let(:current_time) { Time.now.utc } + let!(:staging) { create(:environment, name: 'staging', project: project) } before do project.add_developer(user) - create(:deployment, environment: environment, deployable: build) - stub_all_prometheus_requests(environment.slug) + stub_any_prometheus_request sign_in(user) visit_environment(environment) @@ -23,15 +23,50 @@ describe 'Environment > Metrics' do Timecop.freeze(current_time) { example.run } end + shared_examples 'has environment selector' do + it 'has a working environment selector', :js do + click_link('See metrics') + + expect(page).to have_metrics_path(environment) + expect(page).to have_css('div.js-environments-dropdown') + + within('div.js-environments-dropdown') do + # Click on the dropdown + click_on(environment.name) + + # Select the staging environment + click_on(staging.name) + end + + expect(page).to have_metrics_path(staging) + + wait_for_requests + end + end + + context 'without deployments' do + it_behaves_like 'has environment selector' + end + context 'with deployments and related deployable present' do + before do + create(:deployment, environment: environment, deployable: build) + end + it 'shows metrics' do click_link('See metrics') expect(page).to have_css('div#prometheus-graphs') end + + it_behaves_like 'has environment selector' end def visit_environment(environment) visit project_environment_path(environment.project, environment) end + + def have_metrics_path(environment) + have_current_path(metrics_project_environment_path(project, id: environment.id)) + end end |