From ca7e1058e8d91a01157ac7d9170423e16a732850 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 22 Jan 2018 18:22:44 +0800 Subject: Add a scenario for adding secret variables --- app/views/projects/settings/ci_cd/show.html.haml | 4 +- qa/qa.rb | 3 ++ qa/qa/factory/resource/secret_variable.rb | 43 ++++++++++++++++ qa/qa/page/menu/side.rb | 20 +++++++- qa/qa/page/project/settings/cicd.rb | 21 ++++++++ qa/qa/page/project/settings/secret_variables.rb | 60 ++++++++++++++++++++++ .../features/project/add_secret_variable_spec.rb | 19 +++++++ 7 files changed, 167 insertions(+), 3 deletions(-) create mode 100644 qa/qa/factory/resource/secret_variable.rb create mode 100644 qa/qa/page/project/settings/cicd.rb create mode 100644 qa/qa/page/project/settings/secret_variables.rb create mode 100644 qa/qa/specs/features/project/add_secret_variable_spec.rb 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" diff --git a/qa/qa.rb b/qa/qa.rb index 4803432aeee..ac082cfe9a0 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -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 -- cgit v1.2.1 From 8586391e073901ef7dcd70e20f3ccc00774006d2 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 25 Jan 2018 21:11:44 +0800 Subject: Respect the latest changes from master Basically using the new expand_section --- app/views/projects/settings/ci_cd/show.html.haml | 4 ++-- qa/qa.rb | 1 - qa/qa/factory/resource/secret_variable.rb | 4 +--- qa/qa/page/menu/side.rb | 10 +++++++--- qa/qa/page/project/settings/ci_cd.rb | 7 +++++++ qa/qa/page/project/settings/cicd.rb | 21 --------------------- qa/qa/page/project/settings/common.rb | 11 +++++++++-- qa/qa/page/project/settings/secret_variables.rb | 20 ++++---------------- 8 files changed, 30 insertions(+), 48 deletions(-) delete mode 100644 qa/qa/page/project/settings/cicd.rb diff --git a/app/views/projects/settings/ci_cd/show.html.haml b/app/views/projects/settings/ci_cd/show.html.haml index 32d8eebfa32..664a4554692 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.qa-secret-variables{ class: ('expanded' if expanded) } +%section.settings.no-animate{ 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.qa-expand-secret-variables + %button.btn.js-settings-toggle = expanded ? 'Collapse' : 'Expand' %p = render "ci/variables/content" diff --git a/qa/qa.rb b/qa/qa.rb index dfb0594eebe..8c9dbb786e0 100644 --- a/qa/qa.rb +++ b/qa/qa.rb @@ -112,7 +112,6 @@ 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 :CICD, 'qa/page/project/settings/cicd' 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 index 0b84d6fec60..54ef4d8d964 100644 --- a/qa/qa/factory/resource/secret_variable.rb +++ b/qa/qa/factory/resource/secret_variable.rb @@ -24,9 +24,7 @@ module QA def fabricate! project.visit! - Page::Menu::Side.act do - click_ci_cd_settings - end + Page::Menu::Side.act { click_ci_cd_settings } Page::Project::Settings::CICD.perform do |setting| setting.expand_secret_variables do |page| diff --git a/qa/qa/page/menu/side.rb b/qa/qa/page/menu/side.rb index 0ca428e8b5a..239f2872228 100644 --- a/qa/qa/page/menu/side.rb +++ b/qa/qa/page/menu/side.rb @@ -29,15 +29,19 @@ module QA end end + def click_ci_cd_pipelines + within_sidebar do + click_link('CI / CD') + end + end + private def hover_settings within_sidebar do find('.qa-settings-item').hover - within_fly_out do - yield - end + yield end end 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/cicd.rb b/qa/qa/page/project/settings/cicd.rb deleted file mode 100644 index 045a0826522..00000000000 --- a/qa/qa/page/project/settings/cicd.rb +++ /dev/null @@ -1,21 +0,0 @@ -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/common.rb b/qa/qa/page/project/settings/common.rb index 1357bf031d5..7fa04b62fde 100644 --- a/qa/qa/page/project/settings/common.rb +++ b/qa/qa/page/project/settings/common.rb @@ -12,10 +12,17 @@ module QA end def expand_section(name) + within_section(name) do + # Don't expand if it's already expanded + click_button 'Expand' unless first('button', text: 'Collapse') + + yield + end + end + + def within_section(name) page.within('#content-body') do page.within('section', text: name) do - click_button 'Expand' - yield end end diff --git a/qa/qa/page/project/settings/secret_variables.rb b/qa/qa/page/project/settings/secret_variables.rb index 880ef58ab54..846fd893f94 100644 --- a/qa/qa/page/project/settings/secret_variables.rb +++ b/qa/qa/page/project/settings/secret_variables.rb @@ -3,15 +3,13 @@ module QA 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/projects/settings/ci_cd/show.html.haml' do - element :secret_variable - end - def fill_variable_key(key) fill_in 'variable_key', with: key end @@ -36,21 +34,11 @@ module QA private - def within_section - page.within('.qa-secret-variables') do - yield - end - end - def reveal_value - within_section do - click_button('Reveal value') - end + click_button('Reveal value') yield.tap do - within_section do - click_button('Hide value') - end + click_button('Hide value') end end end -- cgit v1.2.1 From 73e3215b1b6dd2ed154622bbd4c3d16789ff3fa4 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 25 Jan 2018 21:33:30 +0800 Subject: Add more views check --- qa/qa/page/project/settings/secret_variables.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qa/qa/page/project/settings/secret_variables.rb b/qa/qa/page/project/settings/secret_variables.rb index 846fd893f94..e3bfbfcf080 100644 --- a/qa/qa/page/project/settings/secret_variables.rb +++ b/qa/qa/page/project/settings/secret_variables.rb @@ -10,6 +10,15 @@ module QA 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 -- cgit v1.2.1 From f5efeeb807e6c88c380a76bdfb2258ff8b0303cd Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 25 Jan 2018 21:33:48 +0800 Subject: Try to restore page's state --- qa/qa/page/project/settings/common.rb | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/qa/qa/page/project/settings/common.rb b/qa/qa/page/project/settings/common.rb index 7fa04b62fde..b61f64d446c 100644 --- a/qa/qa/page/project/settings/common.rb +++ b/qa/qa/page/project/settings/common.rb @@ -12,18 +12,13 @@ module QA end def expand_section(name) - within_section(name) do - # Don't expand if it's already expanded - click_button 'Expand' unless first('button', text: 'Collapse') - - yield - end - end - - def within_section(name) page.within('#content-body') do page.within('section', text: name) do - yield + click_button 'Expand' + + yield.tap do + click_button 'Collapse' if first('button', text: 'Collapse') + end end end end -- cgit v1.2.1 From 3d4a7f63cbf197465fa556ece387b57f57176d10 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 25 Jan 2018 21:40:27 +0800 Subject: Prefer local variables over given/let --- qa/qa/specs/features/project/add_secret_variable_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qa/qa/specs/features/project/add_secret_variable_spec.rb b/qa/qa/specs/features/project/add_secret_variable_spec.rb index 803ced6e3fc..36422a92afc 100644 --- a/qa/qa/specs/features/project/add_secret_variable_spec.rb +++ b/qa/qa/specs/features/project/add_secret_variable_spec.rb @@ -1,12 +1,12 @@ 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_key = 'VARIABLE_KEY' + variable_value = 'variable value' + variable = Factory::Resource::SecretVariable.fabricate! do |resource| resource.key = variable_key resource.value = variable_value -- cgit v1.2.1 From 2290b438f429071eed96e7db63c0356a2e666778 Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Thu, 25 Jan 2018 20:44:16 +0100 Subject: Fix rubocop offenses introduced in !16623 --- spec/lib/gitlab/git/repository_spec.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index e4562e4d43e..3db04d99855 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -1998,8 +1998,13 @@ describe Gitlab::Git::Repository, seed_helper: true do let(:project) { create(:project) } let(:imported_repo) { project.repository.raw } - before { expect(repository.bundle_to_disk(bundle_path)).to be true } - after { FileUtils.rm_rf(bundle_path) } + before do + expect(repository.bundle_to_disk(bundle_path)).to be true + end + + after do + FileUtils.rm_rf(bundle_path) + end it 'creates a repo from a bundle file' do expect(imported_repo).not_to exist -- cgit v1.2.1 From 8210d2eba5f0a52759156bc2bf8df72884747c42 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Thu, 25 Jan 2018 14:40:48 -0600 Subject: fix bug in webpack_helper in which force_same_domain argument was ignored breaking local rspec tests --- app/helpers/webpack_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/webpack_helper.rb b/app/helpers/webpack_helper.rb index 94887c2cbd2..77433acb92a 100644 --- a/app/helpers/webpack_helper.rb +++ b/app/helpers/webpack_helper.rb @@ -2,7 +2,7 @@ require 'webpack/rails/manifest' module WebpackHelper def webpack_bundle_tag(bundle, force_same_domain: false) - javascript_include_tag(*gitlab_webpack_asset_paths(bundle, force_same_domain: true)) + javascript_include_tag(*gitlab_webpack_asset_paths(bundle, force_same_domain: force_same_domain)) end # override webpack-rails gem helper until changes can make it upstream -- cgit v1.2.1 From 253c2a365fba7e3abbbb01e0d50565cafc696506 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 26 Jan 2018 16:15:52 +0800 Subject: Just don't expand if it's already expanded --- qa/qa/page/project/settings/common.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qa/qa/page/project/settings/common.rb b/qa/qa/page/project/settings/common.rb index b61f64d446c..0a2a3488b9a 100644 --- a/qa/qa/page/project/settings/common.rb +++ b/qa/qa/page/project/settings/common.rb @@ -14,11 +14,9 @@ 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.tap do - click_button 'Collapse' if first('button', text: 'Collapse') - end + yield end end end -- cgit v1.2.1