summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalmyr <walmyr@gitlab.com>2019-08-14 13:24:43 +0000
committerWalmyr <walmyr@gitlab.com>2019-08-14 13:24:43 +0000
commite57cec33b55e3b886e45e7b2ddd98cd068ee879c (patch)
treebf154fa2c6f7cd02135fcb0e11d50138af34a11f
parentebb1314878c4456070547c16f418b03685c46c8b (diff)
parentd8f9890009365627591d27bb733a51eadcdcdbe6 (diff)
downloadgitlab-ce-e57cec33b55e3b886e45e7b2ddd98cd068ee879c.tar.gz
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
-rw-r--r--qa/qa/page/main/login.rb31
-rw-r--r--qa/qa/page/project/issue/new.rb4
-rw-r--r--qa/qa/page/project/issue/show.rb2
-rw-r--r--qa/qa/page/project/menu.rb2
-rw-r--r--qa/qa/resource/merge_request.rb25
-rw-r--r--qa/qa/scenario/test/sanity/selectors.rb8
-rw-r--r--qa/qa/service/omnibus.rb11
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb13
-rw-r--r--qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb23
-rw-r--r--qa/qa/vendor/saml_idp/page/login.rb8
-rw-r--r--qa/spec/resource/repository/push_spec.rb6
-rw-r--r--qa/spec/runtime/env_spec.rb24
12 files changed, 112 insertions, 45 deletions
diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb
index c2b0482d789..94245bbfcba 100644
--- a/qa/qa/page/main/login.rb
+++ b/qa/qa/page/main/login.rb
@@ -52,13 +52,11 @@ module QA
raise NotImplementedError if Runtime::User.ldap_user? && user&.credentials_given?
if Runtime::User.ldap_user?
- sign_in_using_ldap_credentials
+ sign_in_using_ldap_credentials(user || Runtime::User)
else
sign_in_using_gitlab_credentials(user || Runtime::User)
end
end
-
- Page::Main::Menu.perform(&:has_personal_area?)
end
def sign_in_using_admin_credentials
@@ -76,6 +74,25 @@ module QA
Page::Main::Menu.perform(&:has_personal_area?)
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
'/users/sign_in'
end
@@ -133,14 +150,6 @@ module QA
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)
switch_to_sign_in_tab if has_sign_in_tab?
switch_to_standard_tab if has_standard_tab?
diff --git a/qa/qa/page/project/issue/new.rb b/qa/qa/page/project/issue/new.rb
index 0d138417176..65c02801d67 100644
--- a/qa/qa/page/project/issue/new.rb
+++ b/qa/qa/page/project/issue/new.rb
@@ -6,7 +6,7 @@ module QA
module Issue
class New < Page::Base
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
view 'app/views/shared/issuable/form/_title.html.haml' do
@@ -26,7 +26,7 @@ module QA
end
def create_new_issue
- click_on 'Submit issue'
+ click_element :issuable_create_button, Page::Project::Issue::Show
end
end
end
diff --git a/qa/qa/page/project/issue/show.rb b/qa/qa/page/project/issue/show.rb
index 507dccb52d0..45dad9bc0ae 100644
--- a/qa/qa/page/project/issue/show.rb
+++ b/qa/qa/page/project/issue/show.rb
@@ -14,7 +14,7 @@ module QA
end
view 'app/assets/javascripts/notes/components/discussion_filter.vue' do
- element :discussion_filter
+ element :discussion_filter, required: true
element :filter_options
end
diff --git a/qa/qa/page/project/menu.rb b/qa/qa/page/project/menu.rb
index 3fe048f752a..838d59b59cb 100644
--- a/qa/qa/page/project/menu.rb
+++ b/qa/qa/page/project/menu.rb
@@ -5,7 +5,7 @@ module QA
module Project
class Menu < Page::Base
include SubMenus::Common
-
+ include SubMenus::Project
include SubMenus::CiCd
include SubMenus::Issues
include SubMenus::Operations
diff --git a/qa/qa/resource/merge_request.rb b/qa/qa/resource/merge_request.rb
index 7969de726e4..45ab2396a04 100644
--- a/qa/qa/resource/merge_request.rb
+++ b/qa/qa/resource/merge_request.rb
@@ -5,7 +5,8 @@ require 'securerandom'
module QA
module Resource
class MergeRequest < Base
- attr_accessor :title,
+ attr_accessor :id,
+ :title,
:description,
:source_branch,
:target_branch,
@@ -74,6 +75,28 @@ module QA
page.create_merge_request
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
diff --git a/qa/qa/scenario/test/sanity/selectors.rb b/qa/qa/scenario/test/sanity/selectors.rb
index b4d70fc191a..632a0f5f2a9 100644
--- a/qa/qa/scenario/test/sanity/selectors.rb
+++ b/qa/qa/scenario/test/sanity/selectors.rb
@@ -7,11 +7,13 @@ module QA
class Selectors < Scenario::Template
include Scenario::Bootable
- PAGES = [QA::Page].freeze
+ def pages
+ @pages ||= [QA::Page]
+ end
def perform(*)
- validators = PAGES.map do |pages|
- Page::Validator.new(pages)
+ validators = pages.map do |page|
+ Page::Validator.new(page)
end
validators.flat_map(&:errors).tap do |errors|
diff --git a/qa/qa/service/omnibus.rb b/qa/qa/service/omnibus.rb
index b54fd5628f2..c5cddff56cd 100644
--- a/qa/qa/service/omnibus.rb
+++ b/qa/qa/service/omnibus.rb
@@ -11,11 +11,12 @@ module QA
end
def gitlab_ctl(command, input: nil)
- if input.nil?
- shell "docker exec #{@name} gitlab-ctl #{command}"
- else
- shell "docker exec #{@name} bash -c '#{input} | gitlab-ctl #{command}'"
- end
+ docker_exec("gitlab-ctl #{command}", input: input)
+ end
+
+ def docker_exec(command, input: nil)
+ command = "#{input} | #{command}" if input
+ shell "docker exec #{@name} bash -c '#{command}'"
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb
index 9e48ee7ca2a..891cef6c420 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb
@@ -7,13 +7,18 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login)
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.description = 'For downloading patches and diffs'
+ merge_request.description = '... for downloading patches and diffs'
end
end
- it 'user views merge request email patches' do
+ it 'views the merge request email patches' do
@merge_request.visit!
Page::MergeRequest::Show.perform(&:view_email_patches)
@@ -22,7 +27,7 @@ module QA
expect(page).to have_content('diff --git a/added_file.txt b/added_file.txt')
end
- it 'user views merge request plain diff' do
+ it 'views the merge request plain diff' do
@merge_request.visit!
Page::MergeRequest::Show.perform(&:view_plain_diff)
diff --git a/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb b/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb
index 2fe4e4d9d1f..f6411d8c5ad 100644
--- a/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb
+++ b/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb
@@ -3,36 +3,29 @@
require 'digest/sha1'
module QA
- # Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/70
- context 'Release', :docker, :quarantine do
+ context 'Release', :docker do
describe 'Git clone using a deploy key' do
- def login
+ before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- end
-
- before(:all) do
- login
@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'
end
@repository_location = @project.repository_ssh_location
- Resource::Runner.fabricate! do |resource|
+ Resource::Runner.fabricate_via_browser_ui! do |resource|
resource.project = @project
resource.name = @runner_name
resource.tags = %w[qa docker]
resource.image = 'gitlab/gitlab-runner:ubuntu'
end
-
- Page::Main::Menu.perform(&:sign_out)
end
- after(:all) do
+ after do
Service::Runner.new(@runner_name).remove!
end
@@ -46,9 +39,7 @@ module QA
it "user sets up a deploy key with #{key_class}(#{bits}) to clone code using pipelines" do
key = key_class.new(*bits)
- login
-
- Resource::DeployKey.fabricate! do |resource|
+ Resource::DeployKey.fabricate_via_browser_ui! do |resource|
resource.project = @project
resource.title = "deploy key #{key.name}(#{key.bits})"
resource.key = key.public_key
@@ -56,7 +47,7 @@ module QA
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.key = deploy_key_name
resource.value = key.private_key
diff --git a/qa/qa/vendor/saml_idp/page/login.rb b/qa/qa/vendor/saml_idp/page/login.rb
index 9c1f9904a7a..1b8c926532a 100644
--- a/qa/qa/vendor/saml_idp/page/login.rb
+++ b/qa/qa/vendor/saml_idp/page/login.rb
@@ -12,6 +12,14 @@ module QA
fill_in 'password', with: 'user1pass'
click_on 'Login'
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
diff --git a/qa/spec/resource/repository/push_spec.rb b/qa/spec/resource/repository/push_spec.rb
index bf3ebce0cfe..2f9e4958ae1 100644
--- a/qa/spec/resource/repository/push_spec.rb
+++ b/qa/spec/resource/repository/push_spec.rb
@@ -19,7 +19,11 @@ describe QA::Resource::Repository::Push do
expect { subject.files = [] }.to raise_error(ArgumentError)
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
end
end
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
index caf96a213e1..340831aa06d 100644
--- a/qa/spec/runtime/env_spec.rb
+++ b/qa/spec/runtime/env_spec.rb
@@ -192,6 +192,30 @@ describe QA::Runtime::Env do
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
it 'raises ArgumentError if GITHUB_ACCESS_TOKEN is not defined' do
stub_env('GITHUB_ACCESS_TOKEN', nil)