diff --git a/ee/app/assets/javascripts/vulnerabilities/components/vulnerability_details.vue b/ee/app/assets/javascripts/vulnerabilities/components/vulnerability_details.vue index b0b5fa4cc68d73b1386e018b1ff2c3ad7f592be7..e21ad5777cd4503c20b8e65ad18bf5439e0eda47 100644 --- a/ee/app/assets/javascripts/vulnerabilities/components/vulnerability_details.vue +++ b/ee/app/assets/javascripts/vulnerabilities/components/vulnerability_details.vue @@ -328,6 +328,12 @@ export default { ? 'success' : 'warning'; }, + shouldShowConfidenceScore() { + return ( + this.glFeatures.aiExperimentSastFpDetection && + this.vulnerability.latestFlag?.confidenceScore != null + ); + }, vulnerabilityForModal() { return { id: this.vulnerabilityGraphqlId }; }, @@ -437,7 +443,7 @@ export default { }}

- {{ s__('Vulnerability|AI Confidence Score') }}: + {{ s__('Vulnerability|AI false positive Confidence Score') }}: +

{{ __('Description') }}

{ expect(progressBar.exists()).toBe(true); expect(progressBar.props('value')).toBe(85); expect(progressBar.props('variant')).toBe('success'); - expect(wrapper.text()).toContain('AI Confidence Score'); + expect(wrapper.text()).toContain('AI false positive Confidence Score'); expect(wrapper.text()).toContain('85%'); }); @@ -366,6 +366,87 @@ describe('Vulnerability Details', () => { expect(wrapper.text()).not.toContain('AI detected false positive'); }); + + it('shows only the confidence score without title or description', () => { + createWrapper( + { + falsePositive: true, + latestFlag: { + description: 'Some description', + confidenceScore: 0.25, + }, + }, + { aiExperimentSastFpDetection: true }, + ); + + expect(wrapper.text()).not.toContain('AI detected false positive'); + expect(wrapper.text()).not.toContain('Why it is likely a false positive'); + expect(wrapper.text()).not.toContain('Some description'); + expect(wrapper.text()).toContain('AI false positive Confidence Score'); + expect(wrapper.text()).toContain('25%'); + }); + + it('displays the confidence score with correct progress bar variant', () => { + createWrapper( + { + falsePositive: true, + latestFlag: { + description: 'Some description', + confidenceScore: 0.25, + }, + }, + { aiExperimentSastFpDetection: true }, + ); + + const progressBar = wrapper.findComponent(GlProgressBar); + expect(progressBar.exists()).toBe(true); + expect(progressBar.props('value')).toBe(25); + expect(progressBar.props('variant')).toBe('warning'); + }); + + it('does not show the remove flag button', () => { + createWrapper( + { + falsePositive: true, + latestFlag: { + description: 'Some description', + confidenceScore: 0.25, + }, + canAdmin: true, + state: 'detected', + }, + { aiExperimentSastFpDetection: true }, + ); + + const button = wrapper.find('[data-testid="remove-false-positive-button"]'); + expect(button.exists()).toBe(false); + }); + + it('does not show confidence score when latestFlag is not present', () => { + createWrapper( + { + falsePositive: true, + }, + { aiExperimentSastFpDetection: true }, + ); + + expect(wrapper.text()).not.toContain('AI false positive Confidence Score'); + }); + + it('does not show confidence score when feature flag is disabled', () => { + createWrapper( + { + falsePositive: true, + latestFlag: { + description: 'Some description', + confidenceScore: 0.25, + }, + }, + { aiExperimentSastFpDetection: false }, + ); + + expect(wrapper.text()).not.toContain('AI false positive Confidence Score'); + }); }); it('renders description when descriptionHtml is not present', () => { diff --git a/locale/gitlab.pot b/locale/gitlab.pot index de441c898f70f4d2dea18466e902e0b56baaf41f..4a072915a38353e1662f81fef68d2c25f46c5711 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -75032,6 +75032,9 @@ msgstr "" msgid "Vulnerability|AI detected false positive" msgstr "" +msgid "Vulnerability|AI false positive Confidence Score" +msgstr "" + msgid "Vulnerability|AI has created a merge request to resolve this vulnerability" msgstr ""