Commit d8c989e6 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'qa-e2e-share-snippet-spec' into 'master'

E2E for sharing a snippet

Closes gitlab-org/quality/testcases#985

See merge request gitlab-org/gitlab!40688
parents 4f3af541 13beeccc
......@@ -67,6 +67,8 @@ export default {
:title="$options.MSG_COPY"
:data-clipboard-text="value"
icon="copy-to-clipboard"
data-qa-selector="copy_button"
:data-qa-action="name"
/>
</template>
</gl-form-input-group>
......
......@@ -46,7 +46,11 @@ export default {
<snippet-header :snippet="snippet" />
<snippet-title :snippet="snippet" />
<div class="gl-display-flex gl-justify-content-end gl-mb-5">
<embed-dropdown v-if="embeddable" :url="snippet.webUrl" />
<embed-dropdown
v-if="embeddable"
:url="snippet.webUrl"
data-qa-selector="snippet_embed_dropdown"
/>
<clone-dropdown-button
v-if="canBeCloned"
class="gl-ml-3"
......
......@@ -40,6 +40,7 @@ module QA
base.view 'app/assets/javascripts/snippets/components/show.vue' do
element :clone_button
element :snippet_embed_dropdown
end
base.view 'app/assets/javascripts/vue_shared/components/clone_dropdown.vue' do
......@@ -73,6 +74,10 @@ module QA
element :more_actions_dropdown
element :delete_comment_button
end
base.view 'app/assets/javascripts/snippets/components/embed_dropdown.vue' do
element :copy_button
end
end
def has_snippet_title?(snippet_title)
......@@ -105,6 +110,10 @@ module QA
end
end
def has_embed_dropdown?
has_element?(:snippet_embed_dropdown)
end
def click_edit_button
click_element(:snippet_action_button, action: 'Edit')
end
......@@ -129,6 +138,11 @@ module QA
Git::Location.new(find_element(:copy_ssh_url_button)['data-clipboard-text']).uri.to_s
end
def get_sharing_link
click_element(:snippet_embed_dropdown)
find_element(:copy_button, action: 'Share')['data-clipboard-text']
end
def add_comment(comment)
fill_element(:note_field, comment)
click_element(:comment_button)
......
......@@ -19,6 +19,10 @@ module QA
text_area.has_text?(content) # wait for changes to take effect
end
def change_visibility_to(visibility_type)
choose(visibility_type)
end
def save_changes
click_element(:submit_button, Page::Dashboard::Snippet::Show)
end
......
# 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' 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' 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
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