Commit e6c814b4 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'egb-refactor-repository-file' into 'master'

Break repository file tests into three tests

See merge request gitlab-org/gitlab!37849
parents 6455974a 7bcbd59f
......@@ -5,10 +5,10 @@ module QA
class File < Base
attr_accessor :author_email,
:author_name,
:branch,
:content,
:commit_message,
:name
attr_writer :branch
attribute :project do
Project.fabricate! do |resource|
......@@ -29,6 +29,10 @@ module QA
@commit_message = 'QA Test - Commit message'
end
def branch
@branch ||= "master"
end
def fabricate!
project.visit!
......@@ -42,12 +46,6 @@ module QA
end
end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
# this particular resource does not expose a web_url property
end
def api_get_path
"/projects/#{CGI.escape(project.path_with_namespace)}/repository/files/#{CGI.escape(@name)}"
end
......@@ -58,13 +56,20 @@ module QA
def api_post_body
{
branch: @branch || "master",
branch: branch,
author_email: @author_email || Runtime::User.default_email,
author_name: @author_name || Runtime::User.username,
content: content,
commit_message: commit_message
}
end
private
def transform_api_resource(api_resource)
api_resource[:web_url] = "#{Runtime::Scenario.gitlab_address}/#{project.full_path}/-/tree/#{branch}/#{api_resource[:file_path]}"
api_resource
end
end
end
end
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
context 'File management' do
file_name = 'QA Test - File name'
file_content = 'QA Test - File content'
commit_message_for_create = 'QA Test - Create new file'
before do
Flow::Login.sign_in
end
it 'user creates a file via the Web', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1093' do
Resource::File.fabricate_via_browser_ui! do |file|
file.name = file_name
file.content = file_content
file.commit_message = commit_message_for_create
end
Page::File::Show.perform do |file|
aggregate_failures 'file details' do
expect(file).to have_file(file_name)
expect(file).to have_file_content(file_content)
expect(file).to have_commit_message(commit_message_for_create)
end
end
end
end
end
end
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
context 'File management' do
let(:file) { Resource::File.fabricate_via_api! }
commit_message_for_delete = 'QA Test - Delete file'
before do
Flow::Login.sign_in
file.visit!
end
it 'user deletes a file via the Web', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1095' do
Page::File::Show.perform do |file|
file.click_delete
file.add_commit_message(commit_message_for_delete)
file.click_delete_file
end
Page::Project::Show.perform do |project|
aggregate_failures 'file details' do
expect(project).to have_notice('The file has been successfully deleted.')
expect(project).to have_commit_message(commit_message_for_delete)
expect(project).not_to have_file(file.name)
end
end
end
end
end
end
......@@ -2,33 +2,18 @@
module QA
RSpec.describe 'Create' do
describe 'Files management' do
it 'user creates, edits and deletes a file via the Web', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/451' do
Flow::Login.sign_in
# Create
file_name = 'QA Test - File name'
file_content = 'QA Test - File content'
commit_message_for_create = 'QA Test - Create new file'
Resource::File.fabricate_via_browser_ui! do |file|
file.name = file_name
file.content = file_content
file.commit_message = commit_message_for_create
end
Page::File::Show.perform do |file|
aggregate_failures 'file details' do
expect(file).to have_file(file_name)
expect(file).to have_file_content(file_content)
expect(file).to have_commit_message(commit_message_for_create)
end
end
context 'File management' do
let(:file) { Resource::File.fabricate_via_api! }
# Edit
updated_file_content = 'QA Test - Updated file content'
commit_message_for_update = 'QA Test - Update file'
before do
Flow::Login.sign_in
file.visit!
end
it 'user edits a file via the Web', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1094' do
Page::File::Show.perform(&:click_edit)
Page::File::Form.perform do |file|
......@@ -45,23 +30,6 @@ module QA
expect(file).to have_commit_message(commit_message_for_update)
end
end
# Delete
commit_message_for_delete = 'QA Test - Delete file'
Page::File::Show.perform do |file|
file.click_delete
file.add_commit_message(commit_message_for_delete)
file.click_delete_file
end
Page::Project::Show.perform do |project|
aggregate_failures 'file details' do
expect(project).to have_notice('The file has been successfully deleted.')
expect(project).to have_commit_message(commit_message_for_delete)
expect(project).not_to have_file(file_name)
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