Commit 8b35134e authored by Miguel Rincon's avatar Miguel Rincon Committed by Vitaly Slobodin

Rename HelpPopover when imported by summary_row

parent fc416b60
<script>
import { GlLoadingIcon } from '@gitlab/ui';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
import Popover from '~/vue_shared/components/help_popover.vue';
import HelpPopover from '~/vue_shared/components/help_popover.vue';
import { ICON_WARNING } from '../constants';
/**
......@@ -16,7 +16,7 @@ export default {
name: 'ReportSummaryRow',
components: {
CiIcon,
Popover,
HelpPopover,
GlLoadingIcon,
},
props: {
......@@ -79,7 +79,7 @@ export default {
<div class="report-block-list-issue-description-text" data-testid="summary-row-description">
<slot name="summary">{{ summary }}</slot
><span v-if="popoverOptions" class="text-nowrap"
>&nbsp;<popover v-if="popoverOptions" :options="popoverOptions" class="align-top" />
>&nbsp;<help-popover v-if="popoverOptions" :options="popoverOptions" class="align-top" />
</span>
</div>
</div>
......
import { mount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import HelpPopover from '~/vue_shared/components/help_popover.vue';
import SummaryRow from '~/reports/components/summary_row.vue';
describe('Summary row', () => {
let wrapper;
const props = {
summary: 'SAST detected 1 new vulnerability and 1 fixed vulnerability',
popoverOptions: {
title: 'Static Application Security Testing (SAST)',
content: '<a>Learn more about SAST</a>',
},
statusIcon: 'warning',
const summary = 'SAST detected 1 new vulnerability and 1 fixed vulnerability';
const popoverOptions = {
title: 'Static Application Security Testing (SAST)',
content: '<a>Learn more about SAST</a>',
};
const statusIcon = 'warning';
const createComponent = ({ propsData = {}, slots = {} } = {}) => {
const createComponent = ({ props = {}, slots = {} } = {}) => {
wrapper = extendedWrapper(
mount(SummaryRow, {
propsData: {
summary,
popoverOptions,
statusIcon,
...props,
...propsData,
},
slots,
}),
......@@ -28,6 +29,7 @@ describe('Summary row', () => {
const findSummary = () => wrapper.findByTestId('summary-row-description');
const findStatusIcon = () => wrapper.findByTestId('summary-row-icon');
const findHelpPopover = () => wrapper.findComponent(HelpPopover);
afterEach(() => {
wrapper.destroy();
......@@ -36,7 +38,7 @@ describe('Summary row', () => {
it('renders provided summary', () => {
createComponent();
expect(findSummary().text()).toContain(props.summary);
expect(findSummary().text()).toContain(summary);
});
it('renders provided icon', () => {
......@@ -44,12 +46,22 @@ describe('Summary row', () => {
expect(findStatusIcon().classes()).toContain('js-ci-status-icon-warning');
});
it('renders help popover if popoverOptions are provided', () => {
createComponent();
expect(findHelpPopover().props('options')).toEqual(popoverOptions);
});
it('does not render help popover if popoverOptions are not provided', () => {
createComponent({ props: { popoverOptions: null } });
expect(findHelpPopover().exists()).toBe(false);
});
describe('summary slot', () => {
it('replaces the summary prop', () => {
const summarySlotContent = 'Summary slot content';
createComponent({ slots: { summary: summarySlotContent } });
expect(wrapper.text()).not.toContain(props.summary);
expect(wrapper.text()).not.toContain(summary);
expect(findSummary().text()).toContain(summarySlotContent);
});
});
......
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