diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-18 06:09:26 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-18 06:09:26 +0000 |
commit | eb6f2239b44c99f795d0f614324c0804c556b3d5 (patch) | |
tree | 798d7c062ca5a02e1dcb18bc3c628dc54c86ec34 /spec/features/markdown | |
parent | 1f39f07db14d2525d305a824c0b390e96020aac6 (diff) | |
download | gitlab-ce-eb6f2239b44c99f795d0f614324c0804c556b3d5.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/markdown')
-rw-r--r-- | spec/features/markdown/observability_spec.rb | 134 |
1 files changed, 33 insertions, 101 deletions
diff --git a/spec/features/markdown/observability_spec.rb b/spec/features/markdown/observability_spec.rb index 86caf3eb1b1..0b380c74777 100644 --- a/spec/features/markdown/observability_spec.rb +++ b/spec/features/markdown/observability_spec.rb @@ -2,90 +2,50 @@ require 'spec_helper' -RSpec.describe 'Observability rendering', :js do +RSpec.describe 'Observability rendering', :js, feature_category: :metrics do let_it_be(:group) { create(:group, :public) } let_it_be(:project) { create(:project, :repository, group: group) } let_it_be(:user) { create(:user) } - let_it_be(:observable_url) { "https://observe.gitlab.com/" } + let_it_be(:observable_url) { "https://observe.gitlab.com/#{group.id}/some-dashboard" } let_it_be(:expected) do %(<iframe src="#{observable_url}?theme=light&kiosk" frameborder="0") end before do - project.add_maintainer(user) + group.add_developer(user) sign_in(user) end - context 'when embedding in an issue' do - let(:issue) do - create(:issue, project: project, description: observable_url) - end - - before do - visit project_issue_path(project, issue) - wait_for_requests - end - - it 'renders iframe in description' do - page.within('.description') do - expect(page.html).to include(expected) - end - end - - it 'renders iframe in comment' do - expect(page).not_to have_css('.note-text') - - page.within('.js-main-target-form') do - fill_in('note[note]', with: observable_url) - click_button('Comment') + context 'when user is a developer of the embedded group' do + context 'when embedding in an issue' do + let(:issue) do + create(:issue, project: project, description: observable_url) end - wait_for_requests - - page.within('.note-text') do - expect(page.html).to include(expected) + before do + visit project_issue_path(project, issue) + wait_for_requests end - end - end - context 'when embedding in an MR' do - let(:merge_request) do - create(:merge_request, source_project: project, target_project: project, description: observable_url) - end - - before do - visit merge_request_path(merge_request) - wait_for_requests + it_behaves_like 'embeds observability' end - it 'renders iframe in description' do - page.within('.description') do - expect(page.html).to include(expected) + context 'when embedding in an MR' do + let(:merge_request) do + create(:merge_request, source_project: project, target_project: project, description: observable_url) end - end - it 'renders iframe in comment' do - expect(page).not_to have_css('.note-text') - - page.within('.js-main-target-form') do - fill_in('note[note]', with: observable_url) - click_button('Comment') + before do + visit merge_request_path(merge_request) + wait_for_requests end - wait_for_requests - - page.within('.note-text') do - expect(page.html).to include(expected) - end + it_behaves_like 'embeds observability' end end - context 'when feature flag is disabled' do - before do - stub_feature_flags(observability_group_tab: false) - end - + shared_examples 'does not embed observability in issues and MRs' do context 'when embedding in an issue' do let(:issue) do create(:issue, project: project, description: observable_url) @@ -96,28 +56,7 @@ RSpec.describe 'Observability rendering', :js do wait_for_requests end - it 'does not render iframe in description' do - page.within('.description') do - expect(page.html).not_to include(expected) - expect(page.html).to include(observable_url) - end - end - - it 'does not render iframe in comment' do - expect(page).not_to have_css('.note-text') - - page.within('.js-main-target-form') do - fill_in('note[note]', with: observable_url) - click_button('Comment') - end - - wait_for_requests - - page.within('.note-text') do - expect(page.html).not_to include(expected) - expect(page.html).to include(observable_url) - end - end + it_behaves_like 'does not embed observability' end context 'when embedding in an MR' do @@ -130,28 +69,21 @@ RSpec.describe 'Observability rendering', :js do wait_for_requests end - it 'does not render iframe in description' do - page.within('.description') do - expect(page.html).not_to include(expected) - expect(page.html).to include(observable_url) - end - end - - it 'does not render iframe in comment' do - expect(page).not_to have_css('.note-text') - - page.within('.js-main-target-form') do - fill_in('note[note]', with: observable_url) - click_button('Comment') - end + it_behaves_like 'does not embed observability' + end + end - wait_for_requests + context 'when user is not a developer of the embeded group' do + it_behaves_like 'does not embed observability in issues and MRs' do + let_it_be(:observable_url) { "https://observe.gitlab.com/1234/some-dashboard" } + end + end - page.within('.note-text') do - expect(page.html).not_to include(expected) - expect(page.html).to include(observable_url) - end - end + context 'when feature flag is disabled' do + before do + stub_feature_flags(observability_group_tab: false) end + + it_behaves_like 'does not embed observability in issues and MRs' end end |