diff --git a/ee/app/assets/javascripts/security_dashboard/components/shared/vulnerability_report/selection_summary.vue b/ee/app/assets/javascripts/security_dashboard/components/shared/vulnerability_report/selection_summary.vue index 955f7ad66d6631acc868c6648e56b101eb027475..3f6971e236db06ebcb6dcf8e02457d6471cd3920 100644 --- a/ee/app/assets/javascripts/security_dashboard/components/shared/vulnerability_report/selection_summary.vue +++ b/ee/app/assets/javascripts/security_dashboard/components/shared/vulnerability_report/selection_summary.vue @@ -10,7 +10,6 @@ import { GlLink, } from '@gitlab/ui'; import * as Sentry from '@sentry/browser'; -import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import eventHub from 'ee/security_dashboard/utils/event_hub'; import { __, s__, n__ } from '~/locale'; import toast from '~/vue_shared/plugins/global_toast'; @@ -29,7 +28,6 @@ export default { GlFormGroup, GlLink, }, - mixins: [glFeatureFlagMixin()], inject: ['vulnerabilitiesQuery', 'vulnerabilitiesCountsQuery'], props: { selectedVulnerabilities: { @@ -176,7 +174,7 @@ export default { this.isSubmitting = true; - if (this.isDismissedStatus && this.glFeatures.dismissMultipleVulnerabilities) { + if (this.isDismissedStatus) { return this.dismissMultipleVulnerabilities(); } diff --git a/ee/spec/frontend/security_dashboard/components/shared/vulnerability_report/selection_summary_spec.js b/ee/spec/frontend/security_dashboard/components/shared/vulnerability_report/selection_summary_spec.js index f7d0461678b4b6cb3bf172082d3541995dc37f0e..ccd2757b1ae6628fb1d1bd79d84910a1c23227a9 100644 --- a/ee/spec/frontend/security_dashboard/components/shared/vulnerability_report/selection_summary_spec.js +++ b/ee/spec/frontend/security_dashboard/components/shared/vulnerability_report/selection_summary_spec.js @@ -17,7 +17,7 @@ import waitForPromises from 'helpers/wait_for_promises'; import toast from '~/vue_shared/plugins/global_toast'; import { VULNERABILITY_STATE_OBJECTS, DISMISSAL_REASONS } from 'ee/vulnerabilities/constants'; import projectVulnerabilitiesQuery from 'ee/security_dashboard/graphql/queries/project_vulnerabilities.query.graphql'; -import vulnerabilityDismiss from 'ee/security_dashboard/graphql/mutations/vulnerability_dismiss.mutation.graphql'; +import vulnerabilityResolve from 'ee/security_dashboard/graphql/mutations/vulnerability_resolve.mutation.graphql'; import vulnerabilitiesDismiss from 'ee/security_dashboard/graphql/mutations/vulnerabilities_dismiss.mutation.graphql'; import countsQuery from 'ee/security_dashboard/graphql/queries/vulnerability_severities_count.query.graphql'; @@ -80,7 +80,6 @@ describe('Selection Summary component', () => { apolloProvider, vulnerabilitiesQuery, vulnerabilitiesCountsQuery, - dismissMultipleVulnerabilities = true, } = {}) => { wrapper = shallowMountExtended(SelectionSummary, { apolloProvider, @@ -97,7 +96,6 @@ describe('Selection Summary component', () => { provide: { vulnerabilitiesQuery, vulnerabilitiesCountsQuery, - glFeatures: { dismissMultipleVulnerabilities }, }, }); }; @@ -304,7 +302,7 @@ describe('Selection Summary component', () => { }); }); - describe.each(Object.entries(VULNERABILITY_STATE_OBJECTS))( + describe.each(Object.entries(VULNERABILITY_STATE_OBJECTS_WITHOUT_DISMISSED))( 'state dropdown change - %s', (state, { action, mutation }) => { const selectedVulnerabilities = [ @@ -333,18 +331,17 @@ describe('Selection Summary component', () => { createComponent({ apolloProvider, selectedVulnerabilities, - dismissMultipleVulnerabilities: false, }); }); it(`does not emit vulnerability-updated event - ${action}`, async () => { - await submitForm({ state, dismissalReason: 'false_positive', comment: 'test' }); + await submitForm({ state }); await waitForPromises(); expect(wrapper.emitted()['vulnerability-updated']).toBeUndefined(); }); it(`shows alert - ${action}`, async () => { - await submitForm({ state, dismissalReason: 'false_positive', comment: 'test' }); + await submitForm({ state }); await waitForPromises(); expect(findGlAlert().text()).toMatchInterpolatedText( @@ -390,15 +387,13 @@ describe('Selection Summary component', () => { createComponent({ apolloProvider, selectedVulnerabilities, - dismissMultipleVulnerabilities: false, }); }); it(`calls the mutation with the expected data and emits an update for each vulnerability - ${action}`, async () => { const mockComment = 'test comment'; - const mockDismissalReason = 'mitigating_control'; - await submitForm({ state, comment: mockComment, dismissalReason: mockDismissalReason }); + await submitForm({ state, comment: mockComment }); await waitForPromises(); selectedVulnerabilities.forEach((v, i) => { expect(wrapper.emitted()['vulnerabilities-updated'][i][0]).toEqual([v.id]); @@ -408,10 +403,6 @@ describe('Selection Summary component', () => { comment: mockComment, }; - if (state === 'dismissed') { - mutationPayload.dismissalReason = mockDismissalReason.toUpperCase(); - } - expect(requestHandler).toHaveBeenCalledWith(expect.objectContaining(mutationPayload)); }); @@ -423,14 +414,14 @@ describe('Selection Summary component', () => { expect(cacheClearSpy).not.toHaveBeenCalled(); - await submitForm({ state, dismissalReason: 'false_positive', comment: 'test' }); + await submitForm({ state }); await waitForPromises(); expect(cacheClearSpy).toHaveBeenCalledTimes(1); }); it(`calls the toaster - ${action}`, async () => { - await submitForm({ state, dismissalReason: 'false_positive', comment: 'test' }); + await submitForm({ state }); await waitForPromises(); // Workaround for the detected state, which shows as "needs triage" in the UI but uses // "detected" behind the scenes. @@ -441,23 +432,15 @@ describe('Selection Summary component', () => { }); it(`the buttons are unclickable during form submission - ${action}`, async () => { - const areElementsDisabled = () => { - const areGeneralElementDisabled = - findSubmitButton().props('loading') && - findCancelButton().props('disabled') && - findStatusListbox().props('disabled') && - findCommentFormInput().attributes('disabled') === 'true'; - - if (state === 'dismissed') { - return areGeneralElementDisabled && findDismissalReasonListbox().props('disabled'); - } - - return areGeneralElementDisabled; - }; + const areElementsDisabled = () => + findSubmitButton().props('loading') && + findCancelButton().props('disabled') && + findStatusListbox().props('disabled') && + findCommentFormInput().attributes('disabled') === 'true'; expect(findSubmitButton().props('disabled')).toBeDefined(); - await submitForm({ state, dismissalReason: 'false_positive', comment: 'test' }); + await submitForm({ state }); expect(areElementsDisabled()).toBe(true); @@ -470,7 +453,7 @@ describe('Selection Summary component', () => { const spy = jest.fn(); eventHub.$on('vulnerabilities-updated', spy); - await submitForm({ state, dismissalReason: 'false_positive', comment: 'test' }); + await submitForm({ state }); await waitForPromises(); expect(spy).toHaveBeenCalled(); @@ -648,19 +631,17 @@ describe('Selection Summary component', () => { describe('refetch queries', () => { it('uses expected queries with refetchQueries', async () => { const selectedVulnerabilities = [{}, {}, {}]; - const requestHandler = jest.fn().mockResolvedValue({ data: { vulnerabilityDismiss: {} } }); + const requestHandler = jest.fn().mockResolvedValue({ data: { vulnerabilityResolve: {} } }); createComponent({ - apolloProvider: createApolloProvider([vulnerabilityDismiss, requestHandler]), + apolloProvider: createApolloProvider([vulnerabilityResolve, requestHandler]), selectedVulnerabilities, vulnerabilitiesQuery: projectVulnerabilitiesQuery, vulnerabilitiesCountsQuery: countsQuery, - dismissMultipleVulnerabilities: false, }); await submitForm({ - state: 'dismissed', - dismissalReason: 'false_positive', + state: 'resolved', comment: 'test', }); @@ -668,7 +649,6 @@ describe('Selection Summary component', () => { expect(requestHandler).toHaveBeenCalledWith( expect.objectContaining({ comment: 'test', - dismissalReason: 'FALSE_POSITIVE', id: undefined, }), );