diff options
Diffstat (limited to 'spec/frontend/security_configuration')
-rw-r--r-- | spec/frontend/security_configuration/components/app_spec.js | 43 | ||||
-rw-r--r-- | spec/frontend/security_configuration/components/feature_card_spec.js | 11 |
2 files changed, 51 insertions, 3 deletions
diff --git a/spec/frontend/security_configuration/components/app_spec.js b/spec/frontend/security_configuration/components/app_spec.js index f27f45f2b26..d4ee9e6e43d 100644 --- a/spec/frontend/security_configuration/components/app_spec.js +++ b/spec/frontend/security_configuration/components/app_spec.js @@ -1,5 +1,6 @@ import { GlTab } from '@gitlab/ui'; import { mount } from '@vue/test-utils'; +import { nextTick } from 'vue'; import { useLocalStorageSpy } from 'helpers/local_storage_helper'; import { makeMockUserCalloutDismisser } from 'helpers/mock_user_callout_dismisser'; import stubChildren from 'helpers/stub_children'; @@ -70,6 +71,7 @@ describe('App component', () => { const findTabs = () => wrapper.findAllComponents(GlTab); const findByTestId = (id) => wrapper.findByTestId(id); const findFeatureCards = () => wrapper.findAllComponents(FeatureCard); + const findManageViaMRErrorAlert = () => wrapper.findByTestId('manage-via-mr-error-alert'); const findLink = ({ href, text, container = wrapper }) => { const selector = `a[href="${href}"]`; const link = container.find(selector); @@ -132,12 +134,12 @@ describe('App component', () => { it('renders main-heading with correct text', () => { const mainHeading = findMainHeading(); - expect(mainHeading).toExist(); + expect(mainHeading.exists()).toBe(true); expect(mainHeading.text()).toContain('Security Configuration'); }); it('renders GlTab Component ', () => { - expect(findTab()).toExist(); + expect(findTab().exists()).toBe(true); }); it('renders right amount of tabs with correct title ', () => { @@ -173,6 +175,43 @@ describe('App component', () => { }); }); + describe('Manage via MR Error Alert', () => { + beforeEach(() => { + createComponent({ + augmentedSecurityFeatures: securityFeaturesMock, + augmentedComplianceFeatures: complianceFeaturesMock, + }); + }); + + describe('on initial load', () => { + it('should not show Manage via MR Error Alert', () => { + expect(findManageViaMRErrorAlert().exists()).toBe(false); + }); + }); + + describe('when error occurs', () => { + it('should show Alert with error Message', async () => { + expect(findManageViaMRErrorAlert().exists()).toBe(false); + findFeatureCards().at(1).vm.$emit('error', 'There was a manage via MR error'); + + await nextTick(); + expect(findManageViaMRErrorAlert().exists()).toBe(true); + expect(findManageViaMRErrorAlert().text()).toEqual('There was a manage via MR error'); + }); + + it('should hide Alert when it is dismissed', async () => { + findFeatureCards().at(1).vm.$emit('error', 'There was a manage via MR error'); + + await nextTick(); + expect(findManageViaMRErrorAlert().exists()).toBe(true); + + findManageViaMRErrorAlert().vm.$emit('dismiss'); + await nextTick(); + expect(findManageViaMRErrorAlert().exists()).toBe(false); + }); + }); + }); + describe('Auto DevOps hint alert', () => { describe('given the right props', () => { beforeEach(() => { diff --git a/spec/frontend/security_configuration/components/feature_card_spec.js b/spec/frontend/security_configuration/components/feature_card_spec.js index fdb1d2f86e3..0eca2c27075 100644 --- a/spec/frontend/security_configuration/components/feature_card_spec.js +++ b/spec/frontend/security_configuration/components/feature_card_spec.js @@ -80,7 +80,11 @@ describe('FeatureCard component', () => { describe('basic structure', () => { beforeEach(() => { - feature = makeFeature(); + feature = makeFeature({ + type: 'sast', + available: true, + canEnableByMergeRequest: true, + }); createComponent({ feature }); }); @@ -97,6 +101,11 @@ describe('FeatureCard component', () => { expect(links.exists()).toBe(true); expect(links).toHaveLength(1); }); + + it('should catch and emit manage-via-mr-error', () => { + findManageViaMr().vm.$emit('error', 'There was a manage via MR error'); + expect(wrapper.emitted('error')).toEqual([['There was a manage via MR error']]); + }); }); describe('status', () => { |