Skip to content
代码片段 群组 项目
未验证 提交 1e432817 编辑于 作者: David Pisek's avatar David Pisek 提交者: GitLab
浏览文件

Merge branch 'support-gfm-description-finding-modal' into 'master'

Support GitLab flavored markdown in finding modal description

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/150008



Merged-by: default avatarDavid Pisek <dpisek@gitlab.com>
Approved-by: default avatarJay Montal <jmontal@gitlab.com>
Approved-by: default avatarDavid Pisek <dpisek@gitlab.com>
Co-authored-by: default avatarlorenzvanherwaarden <lvanherwaarden@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<script> <script>
import { GlLink, GlSprintf, GlFriendlyWrap } from '@gitlab/ui'; import { GlLink, GlSprintf, GlFriendlyWrap } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { renderGFM } from '~/behaviors/markdown/render_gfm';
import StatusBadge from 'ee/vue_shared/security_reports/components/status_badge.vue'; import StatusBadge from 'ee/vue_shared/security_reports/components/status_badge.vue';
import SeverityBadge from 'ee/vue_shared/security_reports/components/severity_badge.vue'; import SeverityBadge from 'ee/vue_shared/security_reports/components/severity_badge.vue';
import FalsePositiveAlert from 'ee/vulnerabilities/components/false_positive_alert.vue'; import FalsePositiveAlert from 'ee/vulnerabilities/components/false_positive_alert.vue';
...@@ -260,6 +261,9 @@ export default { ...@@ -260,6 +261,9 @@ export default {
return itemsWithContent; return itemsWithContent;
}, },
}, },
mounted() {
renderGFM(this.$refs.description);
},
methods: { methods: {
handleShowTraining(showVulnerabilityTraining) { handleShowTraining(showVulnerabilityTraining) {
this.showTraining = showVulnerabilityTraining; this.showTraining = showVulnerabilityTraining;
...@@ -277,7 +281,12 @@ export default { ...@@ -277,7 +281,12 @@ export default {
:heading="$options.i18n.descriptionSectionHeading" :heading="$options.i18n.descriptionSectionHeading"
data-testid="description-section" data-testid="description-section"
> >
<div v-if="descriptionHtml" v-safe-html="descriptionHtml"></div> <div
v-if="descriptionHtml"
ref="description"
v-safe-html="descriptionHtml"
data-testid="description-html"
></div>
<p v-else>{{ description }}</p> <p v-else>{{ description }}</p>
</details-section> </details-section>
......
import { GlSprintf, GlLink, GlFriendlyWrap } from '@gitlab/ui'; import { GlSprintf, GlLink, GlFriendlyWrap } from '@gitlab/ui';
import { trimText } from 'helpers/text_helper'; import { trimText } from 'helpers/text_helper';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import { renderGFM } from '~/behaviors/markdown/render_gfm';
import { REPORT_TYPES_TO_HUMAN_READABLE } from 'ee/security_dashboard/components/shared/vulnerability_details_graphql/constants'; import { REPORT_TYPES_TO_HUMAN_READABLE } from 'ee/security_dashboard/components/shared/vulnerability_details_graphql/constants';
import Details from 'ee/security_dashboard/components/shared/vulnerability_details_graphql/index.vue'; import Details from 'ee/security_dashboard/components/shared/vulnerability_details_graphql/index.vue';
import DetailsSection from 'ee/security_dashboard/components/shared/vulnerability_details_graphql/details_section.vue'; import DetailsSection from 'ee/security_dashboard/components/shared/vulnerability_details_graphql/details_section.vue';
...@@ -31,6 +32,8 @@ const TEST_VULNERABILITY = { ...@@ -31,6 +32,8 @@ const TEST_VULNERABILITY = {
state: 'DETECTED', state: 'DETECTED',
}; };
jest.mock('~/behaviors/markdown/render_gfm');
describe('ee/security_dashboard/components/shared/vulnerability_details_graphql/index.vue', () => { describe('ee/security_dashboard/components/shared/vulnerability_details_graphql/index.vue', () => {
let wrapper; let wrapper;
...@@ -84,6 +87,7 @@ describe('ee/security_dashboard/components/shared/vulnerability_details_graphql/ ...@@ -84,6 +87,7 @@ describe('ee/security_dashboard/components/shared/vulnerability_details_graphql/
beforeEach(createComponent); beforeEach(createComponent);
const findDescriptionSection = () => wrapper.findByTestId('description-section'); const findDescriptionSection = () => wrapper.findByTestId('description-section');
const findDescriptionHtml = () => wrapper.findByTestId('description-html');
it('is a details section with the correct heading', () => { it('is a details section with the correct heading', () => {
expectToBeDetailsSection(findDescriptionSection(), { heading: 'Description' }); expectToBeDetailsSection(findDescriptionSection(), { heading: 'Description' });
...@@ -93,14 +97,23 @@ describe('ee/security_dashboard/components/shared/vulnerability_details_graphql/ ...@@ -93,14 +97,23 @@ describe('ee/security_dashboard/components/shared/vulnerability_details_graphql/
expect(findDescriptionSection().html()).toContain(TEST_VULNERABILITY.descriptionHtml); expect(findDescriptionSection().html()).toContain(TEST_VULNERABILITY.descriptionHtml);
}); });
it(`contains the vulnerability's plaintext description when descriptionHtml is not available`, () => { it('renders gfm', () => {
createComponent({ expect(renderGFM).toHaveBeenCalledWith(findDescriptionHtml().element);
propsData: { });
...TEST_VULNERABILITY,
descriptionHtml: '', describe('when descriptionHtml is not available', () => {
}, beforeEach(() => {
createComponent({
propsData: {
...TEST_VULNERABILITY,
descriptionHtml: '',
},
});
});
it(`contains the vulnerability's plaintext description`, () => {
expect(findDescriptionSection().text()).toContain(TEST_VULNERABILITY.description);
}); });
expect(findDescriptionSection().text()).toContain(TEST_VULNERABILITY.description);
}); });
}); });
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册