Commit 4f0e1a03 authored by Anastasia McDonald's avatar Anastasia McDonald Committed by Dan Davison

Introduce deleting of snippets via API

And update the tests to clean up resources

See https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/763
parent 9c8f090c
......@@ -33,12 +33,16 @@ module QA
end
def api_get_path
"/projects/#{project.id}/snippets/#{snippet_id}"
"/projects/#{project.id}/snippets/#{id}"
end
def api_post_path
"/projects/#{project.id}/snippets"
end
def api_delete_path
"/projects/#{project.id}/snippets/#{id}"
end
end
end
end
......@@ -3,7 +3,9 @@
module QA
module Resource
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
@title = 'New snippet title'
......@@ -44,7 +46,7 @@ module QA
end
def api_get_path
"/snippets/#{snippet_id}"
"/snippets/#{id}"
end
def api_post_path
......@@ -60,6 +62,10 @@ module QA
}
end
def api_delete_path
"/snippets/#{id}"
end
def all_file_contents
@files.insert(0, { name: @file_name, content: @file_content })
@files.each do |file|
......
......@@ -23,6 +23,11 @@ module QA
Flow::Login.sign_in
end
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'comments on snippets' do |snippet_type|
it "adds, edits, and deletes a comment on a #{snippet_type}" do
send(snippet_type)
......
......@@ -23,6 +23,11 @@ module QA
Flow::Login.sign_in
end
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'adding file to snippet' do |snippet_type|
it "adds second file to an existing #{snippet_type} to make it multi-file" do
send(snippet_type).visit!
......
......@@ -66,6 +66,8 @@ module QA
expect(repository.commits.first).to include('Update snippet')
expect(repository.file_content(new_file)).to include("#{added_content}#{changed_content}")
end
snippet.remove_via_api!
end
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
expect(repository.commits.first).to include 'Update snippet'
expect(repository.file_content(new_file)).to include "#{added_content}#{changed_content}"
end
snippet.remove_via_api!
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
......
......@@ -54,6 +54,11 @@ module QA
Flow::Login.sign_in
end
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
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
send(snippet_type).visit!
......
......@@ -31,6 +31,11 @@ module QA
Flow::Login.sign_in
end
after do
personal_snippet&.remove_via_api!
project_snippet&.remove_via_api!
end
shared_examples 'deleting file from snippet' do |snippet_type|
it "deletes second file from an existing #{snippet_type} to make it single-file" do
send(snippet_type).visit!
......
......@@ -16,6 +16,10 @@ module QA
Flow::Login.sign_in
end
after do
snippet&.remove_via_api!
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.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