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

Merge branch 'qa-secret-variables-scenario' into tmp

* qa-secret-variables-scenario:
  Just don't expand if it's already expanded
  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
parent 6f22ec78
......@@ -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
......@@ -119,6 +120,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
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
......@@ -10,6 +10,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
......
......@@ -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
......
......@@ -17,7 +17,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 if block_given?
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
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