diff options
Diffstat (limited to 'spec/frontend/environments/environments_detail_header_spec.js')
-rw-r--r-- | spec/frontend/environments/environments_detail_header_spec.js | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/spec/frontend/environments/environments_detail_header_spec.js b/spec/frontend/environments/environments_detail_header_spec.js index 1f233c05fbf..9464aeff028 100644 --- a/spec/frontend/environments/environments_detail_header_spec.js +++ b/spec/frontend/environments/environments_detail_header_spec.js @@ -1,12 +1,11 @@ import { GlSprintf } from '@gitlab/ui'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; -import { __, s__ } from '~/locale'; import DeleteEnvironmentModal from '~/environments/components/delete_environment_modal.vue'; import EnvironmentsDetailHeader from '~/environments/components/environments_detail_header.vue'; import StopEnvironmentModal from '~/environments/components/stop_environment_modal.vue'; import TimeAgo from '~/vue_shared/components/time_ago_tooltip.vue'; -import ModalCopyButton from '~/vue_shared/components/modal_copy_button.vue'; +import DeployFreezeAlert from '~/environments/components/deploy_freeze_alert.vue'; import { createEnvironment } from './mock_data'; describe('Environments detail header component', () => { @@ -22,13 +21,14 @@ describe('Environments detail header component', () => { const findCancelAutoStopAtButton = () => wrapper.findByTestId('cancel-auto-stop-button'); const findCancelAutoStopAtForm = () => wrapper.findByTestId('cancel-auto-stop-form'); const findTerminalButton = () => wrapper.findByTestId('terminal-button'); - const findExternalUrlButton = () => wrapper.findByTestId('external-url-button'); + const findExternalUrlButton = () => wrapper.findComponentByTestId('external-url-button'); const findMetricsButton = () => wrapper.findByTestId('metrics-button'); const findEditButton = () => wrapper.findByTestId('edit-button'); const findStopButton = () => wrapper.findByTestId('stop-button'); const findDestroyButton = () => wrapper.findByTestId('destroy-button'); const findStopEnvironmentModal = () => wrapper.findComponent(StopEnvironmentModal); const findDeleteEnvironmentModal = () => wrapper.findComponent(DeleteEnvironmentModal); + const findDeployFreezeAlert = () => wrapper.findComponent(DeployFreezeAlert); const buttons = [ ['Cancel Auto Stop At', findCancelAutoStopAtButton], @@ -40,14 +40,17 @@ describe('Environments detail header component', () => { ['Destroy', findDestroyButton], ]; - const createWrapper = ({ props }) => { + const createWrapper = ({ props, glFeatures = {} }) => { wrapper = shallowMountExtended(EnvironmentsDetailHeader, { stubs: { GlSprintf, TimeAgo, }, + provide: { + glFeatures, + }, directives: { - GlTooltip: createMockDirective(), + GlTooltip: createMockDirective('gl-tooltip'), }, propsData: { canAdminEnvironment: false, @@ -59,10 +62,6 @@ describe('Environments detail header component', () => { }); }; - afterEach(() => { - wrapper.destroy(); - }); - describe('default state with minimal access', () => { beforeEach(() => { createWrapper({ props: { environment: createEnvironment({ externalUrl: null }) } }); @@ -175,6 +174,7 @@ describe('Environments detail header component', () => { it('displays the external url button with correct path', () => { expect(findExternalUrlButton().attributes('href')).toBe(externalUrl); + expect(findExternalUrlButton().props('isUnsafeLink')).toBe(true); }); }); @@ -199,6 +199,25 @@ describe('Environments detail header component', () => { expect(tooltip).toBeDefined(); expect(button.attributes('title')).toBe('See metrics'); }); + + describe.each([true, false])( + 'and `remove_monitor_metrics` flag is %p', + (removeMonitorMetrics) => { + beforeEach(() => { + createWrapper({ + props: { + environment: createEnvironment({ metricsUrl: 'my metrics url' }), + metricsPath, + }, + glFeatures: { removeMonitorMetrics }, + }); + }); + + it(`${removeMonitorMetrics ? 'does not render' : 'renders'} Metrics button`, () => { + expect(findMetricsButton().exists()).toBe(!removeMonitorMetrics); + }); + }, + ); }); describe('when has all admin rights', () => { @@ -246,22 +265,12 @@ describe('Environments detail header component', () => { }); }); - describe('when the environment has an unsafe external url', () => { - const externalUrl = 'postgres://staging'; - - beforeEach(() => { - createWrapper({ - props: { - environment: createEnvironment({ externalUrl }), - }, - }); - }); + describe('deploy freeze alert', () => { + it('passes the environment name to the alert', () => { + const environment = createEnvironment(); + createWrapper({ props: { environment } }); - it('should show a copy button instead', () => { - const button = wrapper.findComponent(ModalCopyButton); - expect(button.props('title')).toBe(s__('Environments|Copy live environment URL')); - expect(button.props('text')).toBe(externalUrl); - expect(button.text()).toBe(__('Copy URL')); + expect(findDeployFreezeAlert().props('name')).toBe(environment.name); }); }); }); |