diff options
-rw-r--r-- | app/views/projects/settings/ci_cd/show.html.haml | 4 | ||||
-rw-r--r-- | qa/qa.rb | 3 | ||||
-rw-r--r-- | qa/qa/factory/resource/secret_variable.rb | 43 | ||||
-rw-r--r-- | qa/qa/page/menu/side.rb | 20 | ||||
-rw-r--r-- | qa/qa/page/project/settings/cicd.rb | 21 | ||||
-rw-r--r-- | qa/qa/page/project/settings/secret_variables.rb | 60 | ||||
-rw-r--r-- | qa/qa/specs/features/project/add_secret_variable_spec.rb | 19 |
7 files changed, 167 insertions, 3 deletions
diff --git a/app/views/projects/settings/ci_cd/show.html.haml b/app/views/projects/settings/ci_cd/show.html.haml index 664a4554692..32d8eebfa32 100644 --- a/app/views/projects/settings/ci_cd/show.html.haml +++ b/app/views/projects/settings/ci_cd/show.html.haml @@ -26,12 +26,12 @@ .settings-content = render 'projects/runners/index' -%section.settings.no-animate{ class: ('expanded' if expanded) } +%section.settings.no-animate.qa-secret-variables{ class: ('expanded' if expanded) } .settings-header %h4 Secret variables = link_to icon('question-circle'), help_page_path('ci/variables/README', anchor: 'secret-variables'), target: '_blank' - %button.btn.js-settings-toggle + %button.btn.js-settings-toggle.qa-expand-secret-variables = expanded ? 'Collapse' : 'Expand' %p = render "ci/variables/content" @@ -26,6 +26,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' end module Repository @@ -105,6 +106,8 @@ module QA autoload :Common, 'qa/page/project/settings/common' autoload :Repository, 'qa/page/project/settings/repository' autoload :DeployKeys, 'qa/page/project/settings/deploy_keys' + autoload :CICD, 'qa/page/project/settings/cicd' + autoload :SecretVariables, 'qa/page/project/settings/secret_variables' end 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..26f27f25a2e --- /dev/null +++ b/qa/qa/factory/resource/secret_variable.rb @@ -0,0 +1,43 @@ +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 do + click_cicd_setting + end + + 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 1df4e0c2429..0053d5056e1 100644 --- a/qa/qa/page/menu/side.rb +++ b/qa/qa/page/menu/side.rb @@ -8,19 +8,31 @@ module QA element :top_level_items, '.sidebar-top-level-items' end + view 'app/assets/javascripts/fly_out_nav.js' do + element :fly_out, "IS_SHOWING_FLY_OUT_CLASS = 'is-showing-fly-out'" + end + def click_repository_setting hover_setting do click_link('Repository') end end + def click_cicd_setting + hover_setting do + click_link('CI / CD') + end + end + private def hover_setting within_sidebar do find('.qa-settings-item').hover - yield + within_fly_out do + yield + end end end @@ -29,6 +41,12 @@ module QA yield end end + + def within_fly_out + page.within('.is-showing-fly-out') do + yield + end + end end end end diff --git a/qa/qa/page/project/settings/cicd.rb b/qa/qa/page/project/settings/cicd.rb new file mode 100644 index 00000000000..045a0826522 --- /dev/null +++ b/qa/qa/page/project/settings/cicd.rb @@ -0,0 +1,21 @@ +module QA + module Page + module Project + module Settings + class CICD < Page::Base + include Common + + view 'app/views/projects/settings/ci_cd/show.html.haml' do + element :expand_secret_variables + end + + def expand_secret_variables(&block) + expand(:expand_secret_variables) do + SecretVariables.perform(&block) + end + end + end + end + end + end +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..880ef58ab54 --- /dev/null +++ b/qa/qa/page/project/settings/secret_variables.rb @@ -0,0 +1,60 @@ +module QA + module Page + module Project + module Settings + class SecretVariables < Page::Base + view 'app/views/ci/variables/_table.html.haml' do + element :variable_key, '.variable-key' + element :variable_value, '.variable-value' + end + + view 'app/views/projects/settings/ci_cd/show.html.haml' do + element :secret_variable + 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 within_section + page.within('.qa-secret-variables') do + yield + end + end + + def reveal_value + within_section do + click_button('Reveal value') + end + + yield.tap do + within_section do + click_button('Hide value') + end + 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..803ced6e3fc --- /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 + given(:variable_key) { 'VARIABLE_KEY' } + given(:variable_value) { 'variable value' } + + scenario 'user adds a secret variable' do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } + + 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 |