Commit b54beca7 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge remote-tracking branch 'upstream/master' into qa/ee-4698-backport

* upstream/master:
  Just don't expand if it's already expanded
  fix bug in webpack_helper in which force_same_domain argument was ignored breaking local rspec tests
  Fix rubocop offenses introduced in !16623
  Prefer local variables over given/let
  Try to restore page's state
  Add more views check
  Respect the latest changes from master
  Add a scenario for adding secret variables
parents a33f7050 b8d044af
...@@ -2,7 +2,7 @@ require 'webpack/rails/manifest' ...@@ -2,7 +2,7 @@ require 'webpack/rails/manifest'
module WebpackHelper module WebpackHelper
def webpack_bundle_tag(bundle, force_same_domain: false) 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 end
# override webpack-rails gem helper until changes can make it upstream # override webpack-rails gem helper until changes can make it upstream
......
...@@ -29,6 +29,7 @@ module QA ...@@ -29,6 +29,7 @@ module QA
autoload :Group, 'qa/factory/resource/group' autoload :Group, 'qa/factory/resource/group'
autoload :Project, 'qa/factory/resource/project' autoload :Project, 'qa/factory/resource/project'
autoload :DeployKey, 'qa/factory/resource/deploy_key' autoload :DeployKey, 'qa/factory/resource/deploy_key'
autoload :SecretVariable, 'qa/factory/resource/secret_variable'
autoload :Runner, 'qa/factory/resource/runner' autoload :Runner, 'qa/factory/resource/runner'
autoload :PersonalAccessToken, 'qa/factory/resource/personal_access_token' autoload :PersonalAccessToken, 'qa/factory/resource/personal_access_token'
end end
...@@ -119,6 +120,7 @@ module QA ...@@ -119,6 +120,7 @@ module QA
autoload :Repository, 'qa/page/project/settings/repository' autoload :Repository, 'qa/page/project/settings/repository'
autoload :CICD, 'qa/page/project/settings/ci_cd' autoload :CICD, 'qa/page/project/settings/ci_cd'
autoload :DeployKeys, 'qa/page/project/settings/deploy_keys' autoload :DeployKeys, 'qa/page/project/settings/deploy_keys'
autoload :SecretVariables, 'qa/page/project/settings/secret_variables'
autoload :Runners, 'qa/page/project/settings/runners' autoload :Runners, 'qa/page/project/settings/runners'
end end
end end
......
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
...@@ -9,6 +9,10 @@ module QA ...@@ -9,6 +9,10 @@ module QA
element :top_level_items, '.sidebar-top-level-items' element :top_level_items, '.sidebar-top-level-items'
end end
view 'app/assets/javascripts/fly_out_nav.js' do
element :fly_out, "classList.add('fly-out-list')"
end
def click_repository_settings def click_repository_settings
hover_settings do hover_settings do
within_submenu do within_submenu do
......
...@@ -7,6 +7,7 @@ module QA ...@@ -7,6 +7,7 @@ module QA
view 'app/views/projects/settings/ci_cd/show.html.haml' do view 'app/views/projects/settings/ci_cd/show.html.haml' do
element :runners_settings, 'Runners settings' element :runners_settings, 'Runners settings'
element :secret_variables, 'Secret variables'
end end
def expand_runners_settings(&block) def expand_runners_settings(&block)
...@@ -14,6 +15,12 @@ module QA ...@@ -14,6 +15,12 @@ module QA
Settings::Runners.perform(&block) Settings::Runners.perform(&block)
end end
end end
def expand_secret_variables(&block)
expand_section('Secret variables') do
Settings::SecretVariables.perform(&block)
end
end
end end
end end
end end
......
...@@ -17,7 +17,7 @@ module QA ...@@ -17,7 +17,7 @@ module QA
def expand_section(name) def expand_section(name)
page.within('#content-body') do page.within('#content-body') do
page.within('section', text: name) do page.within('section', text: name) do
click_button('Expand') click_button 'Expand' unless first('button', text: 'Collapse')
yield if block_given? yield if block_given?
end end
......
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
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
...@@ -1998,8 +1998,13 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -1998,8 +1998,13 @@ describe Gitlab::Git::Repository, seed_helper: true do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:imported_repo) { project.repository.raw } let(:imported_repo) { project.repository.raw }
before { expect(repository.bundle_to_disk(bundle_path)).to be true } before do
after { FileUtils.rm_rf(bundle_path) } 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 it 'creates a repo from a bundle file' do
expect(imported_repo).not_to exist expect(imported_repo).not_to exist
......
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