Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-03-28 00:42:23 +0300
committerKamil Trzciński <ayufan@ayufan.eu>2019-03-28 00:42:23 +0300
commit89fdf64c8a3764cf8c646cb4b9eb9b11a3871eae (patch)
tree8b31028a23cbb3a8b39375b3992f7423b3d5705f /spec
parent1b26f3c536682b8989710e70aeb702f76cad9b92 (diff)
Revert "Merge branch '13784-validate-variables-for-masking' into 'master'"
This reverts merge request !25476
Diffstat (limited to 'spec')
-rw-r--r--spec/features/group_variables_spec.rb2
-rw-r--r--spec/features/project_variables_spec.rb2
-rw-r--r--spec/fixtures/api/schemas/variable.json2
-rw-r--r--spec/javascripts/ci_variable_list/ci_variable_list_spec.js19
-rw-r--r--spec/support/features/variable_list_shared_examples.rb123
5 files changed, 39 insertions, 109 deletions
diff --git a/spec/features/group_variables_spec.rb b/spec/features/group_variables_spec.rb
index fc5777e8c7c..1a53e7c9512 100644
--- a/spec/features/group_variables_spec.rb
+++ b/spec/features/group_variables_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'Group variables', :js do
let(:user) { create(:user) }
let(:group) { create(:group) }
- let!(:variable) { create(:ci_group_variable, key: 'test_key', value: 'test_value', masked: true, group: group) }
+ let!(:variable) { create(:ci_group_variable, key: 'test_key', value: 'test_value', group: group) }
let(:page_path) { group_settings_ci_cd_path(group) }
before do
diff --git a/spec/features/project_variables_spec.rb b/spec/features/project_variables_spec.rb
index 76abc640077..6bdf5df1036 100644
--- a/spec/features/project_variables_spec.rb
+++ b/spec/features/project_variables_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
describe 'Project variables', :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:variable) { create(:ci_variable, key: 'test_key', value: 'test_value', masked: true) }
+ let(:variable) { create(:ci_variable, key: 'test_key', value: 'test_value') }
let(:page_path) { project_settings_ci_cd_path(project) }
before do
diff --git a/spec/fixtures/api/schemas/variable.json b/spec/fixtures/api/schemas/variable.json
index 305071a6b3f..6f6b044115b 100644
--- a/spec/fixtures/api/schemas/variable.json
+++ b/spec/fixtures/api/schemas/variable.json
@@ -4,14 +4,12 @@
"id",
"key",
"value",
- "masked",
"protected"
],
"properties": {
"id": { "type": "integer" },
"key": { "type": "string" },
"value": { "type": "string" },
- "masked": { "type": "boolean" },
"protected": { "type": "boolean" },
"environment_scope": { "type": "string", "optional": true }
},
diff --git a/spec/javascripts/ci_variable_list/ci_variable_list_spec.js b/spec/javascripts/ci_variable_list/ci_variable_list_spec.js
index 394e60fc22c..70f49469300 100644
--- a/spec/javascripts/ci_variable_list/ci_variable_list_spec.js
+++ b/spec/javascripts/ci_variable_list/ci_variable_list_spec.js
@@ -127,25 +127,20 @@ describe('VariableList', () => {
variableList.init();
});
- it('should not add another row when editing the last rows protected checkbox', done => {
+ it('should add another row when editing the last rows protected checkbox', done => {
const $row = $wrapper.find('.js-row:last-child');
$row.find('.ci-variable-protected-item .js-project-feature-toggle').click();
getSetTimeoutPromise()
.then(() => {
- expect($wrapper.find('.js-row').length).toBe(1);
- })
- .then(done)
- .catch(done.fail);
- });
+ expect($wrapper.find('.js-row').length).toBe(2);
- it('should not add another row when editing the last rows masked checkbox', done => {
- const $row = $wrapper.find('.js-row:last-child');
- $row.find('.ci-variable-masked-item .js-project-feature-toggle').click();
+ // Check for the correct default in the new row
+ const $protectedInput = $wrapper
+ .find('.js-row:last-child')
+ .find('.js-ci-variable-input-protected');
- getSetTimeoutPromise()
- .then(() => {
- expect($wrapper.find('.js-row').length).toBe(1);
+ expect($protectedInput.val()).toBe('false');
})
.then(done)
.catch(done.fail);
diff --git a/spec/support/features/variable_list_shared_examples.rb b/spec/support/features/variable_list_shared_examples.rb
index 693b796fbdc..73156d18c1b 100644
--- a/spec/support/features/variable_list_shared_examples.rb
+++ b/spec/support/features/variable_list_shared_examples.rb
@@ -23,13 +23,10 @@ shared_examples 'variable list' do
end
end
- it 'adds a new protected variable' do
+ it 'adds empty variable' do
page.within('.js-ci-variable-list-section .js-row:last-child') do
find('.js-ci-variable-input-key').set('key')
- find('.js-ci-variable-input-value').set('key_value')
- find('.ci-variable-protected-item .js-project-feature-toggle').click
-
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('true')
+ find('.js-ci-variable-input-value').set('')
end
click_button('Save variables')
@@ -40,17 +37,17 @@ shared_examples 'variable list' do
# We check the first row because it re-sorts to alphabetical order on refresh
page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
expect(find('.js-ci-variable-input-key').value).to eq('key')
- expect(find('.js-ci-variable-input-value', visible: false).value).to eq('key_value')
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('true')
+ expect(find('.js-ci-variable-input-value', visible: false).value).to eq('')
end
end
- it 'defaults to masked' do
+ it 'adds new protected variable' do
page.within('.js-ci-variable-list-section .js-row:last-child') do
find('.js-ci-variable-input-key').set('key')
find('.js-ci-variable-input-value').set('key_value')
+ find('.ci-variable-protected-item .js-project-feature-toggle').click
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('true')
+ expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('true')
end
click_button('Save variables')
@@ -62,7 +59,7 @@ shared_examples 'variable list' do
page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
expect(find('.js-ci-variable-input-key').value).to eq('key')
expect(find('.js-ci-variable-input-value', visible: false).value).to eq('key_value')
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('true')
+ expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('true')
end
end
@@ -166,6 +163,27 @@ shared_examples 'variable list' do
end
end
+ it 'edits variable with empty value' do
+ page.within('.js-ci-variable-list-section') do
+ click_button('Reveal value')
+
+ page.within('.js-row:nth-child(1)') do
+ find('.js-ci-variable-input-key').set('new_key')
+ find('.js-ci-variable-input-value').set('')
+ end
+
+ click_button('Save variables')
+ wait_for_requests
+
+ visit page_path
+
+ page.within('.js-row:nth-child(1)') do
+ expect(find('.js-ci-variable-input-key').value).to eq('new_key')
+ expect(find('.js-ci-variable-input-value', visible: false).value).to eq('')
+ end
+ end
+ end
+
it 'edits variable to be protected' do
# Create the unprotected variable
page.within('.js-ci-variable-list-section .js-row:last-child') do
@@ -233,57 +251,6 @@ shared_examples 'variable list' do
end
end
- it 'edits variable to be unmasked' do
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('true')
-
- find('.ci-variable-masked-item .js-project-feature-toggle').click
-
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('false')
- end
-
- click_button('Save variables')
- wait_for_requests
-
- visit page_path
-
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('false')
- end
- end
-
- it 'edits variable to be masked' do
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('true')
-
- find('.ci-variable-masked-item .js-project-feature-toggle').click
-
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('false')
- end
-
- click_button('Save variables')
- wait_for_requests
-
- visit page_path
-
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('false')
-
- find('.ci-variable-masked-item .js-project-feature-toggle').click
-
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('true')
- end
-
- click_button('Save variables')
- wait_for_requests
-
- visit page_path
-
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-masked', visible: false).value).to eq('true')
- end
- end
-
it 'handles multiple edits and deletion in the middle' do
page.within('.js-ci-variable-list-section') do
# Create 2 variables
@@ -330,11 +297,11 @@ shared_examples 'variable list' do
it 'shows validation error box about duplicate keys' do
page.within('.js-ci-variable-list-section .js-row:last-child') do
find('.js-ci-variable-input-key').set('samekey')
- find('.js-ci-variable-input-value').set('value123')
+ find('.js-ci-variable-input-value').set('value1')
end
page.within('.js-ci-variable-list-section .js-row:last-child') do
find('.js-ci-variable-input-key').set('samekey')
- find('.js-ci-variable-input-value').set('value456')
+ find('.js-ci-variable-input-value').set('value2')
end
click_button('Save variables')
@@ -347,34 +314,4 @@ shared_examples 'variable list' do
expect(find('.js-ci-variable-error-box')).to have_content(/Validation failed Variables have duplicate values \(.+\)/)
end
end
-
- it 'shows validation error box about empty values' do
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('empty_value')
- find('.js-ci-variable-input-value').set('')
- end
-
- click_button('Save variables')
- wait_for_requests
-
- page.within('.js-ci-variable-list-section') do
- expect(all('.js-ci-variable-error-box ul li').count).to eq(1)
- expect(find('.js-ci-variable-error-box')).to have_content(/Validation failed Variables value is invalid/)
- end
- end
-
- it 'shows validation error box about unmaskable values' do
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('unmaskable_value')
- find('.js-ci-variable-input-value').set('???')
- end
-
- click_button('Save variables')
- wait_for_requests
-
- page.within('.js-ci-variable-list-section') do
- expect(all('.js-ci-variable-error-box ul li').count).to eq(1)
- expect(find('.js-ci-variable-error-box')).to have_content(/Validation failed Variables value is invalid/)
- end
- end
end