2019-05-23 14:07:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-16 16:13:14 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Project variables', :js do
|
2018-01-16 16:13:14 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project) }
|
2019-03-29 11:46:31 -04:00
|
|
|
let(:variable) { create(:ci_variable, key: 'test_key', value: 'test_value', masked: true) }
|
2018-01-16 16:13:14 -05:00
|
|
|
let(:page_path) { project_settings_ci_cd_path(project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2018-01-16 16:13:14 -05:00
|
|
|
project.variables << variable
|
|
|
|
end
|
|
|
|
|
2022-06-16 05:09:15 -04:00
|
|
|
context 'with disabled ff `ci_variable_settings_graphql' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(ci_variable_settings_graphql: false)
|
|
|
|
visit page_path
|
|
|
|
end
|
2019-08-08 14:51:52 -04:00
|
|
|
|
2022-06-16 05:09:15 -04:00
|
|
|
it_behaves_like 'variable list'
|
2019-08-08 14:51:52 -04:00
|
|
|
|
2022-06-16 05:09:15 -04:00
|
|
|
it 'adds a new variable with an environment scope' do
|
2020-10-27 11:08:39 -04:00
|
|
|
click_button('Add variable')
|
2019-08-08 14:51:52 -04:00
|
|
|
|
2022-06-16 05:09:15 -04:00
|
|
|
page.within('#add-ci-variable') do
|
|
|
|
fill_in 'Key', with: 'akey'
|
|
|
|
find('#ci-variable-value').set('akey_value')
|
|
|
|
find('[data-testid="environment-scope"]').click
|
|
|
|
find('[data-testid="ci-environment-search"]').set('review/*')
|
|
|
|
find('[data-testid="create-wildcard-button"]').click
|
|
|
|
|
|
|
|
click_button('Add variable')
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
2019-08-08 14:51:52 -04:00
|
|
|
|
2022-06-16 05:09:15 -04:00
|
|
|
page.within('[data-testid="ci-variable-table"]') do
|
|
|
|
expect(find('.js-ci-variable-row:first-child [data-label="Environments"]').text).to eq('review/*')
|
|
|
|
end
|
2019-08-08 14:51:52 -04:00
|
|
|
end
|
|
|
|
end
|
2022-08-19 05:11:29 -04:00
|
|
|
|
|
|
|
context 'with enabled ff `ci_variable_settings_graphql' do
|
|
|
|
before do
|
|
|
|
visit page_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'variable list'
|
|
|
|
|
|
|
|
it 'adds a new variable with an environment scope' do
|
|
|
|
click_button('Add variable')
|
|
|
|
|
|
|
|
page.within('#add-ci-variable') do
|
|
|
|
fill_in 'Key', with: 'akey'
|
|
|
|
find('#ci-variable-value').set('akey_value')
|
|
|
|
find('[data-testid="environment-scope"]').click
|
|
|
|
find('[data-testid="ci-environment-search"]').set('review/*')
|
|
|
|
find('[data-testid="create-wildcard-button"]').click
|
|
|
|
|
|
|
|
click_button('Add variable')
|
|
|
|
end
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
page.within('[data-testid="ci-variable-table"]') do
|
|
|
|
expect(find('.js-ci-variable-row:first-child [data-label="Environments"]').text).to eq('review/*')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-01-16 16:13:14 -05:00
|
|
|
end
|