summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2018-01-26 09:21:36 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2018-01-26 09:21:36 +0000
commitb8d044af88507b300d98d9141a2a3d7735f0696d (patch)
treeee5d66deaa5ee3b47dd2354d8581ce104c9c2193
parent8e3f40f71fba520a9e05e13e7902a3dcdc0d7c15 (diff)
parent253c2a365fba7e3abbbb01e0d50565cafc696506 (diff)
downloadgitlab-ce-b8d044af88507b300d98d9141a2a3d7735f0696d.tar.gz
Merge branch 'qa-secret-variables-scenario' into 'master'
Add a scenario for adding secret variables See merge request gitlab-org/gitlab-ce!16607
-rw-r--r--qa/qa.rb2
-rw-r--r--qa/qa/factory/resource/secret_variable.rb41
-rw-r--r--qa/qa/page/menu/side.rb4
-rw-r--r--qa/qa/page/project/settings/ci_cd.rb7
-rw-r--r--qa/qa/page/project/settings/common.rb2
-rw-r--r--qa/qa/page/project/settings/secret_variables.rb57
-rw-r--r--qa/qa/specs/features/project/add_secret_variable_spec.rb19
7 files changed, 131 insertions, 1 deletions
diff --git a/qa/qa.rb b/qa/qa.rb
index 5587a665809..8f200049bf6 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -29,6 +29,7 @@ module QA
autoload :Group, 'qa/factory/resource/group'
autoload :Project, 'qa/factory/resource/project'
autoload :DeployKey, 'qa/factory/resource/deploy_key'
+ autoload :SecretVariable, 'qa/factory/resource/secret_variable'
autoload :Runner, 'qa/factory/resource/runner'
autoload :PersonalAccessToken, 'qa/factory/resource/personal_access_token'
end
@@ -112,6 +113,7 @@ module QA
autoload :Repository, 'qa/page/project/settings/repository'
autoload :CICD, 'qa/page/project/settings/ci_cd'
autoload :DeployKeys, 'qa/page/project/settings/deploy_keys'
+ autoload :SecretVariables, 'qa/page/project/settings/secret_variables'
autoload :Runners, 'qa/page/project/settings/runners'
end
diff --git a/qa/qa/factory/resource/secret_variable.rb b/qa/qa/factory/resource/secret_variable.rb
new file mode 100644
index 00000000000..54ef4d8d964
--- /dev/null
+++ b/qa/qa/factory/resource/secret_variable.rb
@@ -0,0 +1,41 @@
+module QA
+ module Factory
+ module Resource
+ class SecretVariable < Factory::Base
+ attr_accessor :key, :value
+
+ product :key do
+ Page::Project::Settings::CICD.act do
+ expand_secret_variables(&:variable_key)
+ end
+ end
+
+ product :value do
+ Page::Project::Settings::CICD.act do
+ expand_secret_variables(&:variable_value)
+ end
+ end
+
+ dependency Factory::Resource::Project, as: :project do |project|
+ project.name = 'project-with-secret-variables'
+ project.description = 'project for adding secret variable test'
+ end
+
+ def fabricate!
+ project.visit!
+
+ Page::Menu::Side.act { click_ci_cd_settings }
+
+ Page::Project::Settings::CICD.perform do |setting|
+ setting.expand_secret_variables do |page|
+ page.fill_variable_key(key)
+ page.fill_variable_value(value)
+
+ page.add_variable
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/page/menu/side.rb b/qa/qa/page/menu/side.rb
index 7f0f924c5e8..239f2872228 100644
--- a/qa/qa/page/menu/side.rb
+++ b/qa/qa/page/menu/side.rb
@@ -9,6 +9,10 @@ module QA
element :top_level_items, '.sidebar-top-level-items'
end
+ view 'app/assets/javascripts/fly_out_nav.js' do
+ element :fly_out, "classList.add('fly-out-list')"
+ end
+
def click_repository_settings
hover_settings do
within_submenu do
diff --git a/qa/qa/page/project/settings/ci_cd.rb b/qa/qa/page/project/settings/ci_cd.rb
index 5270dde7411..99be21bbe89 100644
--- a/qa/qa/page/project/settings/ci_cd.rb
+++ b/qa/qa/page/project/settings/ci_cd.rb
@@ -7,6 +7,7 @@ module QA
view 'app/views/projects/settings/ci_cd/show.html.haml' do
element :runners_settings, 'Runners settings'
+ element :secret_variables, 'Secret variables'
end
def expand_runners_settings(&block)
@@ -14,6 +15,12 @@ module QA
Settings::Runners.perform(&block)
end
end
+
+ def expand_secret_variables(&block)
+ expand_section('Secret variables') do
+ Settings::SecretVariables.perform(&block)
+ end
+ end
end
end
end
diff --git a/qa/qa/page/project/settings/common.rb b/qa/qa/page/project/settings/common.rb
index 1357bf031d5..0a2a3488b9a 100644
--- a/qa/qa/page/project/settings/common.rb
+++ b/qa/qa/page/project/settings/common.rb
@@ -14,7 +14,7 @@ module QA
def expand_section(name)
page.within('#content-body') do
page.within('section', text: name) do
- click_button 'Expand'
+ click_button 'Expand' unless first('button', text: 'Collapse')
yield
end
diff --git a/qa/qa/page/project/settings/secret_variables.rb b/qa/qa/page/project/settings/secret_variables.rb
new file mode 100644
index 00000000000..e3bfbfcf080
--- /dev/null
+++ b/qa/qa/page/project/settings/secret_variables.rb
@@ -0,0 +1,57 @@
+module QA
+ module Page
+ module Project
+ module Settings
+ class SecretVariables < Page::Base
+ include Common
+
+ view 'app/views/ci/variables/_table.html.haml' do
+ element :variable_key, '.variable-key'
+ element :variable_value, '.variable-value'
+ end
+
+ view 'app/views/ci/variables/_index.html.haml' do
+ element :add_new_variable, 'btn_text: "Add new variable"'
+ end
+
+ view 'app/assets/javascripts/behaviors/secret_values.js' do
+ element :reveal_value, 'Reveal value'
+ element :hide_value, 'Hide value'
+ end
+
+ def fill_variable_key(key)
+ fill_in 'variable_key', with: key
+ end
+
+ def fill_variable_value(value)
+ fill_in 'variable_value', with: value
+ end
+
+ def add_variable
+ click_on 'Add new variable'
+ end
+
+ def variable_key
+ page.find('.variable-key').text
+ end
+
+ def variable_value
+ reveal_value do
+ page.find('.variable-value').text
+ end
+ end
+
+ private
+
+ def reveal_value
+ click_button('Reveal value')
+
+ yield.tap do
+ click_button('Hide value')
+ end
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/qa/qa/specs/features/project/add_secret_variable_spec.rb b/qa/qa/specs/features/project/add_secret_variable_spec.rb
new file mode 100644
index 00000000000..36422a92afc
--- /dev/null
+++ b/qa/qa/specs/features/project/add_secret_variable_spec.rb
@@ -0,0 +1,19 @@
+module QA
+ feature 'secret variables support', :core do
+ scenario 'user adds a secret variable' do
+ Runtime::Browser.visit(:gitlab, Page::Main::Login)
+ Page::Main::Login.act { sign_in_using_credentials }
+
+ variable_key = 'VARIABLE_KEY'
+ variable_value = 'variable value'
+
+ variable = Factory::Resource::SecretVariable.fabricate! do |resource|
+ resource.key = variable_key
+ resource.value = variable_value
+ end
+
+ expect(variable.key).to eq(variable_key)
+ expect(variable.value).to eq(variable_value)
+ end
+ end
+end