diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 18:09:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-13 18:09:21 +0300 |
commit | c36152ff8c41fad2f413f253eb7ac5c927e47c56 (patch) | |
tree | bbf300da207de3e8bbf272d44111ceedb18f5833 /spec/frontend/ci_variable_list | |
parent | 286fe61013674fe2d245ffc8d2233baf09923e70 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ci_variable_list')
6 files changed, 82 insertions, 24 deletions
diff --git a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js index be2c017cc7e..8db6626fca3 100644 --- a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js @@ -35,10 +35,6 @@ describe('Ci variable modal', () => { expect(findModal().props('actionPrimary').attributes.disabled).toBeTruthy(); }); - it('masked checkbox is disabled when value does not meet regex requirements', () => { - expect(wrapper.find({ ref: 'masked-ci-variable' }).attributes('disabled')).toBeTruthy(); - }); - describe('Adding a new variable', () => { beforeEach(() => { const [variable] = mockData.mockVariables; @@ -49,13 +45,6 @@ describe('Ci variable modal', () => { expect(findModal().props('actionPrimary').attributes.disabled).toBeFalsy(); }); - it('masked checkbox is enabled when value meets regex requirements', () => { - store.state.maskableRegex = '^[a-zA-Z0-9_+=/@:-]{8,}$'; - return wrapper.vm.$nextTick(() => { - expect(wrapper.find({ ref: 'masked-ci-variable' }).attributes('disabled')).toBeFalsy(); - }); - }); - it('Add variable button dispatches addVariable action', () => { findModal().vm.$emit('ok'); expect(store.dispatch).toHaveBeenCalledWith('addVariable'); @@ -74,7 +63,7 @@ describe('Ci variable modal', () => { }); it('button text is Update variable when updating', () => { - expect(wrapper.vm.modalActionText).toBe('Update Variable'); + expect(wrapper.vm.modalActionText).toBe('Update variable'); }); it('Update variable button dispatches updateVariable with correct variable', () => { @@ -89,5 +78,10 @@ describe('Ci variable modal', () => { findModal().vm.$emit('hidden'); expect(store.dispatch).toHaveBeenCalledWith('resetEditing'); }); + + it('dispatches deleteVariable with correct variable to delete', () => { + findModal().vm.$emit('secondary'); + expect(store.dispatch).toHaveBeenCalledWith('deleteVariable', mockData.mockVariables[0]); + }); }); }); diff --git a/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js new file mode 100644 index 00000000000..5d37f059161 --- /dev/null +++ b/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js @@ -0,0 +1,48 @@ +import { shallowMount } from '@vue/test-utils'; +import { GlButton } from '@gitlab/ui'; +import CiVariablePopover from '~/ci_variable_list/components/ci_variable_popover.vue'; +import mockData from '../services/mock_data'; + +describe('Ci Variable Popover', () => { + let wrapper; + + const defaultProps = { + target: 'ci-variable-value-22', + value: mockData.mockPemCert, + tooltipText: 'Copy value', + }; + + const createComponent = (props = defaultProps) => { + wrapper = shallowMount(CiVariablePopover, { + propsData: { ...props }, + }); + }; + + const findButton = () => wrapper.find(GlButton); + + beforeEach(() => { + createComponent(); + }); + + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + it('displays max count plus ... when character count is over 95', () => { + expect(wrapper.text()).toHaveLength(98); + }); + + it('copies full value to clipboard', () => { + expect(findButton().attributes('data-clipboard-text')).toEqual(mockData.mockPemCert); + }); + + it('displays full value when count is less than max count', () => { + createComponent({ + target: 'ci-variable-value-22', + value: 'test_variable_value', + tooltipText: 'Copy value', + }); + expect(wrapper.text()).toEqual('test_variable_value'); + }); +}); diff --git a/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js index 973a9c51f16..36aeffe7798 100644 --- a/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js @@ -17,12 +17,12 @@ describe('Ci variable table', () => { store.state.isGroup = true; jest.spyOn(store, 'dispatch').mockImplementation(); wrapper = mount(CiVariableTable, { + attachToDocument: true, localVue, store, }); }; - const findDeleteButton = () => wrapper.find({ ref: 'delete-ci-variable' }); const findRevealButton = () => wrapper.find({ ref: 'secret-value-reveal-button' }); const findEditButton = () => wrapper.find({ ref: 'edit-ci-variable' }); const findEmptyVariablesPlaceholder = () => wrapper.find({ ref: 'empty-variables' }); @@ -71,11 +71,6 @@ describe('Ci variable table', () => { store.state.variables = mockData.mockVariables; }); - it('dispatches deleteVariable with correct variable to delete', () => { - findDeleteButton().trigger('click'); - expect(store.dispatch).toHaveBeenCalledWith('deleteVariable', mockData.mockVariables[0]); - }); - it('reveals secret values when button is clicked', () => { findRevealButton().trigger('click'); expect(store.dispatch).toHaveBeenCalledWith('toggleValues', false); diff --git a/spec/frontend/ci_variable_list/services/mock_data.js b/spec/frontend/ci_variable_list/services/mock_data.js index b04cd223d42..5e0fa55a20c 100644 --- a/spec/frontend/ci_variable_list/services/mock_data.js +++ b/spec/frontend/ci_variable_list/services/mock_data.js @@ -6,8 +6,9 @@ export default { key: 'test_var', masked: false, protected: false, + secret_value: 'test_val', value: 'test_val', - variable_type: 'Variable', + variable_type: 'Var', }, ], @@ -18,6 +19,7 @@ export default { key: 'test_var', masked: false, protected: false, + secret_value: 'test_val', value: 'test_val', variable_type: 'env_var', }, @@ -27,6 +29,7 @@ export default { key: 'test_var_2', masked: false, protected: false, + secret_value: 'test_val_2', value: 'test_val_2', variable_type: 'file', }, @@ -34,20 +37,22 @@ export default { mockVariablesDisplay: [ { - environment_scope: 'All environments', + environment_scope: 'All', id: 113, key: 'test_var', masked: false, protected: false, + secret_value: 'test_val', value: 'test_val', - variable_type: 'Variable', + variable_type: 'Var', }, { - environment_scope: 'All environments', + environment_scope: 'All', id: 114, key: 'test_var_2', masked: false, protected: false, + secret_value: 'test_val_2', value: 'test_val_2', variable_type: 'File', }, @@ -69,4 +74,18 @@ export default { state: 'available', }, ], + + mockPemCert: `-----BEGIN CERTIFICATE REQUEST----- + MIIB9TCCAWACAQAwgbgxGTAXBgNVBAoMEFF1b1ZhZGlzIExpbWl0ZWQxHDAaBgNV + BAsME0RvY3VtZW50IERlcGFydG1lbnQxOTA3BgNVBAMMMFdoeSBhcmUgeW91IGRl + Y29kaW5nIG1lPyAgVGhpcyBpcyBvbmx5IGEgdGVzdCEhITERMA8GA1UEBwwISGFt + aWx0b24xETAPBgNVBAgMCFBlbWJyb2tlMQswCQYDVQQGEwJCTTEPMA0GCSqGSIb3 + DQEJARYAMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCJ9WRanG/fUvcfKiGl + EL4aRLjGt537mZ28UU9/3eiJeJznNSOuNLnF+hmabAu7H0LT4K7EdqfF+XUZW/2j + RKRYcvOUDGF9A7OjW7UfKk1In3+6QDCi7X34RE161jqoaJjrm/T18TOKcgkkhRzE + apQnIDm0Ea/HVzX/PiSOGuertwIDAQABMAsGCSqGSIb3DQEBBQOBgQBzMJdAV4QP + Awel8LzGx5uMOshezF/KfP67wJ93UW+N7zXY6AwPgoLj4Kjw+WtU684JL8Dtr9FX + ozakE+8p06BpxegR4BR3FMHf6p+0jQxUEAkAyb/mVgm66TyghDGC6/YkiKoZptXQ + 98TwDIK/39WEB/V607As+KoYazQG8drorw== + -----END CERTIFICATE REQUEST-----`, }; diff --git a/spec/frontend/ci_variable_list/store/mutations_spec.js b/spec/frontend/ci_variable_list/store/mutations_spec.js index 1bb34e88cf5..05513edff7b 100644 --- a/spec/frontend/ci_variable_list/store/mutations_spec.js +++ b/spec/frontend/ci_variable_list/store/mutations_spec.js @@ -48,12 +48,12 @@ describe('CI variable list mutations', () => { describe('CLEAR_MODAL', () => { it('should clear modal state ', () => { const modalState = { - variable_type: 'Variable', + variable_type: 'Var', key: '', secret_value: '', protected: false, masked: false, - environment_scope: 'All environments', + environment_scope: 'All', }; mutations[types.CLEAR_MODAL](stateCopy); diff --git a/spec/frontend/ci_variable_list/store/utils_spec.js b/spec/frontend/ci_variable_list/store/utils_spec.js index 070bc996d75..5b10370324a 100644 --- a/spec/frontend/ci_variable_list/store/utils_spec.js +++ b/spec/frontend/ci_variable_list/store/utils_spec.js @@ -19,6 +19,7 @@ describe('CI variables store utils', () => { key: 'test_var', masked: 'false', protected: 'false', + secret_value: 'test_val', value: 'test_val', variable_type: 'env_var', }); @@ -29,6 +30,7 @@ describe('CI variables store utils', () => { key: 'test_var_2', masked: 'false', protected: 'false', + secret_value: 'test_val_2', value: 'test_val_2', variable_type: 'file', }); |