diff options
| author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-17 03:08:51 +0000 |
|---|---|---|
| committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-17 03:08:51 +0000 |
| commit | bb6a3bf05eca11bede23c89a4b2a80a946707307 (patch) | |
| tree | 18086fbc00d3c13112c4e64dcfe0ef5462fd1fd3 /spec/support/shared_examples/observability | |
| parent | f52c68bbac191605f793686c472425b000a0879a (diff) | |
| download | gitlab-ce-bb6a3bf05eca11bede23c89a4b2a80a946707307.tar.gz | |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples/observability')
| -rw-r--r-- | spec/support/shared_examples/observability/embed_observabilities_examples.rb | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/spec/support/shared_examples/observability/embed_observabilities_examples.rb b/spec/support/shared_examples/observability/embed_observabilities_examples.rb index 27a8bd614e3..c8d4e9e0d7e 100644 --- a/spec/support/shared_examples/observability/embed_observabilities_examples.rb +++ b/spec/support/shared_examples/observability/embed_observabilities_examples.rb @@ -3,7 +3,7 @@ RSpec.shared_examples 'embeds observability' do it 'renders iframe in description' do page.within('.description') do - expect(page.html).to include(expected) + expect_observability_iframe(page.html) end end @@ -18,7 +18,7 @@ RSpec.shared_examples 'embeds observability' do wait_for_requests page.within('.note-text') do - expect(page.html).to include(expected) + expect_observability_iframe(page.html) end end end @@ -26,8 +26,7 @@ end RSpec.shared_examples 'does not embed observability' do 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) + expect_observability_iframe(page.html, to_be_nil: true) end end @@ -42,8 +41,21 @@ RSpec.shared_examples 'does not embed observability' do wait_for_requests page.within('.note-text') do - expect(page.html).not_to include(expected) - expect(page.html).to include(observable_url) + expect_observability_iframe(page.html, to_be_nil: true) end end end + +def expect_observability_iframe(html, to_be_nil: false) + iframe = Nokogiri::HTML.parse(html).at_css('#observability-ui-iframe') + + expect(html).to include(observable_url) + + if to_be_nil + expect(iframe).to be_nil + else + expect(iframe).not_to be_nil + iframe_src = "#{expected_observable_url}&theme=light&username=#{user.username}&kiosk=inline-embed" + expect(iframe.attributes['src'].value).to eq(iframe_src) + end +end |
