diff options
Diffstat (limited to 'spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js')
-rw-r--r-- | spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js b/spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js index 9508203e5c2..4a2e56c570d 100644 --- a/spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js +++ b/spec/frontend/ci_variable_list/ci_variable_list/ci_variable_list_spec.js @@ -1,5 +1,4 @@ import $ from 'jquery'; -import waitForPromises from 'helpers/wait_for_promises'; import VariableList from '~/ci_variable_list/ci_variable_list'; const HIDE_CLASS = 'hide'; @@ -7,7 +6,6 @@ const HIDE_CLASS = 'hide'; describe('VariableList', () => { preloadFixtures('pipeline_schedules/edit.html'); preloadFixtures('pipeline_schedules/edit_with_variables.html'); - preloadFixtures('projects/ci_cd_settings.html'); let $wrapper; let variableList; @@ -113,92 +111,6 @@ describe('VariableList', () => { }); }); - describe('with all inputs(key, value, protected)', () => { - beforeEach(() => { - loadFixtures('projects/ci_cd_settings.html'); - $wrapper = $('.js-ci-variable-list-section'); - - $wrapper.find('.js-ci-variable-input-protected').attr('data-default', 'false'); - - variableList = new VariableList({ - container: $wrapper, - formField: 'variables', - }); - variableList.init(); - }); - - it('should not add another row when editing the last rows protected checkbox', () => { - const $row = $wrapper.find('.js-row:last-child'); - $row.find('.ci-variable-protected-item .js-project-feature-toggle').click(); - - return waitForPromises().then(() => { - expect($wrapper.find('.js-row').length).toBe(1); - }); - }); - - it('should not add another row when editing the last rows masked checkbox', () => { - jest.spyOn(variableList, 'checkIfRowTouched'); - const $row = $wrapper.find('.js-row:last-child'); - $row.find('.ci-variable-masked-item .js-project-feature-toggle').click(); - - return waitForPromises().then(() => { - // This validates that we are checking after the event listener has run - expect(variableList.checkIfRowTouched).toHaveBeenCalled(); - expect($wrapper.find('.js-row').length).toBe(1); - }); - }); - - describe('validateMaskability', () => { - let $row; - - const maskingErrorElement = '.js-row:last-child .masking-validation-error'; - const clickToggle = () => - $row.find('.ci-variable-masked-item .js-project-feature-toggle').click(); - - beforeEach(() => { - $row = $wrapper.find('.js-row:last-child'); - }); - - it('has a regex provided via a data attribute', () => { - clickToggle(); - - expect($wrapper.attr('data-maskable-regex')).toBe('^[a-zA-Z0-9_+=/@:.-]{8,}$'); - }); - - it('allows values that are 8 characters long', () => { - $row.find('.js-ci-variable-input-value').val('looooong'); - - clickToggle(); - - expect($wrapper.find(maskingErrorElement)).toHaveClass('hide'); - }); - - it('rejects values that are shorter than 8 characters', () => { - $row.find('.js-ci-variable-input-value').val('short'); - - clickToggle(); - - expect($wrapper.find(maskingErrorElement)).toBeVisible(); - }); - - it('allows values with base 64 characters', () => { - $row.find('.js-ci-variable-input-value').val('abcABC123_+=/-'); - - clickToggle(); - - expect($wrapper.find(maskingErrorElement)).toHaveClass('hide'); - }); - - it('rejects values with other special characters', () => { - $row.find('.js-ci-variable-input-value').val('1234567$'); - - clickToggle(); - - expect($wrapper.find(maskingErrorElement)).toBeVisible(); - }); - }); - }); - describe('toggleEnableRow method', () => { beforeEach(() => { loadFixtures('pipeline_schedules/edit_with_variables.html'); @@ -247,36 +159,4 @@ describe('VariableList', () => { expect($wrapper.find('.js-ci-variable-input-key:not([disabled])').length).toBe(3); }); }); - - describe('hideValues', () => { - beforeEach(() => { - loadFixtures('projects/ci_cd_settings.html'); - $wrapper = $('.js-ci-variable-list-section'); - - variableList = new VariableList({ - container: $wrapper, - formField: 'variables', - }); - variableList.init(); - }); - - it('should hide value input and show placeholder stars', () => { - const $row = $wrapper.find('.js-row'); - const $inputValue = $row.find('.js-ci-variable-input-value'); - const $placeholder = $row.find('.js-secret-value-placeholder'); - - $row - .find('.js-ci-variable-input-value') - .val('foo') - .trigger('input'); - - expect($placeholder.hasClass(HIDE_CLASS)).toBe(true); - expect($inputValue.hasClass(HIDE_CLASS)).toBe(false); - - variableList.hideValues(); - - expect($placeholder.hasClass(HIDE_CLASS)).toBe(false); - expect($inputValue.hasClass(HIDE_CLASS)).toBe(true); - }); - }); }); |