Commit d8f98900 authored by Rémy Coutable's avatar Rémy Coutable

Reduce the CE/EE diff under qa/

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 94cf543f
......@@ -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?
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......@@ -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|
......
......@@ -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
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
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