From 24cf74656b68a0ee9a5670389ed526979bbb2dce Mon Sep 17 00:00:00 2001
From: Nate Rosandich
{ 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 de441c898f70f4..4a072915a38353 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 "" -- GitLab