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

Add a scenario for adding secret variables

parent 68cc9ea2
......@@ -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
......
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
......@@ -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
......
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
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
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
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