Commit 35cb061f authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch '11821-insights-back-json-fix' into 'master'

Fix Insights displaying JSON on back navigation

Closes #11821

See merge request gitlab-org/gitlab!25801
parents 536adae2 d5bb7ee3
---
title: Fix Insights displaying JSON on back navigation
merge_request: 25801
author:
type: fixed
- @no_container = true
= render('shared/insights', endpoint: group_insights_path(@group), query_endpoint: query_group_insights_path(@group))
= render('shared/insights', endpoint: group_insights_path(@group, format: :json), query_endpoint: query_group_insights_path(@group))
- @no_container = true
= render('shared/insights', endpoint: namespace_project_insights_path(@project.namespace, @project), query_endpoint: query_namespace_project_insights_path(@project.namespace, @project))
= render('shared/insights', endpoint: namespace_project_insights_path(@project.namespace, @project, format: :json), query_endpoint: query_namespace_project_insights_path(@project.namespace, @project))
......@@ -3,7 +3,7 @@
RSpec.shared_examples 'Insights page' do
let_it_be(:user) { create(:user) }
context 'as a permitted user' do
describe 'as a permitted user' do
before(:context) do
entity.add_maintainer(user)
end
......@@ -24,22 +24,43 @@ RSpec.shared_examples 'Insights page' do
expect(page).to have_content('Insights')
end
context 'hash fragment navigation', :js do
context 'navigation' do
let(:config) { entity.insights_config }
let(:non_default_tab_id) { config.keys.last }
let(:non_default_tab_title) { config[non_default_tab_id][:title] }
let(:hash_fragment) { "#/#{non_default_tab_id}" }
let(:route) { path + hash_fragment }
let(:default_tab_id) { config.each_key.first }
let(:default_tab_title) { config[default_tab_id][:title] }
let(:route) { path }
before do
visit route
wait_for_requests
end
it 'loads the correct page' do
it 'by default loads the first page', :js do
page.within(".insights-container") do
expect(page).to have_content(default_tab_title)
end
end
context 'hash fragment navigation' do
let(:non_default_tab_id) { config.keys.last }
let(:non_default_tab_title) { config[non_default_tab_id][:title] }
let(:hash_fragment) { "#/#{non_default_tab_id}" }
let(:route) { path + hash_fragment }
it 'loads the correct page', :js do
page.within(".insights-container") do
expect(page).to have_content(non_default_tab_title)
end
end
end
it 'displays correctly when navigating back to insights', :js do
visit root_path
page.evaluate_script('window.history.back()')
page.within(".insights-container") do
expect(page).to have_content(non_default_tab_title)
expect(page).to have_content(default_tab_title)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment