Commit c648a838 authored by Dan Davison's avatar Dan Davison

Merge branch 'qa-remove-snippets-after-test-execution' into 'master'

Add deleting of snippets via API

See merge request gitlab-org/gitlab!54406
parents 6af8d67c 4f0e1a03
...@@ -33,12 +33,16 @@ module QA ...@@ -33,12 +33,16 @@ module QA
end end
def api_get_path def api_get_path
"/projects/#{project.id}/snippets/#{snippet_id}" "/projects/#{project.id}/snippets/#{id}"
end end
def api_post_path def api_post_path
"/projects/#{project.id}/snippets" "/projects/#{project.id}/snippets"
end end
def api_delete_path
"/projects/#{project.id}/snippets/#{id}"
end
end end
end end
end end
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
module QA module QA
module Resource module Resource
class Snippet < Base class Snippet < Base
attr_accessor :title, :description, :file_content, :visibility, :file_name, :snippet_id attr_accessor :title, :description, :file_content, :visibility, :file_name
attribute :id
def initialize def initialize
@title = 'New snippet title' @title = 'New snippet title'
...@@ -44,7 +46,7 @@ module QA ...@@ -44,7 +46,7 @@ module QA
end end
def api_get_path def api_get_path
"/snippets/#{snippet_id}" "/snippets/#{id}"
end end
def api_post_path def api_post_path
...@@ -60,6 +62,10 @@ module QA ...@@ -60,6 +62,10 @@ module QA
} }
end end
def api_delete_path
"/snippets/#{id}"
end
def all_file_contents def all_file_contents
@files.insert(0, { name: @file_name, content: @file_content }) @files.insert(0, { name: @file_name, content: @file_content })
@files.each do |file| @files.each do |file|
......
...@@ -23,6 +23,11 @@ module QA ...@@ -23,6 +23,11 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
end end
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'comments on snippets' do |snippet_type| shared_examples 'comments on snippets' do |snippet_type|
it "adds, edits, and deletes a comment on a #{snippet_type}" do it "adds, edits, and deletes a comment on a #{snippet_type}" do
send(snippet_type) send(snippet_type)
......
...@@ -23,6 +23,11 @@ module QA ...@@ -23,6 +23,11 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
end end
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'adding file to snippet' do |snippet_type| shared_examples 'adding file to snippet' do |snippet_type|
it "adds second file to an existing #{snippet_type} to make it multi-file" do it "adds second file to an existing #{snippet_type} to make it multi-file" do
send(snippet_type).visit! send(snippet_type).visit!
......
...@@ -66,6 +66,8 @@ module QA ...@@ -66,6 +66,8 @@ module QA
expect(repository.commits.first).to include('Update snippet') expect(repository.commits.first).to include('Update snippet')
expect(repository.file_content(new_file)).to include("#{added_content}#{changed_content}") expect(repository.file_content(new_file)).to include("#{added_content}#{changed_content}")
end end
snippet.remove_via_api!
end end
it 'clones, pushes, and pulls a snippet over SSH, deletes via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/825' do it 'clones, pushes, and pulls a snippet over SSH, deletes via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/825' do
......
...@@ -67,6 +67,8 @@ module QA ...@@ -67,6 +67,8 @@ module QA
expect(repository.commits.first).to include 'Update snippet' expect(repository.commits.first).to include 'Update snippet'
expect(repository.file_content(new_file)).to include "#{added_content}#{changed_content}" expect(repository.file_content(new_file)).to include "#{added_content}#{changed_content}"
end end
snippet.remove_via_api!
end end
it 'clones, pushes, and pulls a project snippet over SSH, deletes via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/832' do it 'clones, pushes, and pulls a project snippet over SSH, deletes via UI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/832' do
......
...@@ -54,6 +54,11 @@ module QA ...@@ -54,6 +54,11 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
end end
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'copying snippet file contents' do |snippet_type| shared_examples 'copying snippet file contents' do |snippet_type|
it "copies file contents of a multi-file #{snippet_type} to a comment and verifies them" do it "copies file contents of a multi-file #{snippet_type} to a comment and verifies them" do
send(snippet_type).visit! send(snippet_type).visit!
......
...@@ -31,6 +31,11 @@ module QA ...@@ -31,6 +31,11 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
end end
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'deleting file from snippet' do |snippet_type| shared_examples 'deleting file from snippet' do |snippet_type|
it "deletes second file from an existing #{snippet_type} to make it single-file" do it "deletes second file from an existing #{snippet_type} to make it single-file" do
send(snippet_type).visit! send(snippet_type).visit!
......
...@@ -16,6 +16,10 @@ module QA ...@@ -16,6 +16,10 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
end end
after do
snippet&.remove_via_api!
end
context 'when the snippet is public' do 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 it 'can be shared with not signed-in users', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1016' do
snippet.visit! snippet.visit!
......
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