diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-16 18:10:52 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-16 18:10:52 +0300 |
commit | 0552020767452da44de2bf5424096f2cb2ea6bf5 (patch) | |
tree | 9579d9f0ad3c730c33883130ec23420e80d1c5dc /spec/frontend/ci_variable_list | |
parent | e3748b81ca29b24197276767e245158d8f84fda3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ci_variable_list')
6 files changed, 75 insertions, 22 deletions
diff --git a/spec/frontend/ci_variable_list/components/ci_admin_variables_spec.js b/spec/frontend/ci_variable_list/components/ci_admin_variables_spec.js index c80e1184f02..c7375acd8e5 100644 --- a/spec/frontend/ci_variable_list/components/ci_admin_variables_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_admin_variables_spec.js @@ -24,6 +24,7 @@ describe('Ci Project Variable wrapper', () => { expect(findCiShared().props()).toEqual({ areScopedVariablesAvailable: false, componentName: 'InstanceVariables', + hideEnvironmentScope: true, mutationData: wrapper.vm.$options.mutationData, queryData: wrapper.vm.$options.queryData, refetchAfterMutation: true, diff --git a/spec/frontend/ci_variable_list/components/ci_group_variables_spec.js b/spec/frontend/ci_variable_list/components/ci_group_variables_spec.js index 525cba3424b..ef5a86ccb61 100644 --- a/spec/frontend/ci_variable_list/components/ci_group_variables_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_group_variables_spec.js @@ -40,6 +40,7 @@ describe('Ci Group Variable wrapper', () => { areScopedVariablesAvailable: false, componentName: 'GroupVariables', fullPath: mockProvide.groupPath, + hideEnvironmentScope: false, mutationData: wrapper.vm.$options.mutationData, queryData: wrapper.vm.$options.queryData, refetchAfterMutation: false, diff --git a/spec/frontend/ci_variable_list/components/ci_project_variables_spec.js b/spec/frontend/ci_variable_list/components/ci_project_variables_spec.js index 984baa45d91..97051325f59 100644 --- a/spec/frontend/ci_variable_list/components/ci_project_variables_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_project_variables_spec.js @@ -36,6 +36,7 @@ describe('Ci Project Variable wrapper', () => { areScopedVariablesAvailable: true, componentName: 'ProjectVariables', fullPath: mockProvide.projectFullPath, + hideEnvironmentScope: false, mutationData: wrapper.vm.$options.mutationData, queryData: wrapper.vm.$options.queryData, refetchAfterMutation: false, 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 1ea4e4f833b..e4771f040d1 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 @@ -39,6 +39,7 @@ describe('Ci variable modal', () => { const defaultProps = { areScopedVariablesAvailable: true, environments: [], + hideEnvironmentScope: false, mode: ADD_VARIABLE_ACTION, selectedVariable: {}, variable: [], @@ -75,6 +76,7 @@ describe('Ci variable modal', () => { const findEnvScopeInput = () => wrapper.findByTestId('environment-scope').findComponent(GlFormInput); const findVariableTypeDropdown = () => wrapper.find('#ci-variable-type'); + const findEnvironmentScopeText = () => wrapper.findByText('Environment scope'); afterEach(() => { wrapper.destroy(); @@ -250,39 +252,83 @@ describe('Ci variable modal', () => { describe('Environment scope', () => { describe('when feature is available', () => { - it('renders the environment dropdown', () => { - createComponent({ - mountFn: mountExtended, - props: { - areScopedVariablesAvailable: true, - }, + describe('and section is not hidden', () => { + beforeEach(() => { + createComponent({ + mountFn: mountExtended, + props: { + areScopedVariablesAvailable: true, + hideEnvironmentScope: false, + }, + }); }); - expect(findCiEnvironmentsDropdown().exists()).toBe(true); - expect(findCiEnvironmentsDropdown().isVisible()).toBe(true); - }); + it('renders the environment dropdown and section title', () => { + expect(findCiEnvironmentsDropdown().exists()).toBe(true); + expect(findCiEnvironmentsDropdown().isVisible()).toBe(true); + expect(findEnvironmentScopeText().exists()).toBe(true); + }); - it('renders a link to documentation on scopes', () => { - createComponent({ mountFn: mountExtended }); + it('renders a link to documentation on scopes', () => { + const link = findEnvScopeLink(); + + expect(link.attributes('title')).toBe(ENVIRONMENT_SCOPE_LINK_TITLE); + expect(link.attributes('href')).toBe(defaultProvide.environmentScopeLink); + }); + }); - const link = findEnvScopeLink(); + describe('and section is hidden', () => { + beforeEach(() => { + createComponent({ + mountFn: mountExtended, + props: { + areScopedVariablesAvailable: true, + hideEnvironmentScope: true, + }, + }); + }); - expect(link.attributes('title')).toBe(ENVIRONMENT_SCOPE_LINK_TITLE); - expect(link.attributes('href')).toBe(defaultProvide.environmentScopeLink); + it('does not renders the environment dropdown and section title', () => { + expect(findCiEnvironmentsDropdown().exists()).toBe(false); + expect(findEnvironmentScopeText().exists()).toBe(false); + }); }); }); describe('when feature is not available', () => { - it('disables the dropdown', () => { - createComponent({ - mountFn: mountExtended, - props: { - areScopedVariablesAvailable: false, - }, + describe('and section is not hidden', () => { + beforeEach(() => { + createComponent({ + mountFn: mountExtended, + props: { + areScopedVariablesAvailable: false, + hideEnvironmentScope: false, + }, + }); }); - expect(findCiEnvironmentsDropdown().exists()).toBe(false); - expect(findEnvScopeInput().attributes('readonly')).toBe('readonly'); + it('disables the dropdown', () => { + expect(findCiEnvironmentsDropdown().exists()).toBe(false); + expect(findEnvironmentScopeText().exists()).toBe(true); + expect(findEnvScopeInput().attributes('readonly')).toBe('readonly'); + }); + }); + + describe('and section is hidden', () => { + beforeEach(() => { + createComponent({ + mountFn: mountExtended, + props: { + areScopedVariablesAvailable: false, + hideEnvironmentScope: true, + }, + }); + }); + + it('hides the dropdown', () => { + expect(findEnvironmentScopeText().exists()).toBe(false); + expect(findCiEnvironmentsDropdown().exists()).toBe(false); + }); }); }); }); diff --git a/spec/frontend/ci_variable_list/components/ci_variable_settings_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_settings_spec.js index 5c77ce71b41..8b5a0f7ae9d 100644 --- a/spec/frontend/ci_variable_list/components/ci_variable_settings_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_variable_settings_spec.js @@ -18,6 +18,7 @@ describe('Ci variable table', () => { const defaultProps = { areScopedVariablesAvailable: true, environments: mapEnvironmentNames(mockEnvs), + hideEnvironmentScope: false, isLoading: false, variables: mockVariablesWithScopes(projectString), }; @@ -56,6 +57,7 @@ describe('Ci variable table', () => { expect(findCiVariableModal().props()).toEqual({ areScopedVariablesAvailable: defaultProps.areScopedVariablesAvailable, environments: defaultProps.environments, + hideEnvironmentScope: defaultProps.hideEnvironmentScope, variables: defaultProps.variables, mode: ADD_VARIABLE_ACTION, selectedVariable: {}, diff --git a/spec/frontend/ci_variable_list/components/ci_variable_shared_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_shared_spec.js index 78c0bd2aa1f..0cc0ee7a9c7 100644 --- a/spec/frontend/ci_variable_list/components/ci_variable_shared_spec.js +++ b/spec/frontend/ci_variable_list/components/ci_variable_shared_spec.js @@ -48,6 +48,7 @@ const mockProvide = { const defaultProps = { areScopedVariablesAvailable: true, + hideEnvironmentScope: false, refetchAfterMutation: false, }; @@ -318,6 +319,7 @@ describe('Ci Variable Shared Component', () => { expect(findCiSettings().props()).toEqual({ areScopedVariablesAvailable: wrapper.props().areScopedVariablesAvailable, + hideEnvironmentScope: defaultProps.hideEnvironmentScope, isLoading: false, variables: wrapper.props().queryData.ciVariables.lookup(mockVariablesValue.data)?.nodes, environments: expectedEnvironments, |