Commit 86e9de9a authored by Dan Davison's avatar Dan Davison

Merge branch 'egb-audit-epic-3169' into 'master'

Initial refactor in test audit

See merge request gitlab-org/gitlab!31816
parents 1f2e28ac da361162
...@@ -5,11 +5,8 @@ require 'airborne' ...@@ -5,11 +5,8 @@ require 'airborne'
module QA module QA
RSpec.describe 'Manage' do RSpec.describe 'Manage' do
describe 'Users API' do describe 'Users API' do
before(:context) do let(:api_client) { Runtime::API::Client.new(:gitlab) }
@api_client = Runtime::API::Client.new(:gitlab) let(:request) { Runtime::API::Request.new(api_client, '/users') }
end
let(:request) { Runtime::API::Request.new(@api_client, '/users') }
it 'GET /users' do it 'GET /users' do
get request.url get request.url
......
...@@ -8,30 +8,33 @@ module QA ...@@ -8,30 +8,33 @@ module QA
RSpec.describe 'Create' do RSpec.describe 'Create' do
describe 'Compare archives of different user projects with the same name and check they\'re different' do describe 'Compare archives of different user projects with the same name and check they\'re different' do
include Support::Api include Support::Api
let(:project_name) { "project-archive-download-#{SecureRandom.hex(8)}" }
before do let(:archive_types) { %w(tar.gz tar.bz2 tar zip) }
@project_name = "project-archive-download-#{SecureRandom.hex(8)}"
@archive_types = %w(tar.gz tar.bz2 tar zip) let(:users) do
@users = { {
user1: { username: Runtime::Env.gitlab_qa_username_1, password: Runtime::Env.gitlab_qa_password_1 }, user1: { username: Runtime::Env.gitlab_qa_username_1, password: Runtime::Env.gitlab_qa_password_1 },
user2: { username: Runtime::Env.gitlab_qa_username_2, password: Runtime::Env.gitlab_qa_password_2 } user2: { username: Runtime::Env.gitlab_qa_username_2, password: Runtime::Env.gitlab_qa_password_2 }
} }
end
@users.each do |_, user_info| before do
users.each do |_, user_info|
user_info[:user] = Resource::User.fabricate_or_use(user_info[:username], user_info[:password]) user_info[:user] = Resource::User.fabricate_or_use(user_info[:username], user_info[:password])
user_info[:api_client] = Runtime::API::Client.new(:gitlab, user: user_info[:user]) user_info[:api_client] = Runtime::API::Client.new(:gitlab, user: user_info[:user])
user_info[:api_client].personal_access_token user_info[:api_client].personal_access_token
user_info[:project] = create_project(user_info[:user], user_info[:api_client], @project_name) user_info[:project] = create_project(user_info[:user], user_info[:api_client], project_name)
end end
end end
it 'download archives of each user project then check they are different' do it 'download archives of each user project then check they are different' do
archive_checksums = {} archive_checksums = {}
@users.each do |user_key, user_info| users.each do |user_key, user_info|
archive_checksums[user_key] = {} archive_checksums[user_key] = {}
@archive_types.each do |type| archive_types.each do |type|
archive_path = download_project_archive_via_api(user_info[:api_client], user_info[:project], type).path archive_path = download_project_archive_via_api(user_info[:api_client], user_info[:project], type).path
archive_checksums[user_key][type] = Digest::MD5.hexdigest(File.read(archive_path)) archive_checksums[user_key][type] = Digest::MD5.hexdigest(File.read(archive_path))
end end
......
...@@ -3,22 +3,30 @@ ...@@ -3,22 +3,30 @@
module QA module QA
RSpec.describe 'Manage' do RSpec.describe 'Manage' do
describe 'Project transfer between groups' do describe 'Project transfer between groups' do
it 'user transfers a project between groups' do let(:source_group) do
Flow::Login.sign_in Resource::Group.fabricate_via_api! do |group|
source_group = Resource::Group.fabricate_via_api! do |group|
group.path = 'source-group' group.path = 'source-group'
end end
end
target_group = Resource::Group.fabricate_via_api! do |group| let(:target_group) do
Resource::Group.fabricate_via_api! do |group|
group.path = 'target-group' group.path = 'target-group'
end end
end
project = Resource::Project.fabricate_via_api! do |project| let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.group = source_group project.group = source_group
project.name = 'transfer-project' project.name = 'transfer-project'
project.initialize_with_readme = true project.initialize_with_readme = true
end end
end
let(:edited_readme_content) { 'Here is the edited content.' }
before do
Flow::Login.sign_in
project.visit! project.visit!
...@@ -28,14 +36,14 @@ module QA ...@@ -28,14 +36,14 @@ module QA
Page::File::Show.perform(&:click_edit) Page::File::Show.perform(&:click_edit)
edited_readme_content = 'Here is the edited content.'
Page::File::Edit.perform do |file| Page::File::Edit.perform do |file|
file.remove_content file.remove_content
file.add_content(edited_readme_content) file.add_content(edited_readme_content)
file.commit_changes file.commit_changes
end end
end
it 'user transfers a project between groups' do
Page::File::Show.perform(&:go_to_general_settings) Page::File::Show.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform(&:expand_advanced_settings) Page::Project::Settings::Main.perform(&:expand_advanced_settings)
......
...@@ -3,27 +3,29 @@ ...@@ -3,27 +3,29 @@
module QA module QA
RSpec.describe 'Create' do RSpec.describe 'Create' do
describe 'Create a new merge request' do describe 'Create a new merge request' do
before do let(:project) do
Flow::Login.sign_in Resource::Project.fabricate_via_api! do |project|
@project = Resource::Project.fabricate_via_api! do |project|
project.name = 'project' project.name = 'project'
end end
end
@merge_request_title = 'One merge request to rule them all' let(:merge_request_title) { 'One merge request to rule them all' }
@merge_request_description = '... to find them, to bring them all, and in the darkness bind them' let(:merge_request_description) { '... to find them, to bring them all, and in the darkness bind them' }
before do
Flow::Login.sign_in
end end
it 'creates a basic merge request' do it 'creates a basic merge request' do
Resource::MergeRequest.fabricate_via_browser_ui! do |merge_request| Resource::MergeRequest.fabricate_via_browser_ui! do |merge_request|
merge_request.project = @project merge_request.project = project
merge_request.title = @merge_request_title merge_request.title = merge_request_title
merge_request.description = @merge_request_description merge_request.description = merge_request_description
end end
Page::MergeRequest::Show.perform do |merge_request| Page::MergeRequest::Show.perform do |merge_request|
expect(merge_request).to have_title(@merge_request_title) expect(merge_request).to have_title(merge_request_title)
expect(merge_request).to have_description(@merge_request_description) expect(merge_request).to have_description(merge_request_description)
end end
end end
...@@ -31,26 +33,26 @@ module QA ...@@ -31,26 +33,26 @@ module QA
gitlab_account_username = "@#{Runtime::User.username}" gitlab_account_username = "@#{Runtime::User.username}"
milestone = Resource::ProjectMilestone.fabricate_via_api! do |milestone| milestone = Resource::ProjectMilestone.fabricate_via_api! do |milestone|
milestone.project = @project milestone.project = project
end end
label = Resource::Label.fabricate_via_api! do |label| label = Resource::Label.fabricate_via_api! do |label|
label.project = @project label.project = project
label.title = 'label' label.title = 'label'
end end
Resource::MergeRequest.fabricate_via_browser_ui! do |merge_request| Resource::MergeRequest.fabricate_via_browser_ui! do |merge_request|
merge_request.title = @merge_request_title merge_request.title = merge_request_title
merge_request.description = @merge_request_description merge_request.description = merge_request_description
merge_request.project = @project merge_request.project = project
merge_request.milestone = milestone merge_request.milestone = milestone
merge_request.assignee = 'me' merge_request.assignee = 'me'
merge_request.labels.push(label) merge_request.labels.push(label)
end end
Page::MergeRequest::Show.perform do |merge_request| Page::MergeRequest::Show.perform do |merge_request|
expect(merge_request).to have_title(@merge_request_title) expect(merge_request).to have_title(merge_request_title)
expect(merge_request).to have_description(@merge_request_description) expect(merge_request).to have_description(merge_request_description)
expect(merge_request).to have_assignee(gitlab_account_username) expect(merge_request).to have_assignee(gitlab_account_username)
expect(merge_request).to have_label(label.title) expect(merge_request).to have_label(label.title)
expect(merge_request).to have_milestone(milestone.title) expect(merge_request).to have_milestone(milestone.title)
......
...@@ -3,17 +3,14 @@ ...@@ -3,17 +3,14 @@
module QA module QA
RSpec.describe 'Create' do RSpec.describe 'Create' do
describe 'Merge request creation from fork' do describe 'Merge request creation from fork' do
it 'user forks a project, submits a merge request and maintainer merges it' do let(:merge_request) do
Flow::Login.sign_in Resource::MergeRequestFromFork.fabricate_via_api! do |merge_request|
merge_request = Resource::MergeRequestFromFork.fabricate_via_browser_ui! do |merge_request|
merge_request.fork_branch = 'feature-branch' merge_request.fork_branch = 'feature-branch'
end end
end
merge_request.project.api_put(auto_devops_enabled: false) it 'can merge feature branch fork to mainline' do
Flow::Login.sign_in
Page::Main::Menu.perform(&:sign_out)
Page::Main::Login.perform(&:sign_in_using_credentials)
merge_request.visit! merge_request.visit!
......
...@@ -3,17 +3,21 @@ ...@@ -3,17 +3,21 @@
module QA module QA
RSpec.describe 'Create' do RSpec.describe 'Create' do
describe 'Merge request squashing' do describe 'Merge request squashing' do
it 'user squashes commits while merging' do let(:project) do
Flow::Login.sign_in Resource::Project.fabricate_via_api! do |project|
project = Resource::Project.fabricate_via_api! do |project|
project.name = "squash-before-merge" project.name = "squash-before-merge"
end end
end
merge_request = Resource::MergeRequest.fabricate! do |merge_request| let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project merge_request.project = project
merge_request.title = 'Squashing commits' merge_request.title = 'Squashing commits'
end end
end
before do
Flow::Login.sign_in
Resource::Repository::ProjectPush.fabricate! do |push| Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project push.project = project
...@@ -25,7 +29,9 @@ module QA ...@@ -25,7 +29,9 @@ module QA
end end
merge_request.visit! merge_request.visit!
end
it 'user squashes commits while merging' do
Page::MergeRequest::Show.perform do |merge_request_page| Page::MergeRequest::Show.perform do |merge_request_page|
merge_request_page.retry_on_exception(reload: true) do merge_request_page.retry_on_exception(reload: true) do
expect(merge_request_page).to have_text('to be squashed') expect(merge_request_page).to have_text('to be squashed')
......
...@@ -5,8 +5,8 @@ module QA ...@@ -5,8 +5,8 @@ module QA
describe 'File templates' do describe 'File templates' do
include Runtime::Fixtures include Runtime::Fixtures
before(:all) do let(:project) do
@project = Resource::Project.fabricate_via_api! do |project| Resource::Project.fabricate_via_api! do |project|
project.name = 'file-template-project' project.name = 'file-template-project'
project.description = 'Add file templates via the Files view' project.description = 'Add file templates via the Files view'
project.initialize_with_readme = true project.initialize_with_readme = true
...@@ -46,7 +46,7 @@ module QA ...@@ -46,7 +46,7 @@ module QA
Flow::Login.sign_in Flow::Login.sign_in
@project.visit! project.visit!
Page::Project::Show.perform(&:create_new_file!) Page::Project::Show.perform(&:create_new_file!)
Page::File::Form.perform do |form| Page::File::Form.perform do |form|
......
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