diff options
Diffstat (limited to 'qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb')
-rw-r--r-- | qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb b/qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb new file mode 100644 index 00000000000..6b21d84cb13 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/3_create/snippet/share_snippet_spec.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Create' do + describe 'Sharing snippets' do + let(:snippet) do + Resource::Snippet.fabricate! do |snippet| + snippet.title = 'Shared snippet' + snippet.visibility = 'Public' + snippet.file_content = 'code.py' + snippet.file_content = 'code to be shared' + end + end + + before do + Flow::Login.sign_in + end + + context 'when the snippet is public' do + it 'can be shared with not signed-in users', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1016' do + snippet + + sharing_link = Page::Dashboard::Snippet::Show.perform do |snippet| + expect(snippet).to have_embed_dropdown + snippet.get_sharing_link + end + + Page::Main::Menu.perform(&:sign_out) + + page.visit(sharing_link) + + Page::Dashboard::Snippet::Show.perform do |snippet| + expect(snippet).to have_snippet_title('Shared snippet') + expect(snippet).to have_visibility_type(/public/i) + expect(snippet).to have_file_content('code to be shared') + expect(snippet).to have_embed_dropdown + end + end + end + + context 'when the snippet is changed to private' do + it 'does not display Embed/Share dropdown', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1015' do + snippet + + Page::Dashboard::Snippet::Show.perform do |snippet| + expect(snippet).to have_embed_dropdown + + snippet.click_edit_button + end + + Page::Dashboard::Snippet::Edit.perform do |snippet| + snippet.change_visibility_to('Private') + snippet.save_changes + end + + Page::Dashboard::Snippet::Show.perform do |snippet| + expect(snippet).not_to have_embed_dropdown + end + end + end + end + end +end |