Commit e57cec33 authored by Walmyr's avatar Walmyr

Merge branch 'qa-reduce-ce-ee-diff-in-qa-folder' into 'master'

Reduce the CE/EE diff under `qa/`

See merge request gitlab-org/gitlab-ce!31799
parents ebb13148 d8f98900
...@@ -52,13 +52,11 @@ module QA ...@@ -52,13 +52,11 @@ module QA
raise NotImplementedError if Runtime::User.ldap_user? && user&.credentials_given? raise NotImplementedError if Runtime::User.ldap_user? && user&.credentials_given?
if Runtime::User.ldap_user? if Runtime::User.ldap_user?
sign_in_using_ldap_credentials sign_in_using_ldap_credentials(user || Runtime::User)
else else
sign_in_using_gitlab_credentials(user || Runtime::User) sign_in_using_gitlab_credentials(user || Runtime::User)
end end
end end
Page::Main::Menu.perform(&:has_personal_area?)
end end
def sign_in_using_admin_credentials def sign_in_using_admin_credentials
...@@ -76,6 +74,25 @@ module QA ...@@ -76,6 +74,25 @@ module QA
Page::Main::Menu.perform(&:has_personal_area?) Page::Main::Menu.perform(&:has_personal_area?)
end end
def sign_in_using_ldap_credentials(user)
# Log out if already logged in
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
using_wait_time 0 do
set_initial_password_if_present
switch_to_ldap_tab
fill_element :username_field, user.ldap_username
fill_element :password_field, user.ldap_password
click_element :sign_in_button
end
Page::Main::Menu.perform(&:has_personal_area?)
end
def self.path def self.path
'/users/sign_in' '/users/sign_in'
end end
...@@ -133,14 +150,6 @@ module QA ...@@ -133,14 +150,6 @@ module QA
private private
def sign_in_using_ldap_credentials
switch_to_ldap_tab
fill_element :username_field, Runtime::User.ldap_username
fill_element :password_field, Runtime::User.ldap_password
click_element :sign_in_button
end
def sign_in_using_gitlab_credentials(user) def sign_in_using_gitlab_credentials(user)
switch_to_sign_in_tab if has_sign_in_tab? switch_to_sign_in_tab if has_sign_in_tab?
switch_to_standard_tab if has_standard_tab? switch_to_standard_tab if has_standard_tab?
......
...@@ -6,7 +6,7 @@ module QA ...@@ -6,7 +6,7 @@ module QA
module Issue module Issue
class New < Page::Base class New < Page::Base
view 'app/views/shared/issuable/_form.html.haml' do view 'app/views/shared/issuable/_form.html.haml' do
element :submit_issue_button, 'form.submit "Submit' # rubocop:disable QA/ElementWithPattern element :issuable_create_button
end end
view 'app/views/shared/issuable/form/_title.html.haml' do view 'app/views/shared/issuable/form/_title.html.haml' do
...@@ -26,7 +26,7 @@ module QA ...@@ -26,7 +26,7 @@ module QA
end end
def create_new_issue def create_new_issue
click_on 'Submit issue' click_element :issuable_create_button, Page::Project::Issue::Show
end end
end end
end end
......
...@@ -14,7 +14,7 @@ module QA ...@@ -14,7 +14,7 @@ module QA
end end
view 'app/assets/javascripts/notes/components/discussion_filter.vue' do view 'app/assets/javascripts/notes/components/discussion_filter.vue' do
element :discussion_filter element :discussion_filter, required: true
element :filter_options element :filter_options
end end
......
...@@ -5,7 +5,7 @@ module QA ...@@ -5,7 +5,7 @@ module QA
module Project module Project
class Menu < Page::Base class Menu < Page::Base
include SubMenus::Common include SubMenus::Common
include SubMenus::Project
include SubMenus::CiCd include SubMenus::CiCd
include SubMenus::Issues include SubMenus::Issues
include SubMenus::Operations include SubMenus::Operations
......
...@@ -5,7 +5,8 @@ require 'securerandom' ...@@ -5,7 +5,8 @@ require 'securerandom'
module QA module QA
module Resource module Resource
class MergeRequest < Base class MergeRequest < Base
attr_accessor :title, attr_accessor :id,
:title,
:description, :description,
:source_branch, :source_branch,
:target_branch, :target_branch,
...@@ -74,6 +75,28 @@ module QA ...@@ -74,6 +75,28 @@ module QA
page.create_merge_request page.create_merge_request
end end
end end
def fabricate_via_api!
populate(:target, :source)
super
end
def api_get_path
"/projects/#{project.id}/merge_requests/#{id}"
end
def api_post_path
"/projects/#{project.id}/merge_requests"
end
def api_post_body
{
description: @description,
source_branch: @source_branch,
target_branch: @target_branch,
title: @title
}
end
end end
end end
end end
...@@ -7,11 +7,13 @@ module QA ...@@ -7,11 +7,13 @@ module QA
class Selectors < Scenario::Template class Selectors < Scenario::Template
include Scenario::Bootable include Scenario::Bootable
PAGES = [QA::Page].freeze def pages
@pages ||= [QA::Page]
end
def perform(*) def perform(*)
validators = PAGES.map do |pages| validators = pages.map do |page|
Page::Validator.new(pages) Page::Validator.new(page)
end end
validators.flat_map(&:errors).tap do |errors| validators.flat_map(&:errors).tap do |errors|
......
...@@ -11,11 +11,12 @@ module QA ...@@ -11,11 +11,12 @@ module QA
end end
def gitlab_ctl(command, input: nil) def gitlab_ctl(command, input: nil)
if input.nil? docker_exec("gitlab-ctl #{command}", input: input)
shell "docker exec #{@name} gitlab-ctl #{command}" end
else
shell "docker exec #{@name} bash -c '#{input} | gitlab-ctl #{command}'" def docker_exec(command, input: nil)
end command = "#{input} | #{command}" if input
shell "docker exec #{@name} bash -c '#{command}'"
end end
end end
end end
......
...@@ -7,13 +7,18 @@ module QA ...@@ -7,13 +7,18 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials) Page::Main::Login.perform(&:sign_in_using_credentials)
@merge_request = Resource::MergeRequest.fabricate! do |merge_request| project = Resource::Project.fabricate_via_api! do |project|
project.name = 'project'
end
@merge_request = Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project
merge_request.title = 'This is a merge request' merge_request.title = 'This is a merge request'
merge_request.description = 'For downloading patches and diffs' merge_request.description = '... for downloading patches and diffs'
end end
end end
it 'user views merge request email patches' do it 'views the merge request email patches' do
@merge_request.visit! @merge_request.visit!
Page::MergeRequest::Show.perform(&:view_email_patches) Page::MergeRequest::Show.perform(&:view_email_patches)
...@@ -22,7 +27,7 @@ module QA ...@@ -22,7 +27,7 @@ module QA
expect(page).to have_content('diff --git a/added_file.txt b/added_file.txt') expect(page).to have_content('diff --git a/added_file.txt b/added_file.txt')
end end
it 'user views merge request plain diff' do it 'views the merge request plain diff' do
@merge_request.visit! @merge_request.visit!
Page::MergeRequest::Show.perform(&:view_plain_diff) Page::MergeRequest::Show.perform(&:view_plain_diff)
......
...@@ -3,36 +3,29 @@ ...@@ -3,36 +3,29 @@
require 'digest/sha1' require 'digest/sha1'
module QA module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/70 context 'Release', :docker do
context 'Release', :docker, :quarantine do
describe 'Git clone using a deploy key' do describe 'Git clone using a deploy key' do
def login before do
Runtime::Browser.visit(:gitlab, Page::Main::Login) Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials) Page::Main::Login.perform(&:sign_in_using_credentials)
end
before(:all) do
login
@runner_name = "qa-runner-#{Time.now.to_i}" @runner_name = "qa-runner-#{Time.now.to_i}"
@project = Resource::Project.fabricate! do |resource| @project = Resource::Project.fabricate_via_api! do |resource|
resource.name = 'deploy-key-clone-project' resource.name = 'deploy-key-clone-project'
end end
@repository_location = @project.repository_ssh_location @repository_location = @project.repository_ssh_location
Resource::Runner.fabricate! do |resource| Resource::Runner.fabricate_via_browser_ui! do |resource|
resource.project = @project resource.project = @project
resource.name = @runner_name resource.name = @runner_name
resource.tags = %w[qa docker] resource.tags = %w[qa docker]
resource.image = 'gitlab/gitlab-runner:ubuntu' resource.image = 'gitlab/gitlab-runner:ubuntu'
end end
Page::Main::Menu.perform(&:sign_out)
end end
after(:all) do after do
Service::Runner.new(@runner_name).remove! Service::Runner.new(@runner_name).remove!
end end
...@@ -46,9 +39,7 @@ module QA ...@@ -46,9 +39,7 @@ module QA
it "user sets up a deploy key with #{key_class}(#{bits}) to clone code using pipelines" do it "user sets up a deploy key with #{key_class}(#{bits}) to clone code using pipelines" do
key = key_class.new(*bits) key = key_class.new(*bits)
login Resource::DeployKey.fabricate_via_browser_ui! do |resource|
Resource::DeployKey.fabricate! do |resource|
resource.project = @project resource.project = @project
resource.title = "deploy key #{key.name}(#{key.bits})" resource.title = "deploy key #{key.name}(#{key.bits})"
resource.key = key.public_key resource.key = key.public_key
...@@ -56,7 +47,7 @@ module QA ...@@ -56,7 +47,7 @@ module QA
deploy_key_name = "DEPLOY_KEY_#{key.name}_#{key.bits}" deploy_key_name = "DEPLOY_KEY_#{key.name}_#{key.bits}"
Resource::CiVariable.fabricate! do |resource| Resource::CiVariable.fabricate_via_browser_ui! do |resource|
resource.project = @project resource.project = @project
resource.key = deploy_key_name resource.key = deploy_key_name
resource.value = key.private_key resource.value = key.private_key
......
...@@ -12,6 +12,14 @@ module QA ...@@ -12,6 +12,14 @@ module QA
fill_in 'password', with: 'user1pass' fill_in 'password', with: 'user1pass'
click_on 'Login' click_on 'Login'
end end
def login_if_required
login if login_required?
end
def login_required?
page.has_text?('Enter your username and password')
end
end end
end end
end end
......
...@@ -19,7 +19,11 @@ describe QA::Resource::Repository::Push do ...@@ -19,7 +19,11 @@ describe QA::Resource::Repository::Push do
expect { subject.files = [] }.to raise_error(ArgumentError) expect { subject.files = [] }.to raise_error(ArgumentError)
end end
it 'does not raise if files is an array' do it 'raises an error if files is not an array of hashes with :name and :content keys' do
expect { subject.files = [{ foo: 'foo' }] }.to raise_error(ArgumentError)
end
it 'does not raise if files is an array of hashes with :name and :content keys' do
expect { subject.files = files }.not_to raise_error expect { subject.files = files }.not_to raise_error
end end
end end
......
...@@ -192,6 +192,30 @@ describe QA::Runtime::Env do ...@@ -192,6 +192,30 @@ describe QA::Runtime::Env do
end end
end end
describe '.knapsack?' do
it 'returns true if KNAPSACK_GENERATE_REPORT is defined' do
stub_env('KNAPSACK_GENERATE_REPORT', 'true')
expect(described_class.knapsack?).to be_truthy
end
it 'returns true if KNAPSACK_REPORT_PATH is defined' do
stub_env('KNAPSACK_REPORT_PATH', '/a/path')
expect(described_class.knapsack?).to be_truthy
end
it 'returns true if KNAPSACK_TEST_FILE_PATTERN is defined' do
stub_env('KNAPSACK_TEST_FILE_PATTERN', '/a/**/pattern')
expect(described_class.knapsack?).to be_truthy
end
it 'returns false if neither KNAPSACK_GENERATE_REPORT nor KNAPSACK_REPORT_PATH nor KNAPSACK_TEST_FILE_PATTERN are defined' do
expect(described_class.knapsack?).to be_falsey
end
end
describe '.require_github_access_token!' do describe '.require_github_access_token!' do
it 'raises ArgumentError if GITHUB_ACCESS_TOKEN is not defined' do it 'raises ArgumentError if GITHUB_ACCESS_TOKEN is not defined' do
stub_env('GITHUB_ACCESS_TOKEN', nil) stub_env('GITHUB_ACCESS_TOKEN', nil)
......
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