Commit d344d378 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'jnnkl-vulnerability-survey-flag-reintroduce' into 'master'

Reintroduced  vulnerability_management_survey for survey Banner

See merge request gitlab-org/gitlab!77745
parents 72e4dc4a e44769da
...@@ -11,14 +11,20 @@ import { ...@@ -11,14 +11,20 @@ import {
} from 'ee/security_dashboard/constants'; } from 'ee/security_dashboard/constants';
import SurveyBanner from 'ee/vue_shared/survey_banner/survey_banner.vue'; import SurveyBanner from 'ee/vue_shared/survey_banner/survey_banner.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
export default { export default {
name: 'VulnManagementFeatureSurvey', name: 'VulnManagementFeatureSurvey',
components: { components: {
SurveyBanner, SurveyBanner,
}, },
mixins: [glFeatureFlagsMixin()],
inject: ['surveyRequestSvgPath'], inject: ['surveyRequestSvgPath'],
computed: {
shouldShowSurveyBanner() {
return this.glFeatures.vulnerabilityManagementSurvey;
},
},
storageKey: SURVEY_BANNER_LOCAL_STORAGE_KEY, storageKey: SURVEY_BANNER_LOCAL_STORAGE_KEY,
surveyLink: SURVEY_LINK, surveyLink: SURVEY_LINK,
daysToAskLater: SURVEY_DAYS_TO_ASK_LATER, daysToAskLater: SURVEY_DAYS_TO_ASK_LATER,
...@@ -32,6 +38,7 @@ export default { ...@@ -32,6 +38,7 @@ export default {
<template> <template>
<survey-banner <survey-banner
v-if="shouldShowSurveyBanner"
:svg-path="surveyRequestSvgPath" :svg-path="surveyRequestSvgPath"
:survey-link="$options.surveyLink" :survey-link="$options.surveyLink"
:days-to-ask-later="$options.daysToAskLater" :days-to-ask-later="$options.daysToAskLater"
......
...@@ -20,10 +20,15 @@ describe('SurveyRequestBanner Component', () => { ...@@ -20,10 +20,15 @@ describe('SurveyRequestBanner Component', () => {
const SURVEY_REQUEST_SVG_PATH = 'foo.svg'; const SURVEY_REQUEST_SVG_PATH = 'foo.svg';
const createComponent = (sbomSurvey = { sbomSurvey: true }) => { const createComponent = (
vulnerabilityManagementSurvey = { vulnerabilityManagementSurvey: true },
) => {
wrapper = extendedWrapper( wrapper = extendedWrapper(
mount(SurveyRequestBanner, { mount(SurveyRequestBanner, {
provide: { glFeatures: { ...sbomSurvey }, surveyRequestSvgPath: SURVEY_REQUEST_SVG_PATH }, provide: {
glFeatures: { ...vulnerabilityManagementSurvey },
surveyRequestSvgPath: SURVEY_REQUEST_SVG_PATH,
},
}), }),
); );
}; };
...@@ -36,20 +41,33 @@ describe('SurveyRequestBanner Component', () => { ...@@ -36,20 +41,33 @@ describe('SurveyRequestBanner Component', () => {
createComponent(); createComponent();
}); });
it('renders the SurveyRequestBanner component with the right props', () => { describe('given a true vulnerability_management_survey flag', () => {
const surveyBanner = findSharedSurveyBanner(); it('renders the SurveyRequestBanner component with the right props', () => {
expect(surveyBanner.exists()).toBe(true); const surveyBanner = findSharedSurveyBanner();
expect(surveyBanner.exists()).toBe(true);
expect(surveyBanner.props()).toMatchObject({
bannerId: SURVEY_BANNER_CURRENT_ID, expect(surveyBanner.props()).toMatchObject({
storageKey: SURVEY_BANNER_LOCAL_STORAGE_KEY, bannerId: SURVEY_BANNER_CURRENT_ID,
daysToAskLater: SURVEY_DAYS_TO_ASK_LATER, storageKey: SURVEY_BANNER_LOCAL_STORAGE_KEY,
surveyLink: SURVEY_LINK, daysToAskLater: SURVEY_DAYS_TO_ASK_LATER,
svgPath: SURVEY_REQUEST_SVG_PATH, surveyLink: SURVEY_LINK,
title: SURVEY_TITLE, svgPath: SURVEY_REQUEST_SVG_PATH,
toastMessage: SURVEY_TOAST_MESSAGE, title: SURVEY_TITLE,
toastMessage: SURVEY_TOAST_MESSAGE,
});
expect(surveyBanner.props('buttonText')).toContain(SURVEY_BUTTON_TEXT);
expect(surveyBanner.props('description')).toContain(SURVEY_DESCRIPTION);
});
});
describe('given a false vulnerability_management_survey flag', () => {
beforeEach(() => {
createComponent({ vulnerabilityManagementSurvey: false });
});
it('does not renders the SurveyRequestBanner', () => {
const surveyBanner = findSharedSurveyBanner();
expect(surveyBanner.exists()).toBe(false);
}); });
expect(surveyBanner.props('buttonText')).toContain(SURVEY_BUTTON_TEXT);
expect(surveyBanner.props('description')).toContain(SURVEY_DESCRIPTION);
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment