summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-09 09:42:43 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-09 09:42:43 +0100
commit489267e6dd10b9eac15f2aea4c1f3259cc5510f2 (patch)
treefbbc6aa16bcc7a667d0fdb9c4402b8c232b56323 /qa
parentd2c2f93fe6ed557ecfbc53afedef899dd49b244d (diff)
parent7b2f9af4486b26512a2fefb3f385a2b8fa65a068 (diff)
downloadgitlab-ce-489267e6dd10b9eac15f2aea4c1f3259cc5510f2.tar.gz
Merge branch 'master' into qa/gb/validate-qa-selectors
* master: (429 commits)
Diffstat (limited to 'qa')
-rw-r--r--qa/qa.rb16
-rw-r--r--qa/qa/factory/resource/deploy_key.rb31
-rw-r--r--qa/qa/factory/resource/sandbox.rb2
-rw-r--r--qa/qa/factory/settings/hashed_storage.rb6
-rw-r--r--qa/qa/page/menu/admin.rb (renamed from qa/qa/page/admin/menu.rb)4
-rw-r--r--qa/qa/page/menu/main.rb (renamed from qa/qa/page/main/menu.rb)4
-rw-r--r--qa/qa/page/menu/side.rb29
-rw-r--r--qa/qa/page/project/settings/common.rb17
-rw-r--r--qa/qa/page/project/settings/deploy_keys.rb27
-rw-r--r--qa/qa/page/project/settings/repository.rb17
-rw-r--r--qa/qa/runtime/browser.rb41
-rw-r--r--qa/qa/runtime/env.rb15
-rw-r--r--qa/qa/runtime/user.rb11
-rw-r--r--qa/qa/specs/features/login/standard_spec.rb2
-rw-r--r--qa/qa/specs/features/mattermost/group_create_spec.rb2
-rw-r--r--qa/qa/specs/features/project/add_deploy_key_spec.rb22
-rw-r--r--qa/spec/runtime/env_spec.rb64
17 files changed, 291 insertions, 19 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index fb3b646564a..9ee4e6b9d0c 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -10,6 +10,7 @@ module QA
autoload :Namespace, 'qa/runtime/namespace'
autoload :Scenario, 'qa/runtime/scenario'
autoload :Browser, 'qa/runtime/browser'
+ autoload :Env, 'qa/runtime/env'
end
##
@@ -24,6 +25,7 @@ module QA
autoload :Sandbox, 'qa/factory/resource/sandbox'
autoload :Group, 'qa/factory/resource/group'
autoload :Project, 'qa/factory/resource/project'
+ autoload :DeployKey, 'qa/factory/resource/deploy_key'
end
module Repository
@@ -75,10 +77,15 @@ module QA
module Main
autoload :Login, 'qa/page/main/login'
- autoload :Menu, 'qa/page/main/menu'
autoload :OAuth, 'qa/page/main/oauth'
end
+ module Menu
+ autoload :Main, 'qa/page/menu/main'
+ autoload :Side, 'qa/page/menu/side'
+ autoload :Admin, 'qa/page/menu/admin'
+ end
+
module Dashboard
autoload :Projects, 'qa/page/dashboard/projects'
autoload :Groups, 'qa/page/dashboard/groups'
@@ -92,10 +99,15 @@ module QA
module Project
autoload :New, 'qa/page/project/new'
autoload :Show, 'qa/page/project/show'
+
+ module Settings
+ autoload :Common, 'qa/page/project/settings/common'
+ autoload :Repository, 'qa/page/project/settings/repository'
+ autoload :DeployKeys, 'qa/page/project/settings/deploy_keys'
+ end
end
module Admin
- autoload :Menu, 'qa/page/admin/menu'
autoload :Settings, 'qa/page/admin/settings'
end
diff --git a/qa/qa/factory/resource/deploy_key.rb b/qa/qa/factory/resource/deploy_key.rb
new file mode 100644
index 00000000000..7c58e70bcc4
--- /dev/null
+++ b/qa/qa/factory/resource/deploy_key.rb
@@ -0,0 +1,31 @@
+module QA
+ module Factory
+ module Resource
+ class DeployKey < Factory::Base
+ attr_accessor :title, :key
+
+ dependency Factory::Resource::Project, as: :project do |project|
+ project.name = 'project-to-deploy'
+ project.description = 'project for adding deploy key test'
+ end
+
+ def fabricate!
+ project.visit!
+
+ Page::Menu::Side.act do
+ click_repository_setting
+ end
+
+ Page::Project::Settings::Repository.perform do |setting|
+ setting.expand_deploy_keys do |page|
+ page.fill_key_title(title)
+ page.fill_key_value(key)
+
+ page.add_key
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/factory/resource/sandbox.rb b/qa/qa/factory/resource/sandbox.rb
index 558da1c973b..ad376988e82 100644
--- a/qa/qa/factory/resource/sandbox.rb
+++ b/qa/qa/factory/resource/sandbox.rb
@@ -11,7 +11,7 @@ module QA
end
def fabricate!
- Page::Main::Menu.act { go_to_groups }
+ Page::Menu::Main.act { go_to_groups }
Page::Dashboard::Groups.perform do |page|
if page.has_group?(@name)
diff --git a/qa/qa/factory/settings/hashed_storage.rb b/qa/qa/factory/settings/hashed_storage.rb
index eb3b28f2613..13ce2435fe4 100644
--- a/qa/qa/factory/settings/hashed_storage.rb
+++ b/qa/qa/factory/settings/hashed_storage.rb
@@ -6,15 +6,15 @@ module QA
raise ArgumentError unless traits.include?(:enabled)
Page::Main::Login.act { sign_in_using_credentials }
- Page::Main::Menu.act { go_to_admin_area }
- Page::Admin::Menu.act { go_to_settings }
+ Page::Menu::Main.act { go_to_admin_area }
+ Page::Menu::Admin.act { go_to_settings }
Page::Admin::Settings.act do
enable_hashed_storage
save_settings
end
- QA::Page::Main::Menu.act { sign_out }
+ QA::Page::Menu::Main.act { sign_out }
end
end
end
diff --git a/qa/qa/page/admin/menu.rb b/qa/qa/page/menu/admin.rb
index dd289ffe269..07fe40fda3a 100644
--- a/qa/qa/page/admin/menu.rb
+++ b/qa/qa/page/menu/admin.rb
@@ -1,7 +1,7 @@
module QA
module Page
- module Admin
- class Menu < Page::Base
+ module Menu
+ class Admin < Page::Base
def go_to_license
click_link 'License'
end
diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/menu/main.rb
index bc9c4ec1215..b94c2c6c23d 100644
--- a/qa/qa/page/main/menu.rb
+++ b/qa/qa/page/menu/main.rb
@@ -1,7 +1,7 @@
module QA
module Page
- module Main
- class Menu < Page::Base
+ module Menu
+ class Main < Page::Base
def go_to_groups
within_top_menu { click_link 'Groups' }
end
diff --git a/qa/qa/page/menu/side.rb b/qa/qa/page/menu/side.rb
new file mode 100644
index 00000000000..6c25aba4bac
--- /dev/null
+++ b/qa/qa/page/menu/side.rb
@@ -0,0 +1,29 @@
+module QA
+ module Page
+ module Menu
+ class Side < Page::Base
+ def click_repository_setting
+ hover_setting do
+ click_link('Repository')
+ end
+ end
+
+ private
+
+ def hover_setting
+ within_sidebar do
+ find('.nav-item-name', text: 'Settings').hover
+
+ yield
+ end
+ end
+
+ def within_sidebar
+ page.within('.sidebar-top-level-items') do
+ yield
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/project/settings/common.rb b/qa/qa/page/project/settings/common.rb
new file mode 100644
index 00000000000..5d1d5120929
--- /dev/null
+++ b/qa/qa/page/project/settings/common.rb
@@ -0,0 +1,17 @@
+module QA
+ module Page
+ module Project
+ module Settings
+ module Common
+ def expand(selector)
+ page.within('#content-body') do
+ find(selector).click
+
+ yield
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/project/settings/deploy_keys.rb b/qa/qa/page/project/settings/deploy_keys.rb
new file mode 100644
index 00000000000..4028b8cccc5
--- /dev/null
+++ b/qa/qa/page/project/settings/deploy_keys.rb
@@ -0,0 +1,27 @@
+module QA
+ module Page
+ module Project
+ module Settings
+ class DeployKeys < Page::Base
+ def fill_key_title(title)
+ fill_in 'deploy_key_title', with: title
+ end
+
+ def fill_key_value(key)
+ fill_in 'deploy_key_key', with: key
+ end
+
+ def add_key
+ click_on 'Add key'
+ end
+
+ def has_key_title?(title)
+ page.within('.deploy-keys') do
+ page.find('.title', text: title)
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/project/settings/repository.rb b/qa/qa/page/project/settings/repository.rb
new file mode 100644
index 00000000000..034b0d09c1c
--- /dev/null
+++ b/qa/qa/page/project/settings/repository.rb
@@ -0,0 +1,17 @@
+module QA
+ module Page
+ module Project
+ module Settings
+ class Repository < Page::Base
+ include Common
+
+ def expand_deploy_keys(&block)
+ expand('.qa-expand-deploy-keys') do
+ DeployKeys.perform(&block)
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb
index 220bb45741b..14b2a488760 100644
--- a/qa/qa/runtime/browser.rb
+++ b/qa/qa/runtime/browser.rb
@@ -38,22 +38,49 @@ module QA
Capybara.register_driver :chrome do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
- 'chromeOptions' => {
- 'args' => %w[headless no-sandbox disable-gpu window-size=1280,1680]
+ # This enables access to logs with `page.driver.manage.get_log(:browser)`
+ loggingPrefs: {
+ browser: "ALL",
+ client: "ALL",
+ driver: "ALL",
+ server: "ALL"
}
)
- Capybara::Selenium::Driver
- .new(app, browser: :chrome, desired_capabilities: capabilities)
- end
+ options = Selenium::WebDriver::Chrome::Options.new
+ options.add_argument("window-size=1240,1680")
- Capybara::Screenshot.register_driver(:chrome) do |driver, path|
- driver.browser.save_screenshot(path)
+ # Chrome won't work properly in a Docker container in sandbox mode
+ options.add_argument("no-sandbox")
+
+ # Run headless by default unless CHROME_HEADLESS is false
+ if QA::Runtime::Env.chrome_headless?
+ options.add_argument("headless")
+
+ # Chrome documentation says this flag is needed for now
+ # https://developers.google.com/web/updates/2017/04/headless-chrome#cli
+ options.add_argument("disable-gpu")
+ end
+
+ # Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252
+ options.add_argument("disable-dev-shm-usage") if QA::Runtime::Env.running_in_ci?
+
+ Capybara::Selenium::Driver.new(
+ app,
+ browser: :chrome,
+ desired_capabilities: capabilities,
+ options: options
+ )
end
# Keep only the screenshots generated from the last failing test suite
Capybara::Screenshot.prune_strategy = :keep_last_run
+ # From https://github.com/mattheworiordan/capybara-screenshot/issues/84#issuecomment-41219326
+ Capybara::Screenshot.register_driver(:chrome) do |driver, path|
+ driver.browser.save_screenshot(path)
+ end
+
Capybara.configure do |config|
config.default_driver = :chrome
config.javascript_driver = :chrome
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb
new file mode 100644
index 00000000000..d5c28e9a7db
--- /dev/null
+++ b/qa/qa/runtime/env.rb
@@ -0,0 +1,15 @@
+module QA
+ module Runtime
+ module Env
+ extend self
+
+ def chrome_headless?
+ (ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i) != 0
+ end
+
+ def running_in_ci?
+ ENV['CI'] || ENV['CI_SERVER']
+ end
+ end
+ end
+end
diff --git a/qa/qa/runtime/user.rb b/qa/qa/runtime/user.rb
index 60027c89ab1..2832439d9e0 100644
--- a/qa/qa/runtime/user.rb
+++ b/qa/qa/runtime/user.rb
@@ -10,6 +10,17 @@ module QA
def password
ENV['GITLAB_PASSWORD'] || '5iveL!fe'
end
+
+ def ssh_key
+ <<~KEY.delete("\n")
+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFf6RYK3qu/RKF/3ndJmL5xgMLp3O9
+ 6x8lTay+QGZ0+9FnnAXMdUqBq/ZU6d/gyMB4IaW3nHzM1w049++yAB6UPCzMB8Uo27K5
+ /jyZCtj7Vm9PFNjF/8am1kp46c/SeYicQgQaSBdzIW3UDEa1Ef68qroOlvpi9PYZ/tA7
+ M0YP0K5PXX+E36zaIRnJVMPT3f2k+GnrxtjafZrwFdpOP/Fol5BQLBgcsyiU+LM1SuaC
+ rzd8c9vyaTA1CxrkxaZh+buAi0PmdDtaDrHd42gqZkXCKavyvgM5o2CkQ5LJHCgzpXy0
+ 5qNFzmThBSkb+XtoxbyagBiGbVZtSVow6Xa7qewz= dummy@gitlab.com
+ KEY
+ end
end
end
end
diff --git a/qa/qa/specs/features/login/standard_spec.rb b/qa/qa/specs/features/login/standard_spec.rb
index 9eaa2b772e6..141ffa3cfb7 100644
--- a/qa/qa/specs/features/login/standard_spec.rb
+++ b/qa/qa/specs/features/login/standard_spec.rb
@@ -7,7 +7,7 @@ module QA
# TODO, since `Signed in successfully` message was removed
# this is the only way to tell if user is signed in correctly.
#
- Page::Main::Menu.perform do |menu|
+ Page::Menu::Main.perform do |menu|
expect(menu).to have_personal_area
end
end
diff --git a/qa/qa/specs/features/mattermost/group_create_spec.rb b/qa/qa/specs/features/mattermost/group_create_spec.rb
index b3dbe44bf6e..2e27a285223 100644
--- a/qa/qa/specs/features/mattermost/group_create_spec.rb
+++ b/qa/qa/specs/features/mattermost/group_create_spec.rb
@@ -3,7 +3,7 @@ module QA
scenario 'creating a group with a mattermost team' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
- Page::Main::Menu.act { go_to_groups }
+ Page::Menu::Main.act { go_to_groups }
Page::Dashboard::Groups.perform do |page|
page.go_to_new_group
diff --git a/qa/qa/specs/features/project/add_deploy_key_spec.rb b/qa/qa/specs/features/project/add_deploy_key_spec.rb
new file mode 100644
index 00000000000..43a85213501
--- /dev/null
+++ b/qa/qa/specs/features/project/add_deploy_key_spec.rb
@@ -0,0 +1,22 @@
+module QA
+ feature 'deploy keys support', :core do
+ given(:deploy_key_title) { 'deploy key title' }
+ given(:deploy_key_value) { Runtime::User.ssh_key }
+
+ scenario 'user adds a deploy key' do
+ Runtime::Browser.visit(:gitlab, Page::Main::Login)
+ Page::Main::Login.act { sign_in_using_credentials }
+
+ Factory::Resource::DeployKey.fabricate! do |deploy_key|
+ deploy_key.title = deploy_key_title
+ deploy_key.key = deploy_key_value
+ end
+
+ Page::Project::Settings::Repository.perform do |setting|
+ setting.expand_deploy_keys do |page|
+ expect(page).to have_key_title(deploy_key_title)
+ end
+ end
+ end
+ end
+end
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
new file mode 100644
index 00000000000..57a72a04507
--- /dev/null
+++ b/qa/spec/runtime/env_spec.rb
@@ -0,0 +1,64 @@
+describe QA::Runtime::Env do
+ before do
+ allow(ENV).to receive(:[]).and_call_original
+ end
+
+ describe '.chrome_headless?' do
+ context 'when there is an env variable set' do
+ it 'returns false when falsey values specified' do
+ stub_env('CHROME_HEADLESS', 'false')
+ expect(described_class.chrome_headless?).to be_falsey
+
+ stub_env('CHROME_HEADLESS', 'no')
+ expect(described_class.chrome_headless?).to be_falsey
+
+ stub_env('CHROME_HEADLESS', '0')
+ expect(described_class.chrome_headless?).to be_falsey
+ end
+
+ it 'returns true when anything else specified' do
+ stub_env('CHROME_HEADLESS', 'true')
+ expect(described_class.chrome_headless?).to be_truthy
+
+ stub_env('CHROME_HEADLESS', '1')
+ expect(described_class.chrome_headless?).to be_truthy
+
+ stub_env('CHROME_HEADLESS', 'anything')
+ expect(described_class.chrome_headless?).to be_truthy
+ end
+ end
+
+ context 'when there is no env variable set' do
+ it 'returns the default, true' do
+ stub_env('CHROME_HEADLESS', nil)
+ expect(described_class.chrome_headless?).to be_truthy
+ end
+ end
+ end
+
+ describe '.running_in_ci?' do
+ context 'when there is an env variable set' do
+ it 'returns true if CI' do
+ stub_env('CI', 'anything')
+ expect(described_class.running_in_ci?).to be_truthy
+ end
+
+ it 'returns true if CI_SERVER' do
+ stub_env('CI_SERVER', 'anything')
+ expect(described_class.running_in_ci?).to be_truthy
+ end
+ end
+
+ context 'when there is no env variable set' do
+ it 'returns true' do
+ stub_env('CI', nil)
+ stub_env('CI_SERVER', nil)
+ expect(described_class.running_in_ci?).to be_falsey
+ end
+ end
+ end
+
+ def stub_env(name, value)
+ allow(ENV).to receive(:[]).with(name).and_return(value)
+ end
+end