Commit f2212234 authored by Jannik Lehmann's avatar Jannik Lehmann Committed by Kushal Pandya

Reintroduce text on Pipeline Widget dropdown

parent c54a30c1
...@@ -76,6 +76,7 @@ export default { ...@@ -76,6 +76,7 @@ export default {
<template> <template>
<security-report-download-dropdown <security-report-download-dropdown
:title="s__('SecurityReports|Download results')"
:artifacts="reportArtifacts" :artifacts="reportArtifacts"
:loading="isLoadingReportArtifacts" :loading="isLoadingReportArtifacts"
/> />
......
...@@ -21,6 +21,16 @@ export default { ...@@ -21,6 +21,16 @@ export default {
required: false, required: false,
default: false, default: false,
}, },
text: {
type: String,
required: false,
default: '',
},
title: {
type: String,
required: false,
default: '',
},
}, },
methods: { methods: {
artifactText({ name }) { artifactText({ name }) {
...@@ -35,7 +45,8 @@ export default { ...@@ -35,7 +45,8 @@ export default {
<template> <template>
<gl-dropdown <gl-dropdown
v-gl-tooltip v-gl-tooltip
:text="s__('SecurityReports|Download results')" :text="text"
:title="title"
:loading="loading" :loading="loading"
icon="download" icon="download"
size="small" size="small"
......
...@@ -200,6 +200,7 @@ export default { ...@@ -200,6 +200,7 @@ export default {
<template #action-buttons> <template #action-buttons>
<security-report-download-dropdown <security-report-download-dropdown
:text="s__('SecurityReports|Download results')"
:artifacts="reportArtifacts" :artifacts="reportArtifacts"
:loading="isLoadingReportArtifacts" :loading="isLoadingReportArtifacts"
/> />
...@@ -228,6 +229,7 @@ export default { ...@@ -228,6 +229,7 @@ export default {
<template #action-buttons> <template #action-buttons>
<security-report-download-dropdown <security-report-download-dropdown
:text="s__('SecurityReports|Download results')"
:artifacts="reportArtifacts" :artifacts="reportArtifacts"
:loading="isLoadingReportArtifacts" :loading="isLoadingReportArtifacts"
/> />
......
...@@ -78,6 +78,7 @@ export default { ...@@ -78,6 +78,7 @@ export default {
<div> <div>
<slot name="label"></slot> <slot name="label"></slot>
<security-report-download-dropdown <security-report-download-dropdown
:text="s__('SecurityReports|Download results')"
:artifacts="reportArtifacts" :artifacts="reportArtifacts"
:loading="isLoadingReportArtifacts" :loading="isLoadingReportArtifacts"
/> />
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
} from 'ee/vue_shared/security_reports/constants'; } from 'ee/vue_shared/security_reports/constants';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { import {
expectedDownloadDropdownProps, expectedDownloadDropdownPropsWithText,
securityReportPipelineDownloadPathsQueryResponse, securityReportPipelineDownloadPathsQueryResponse,
} from 'jest/vue_shared/security_reports/mock_data'; } from 'jest/vue_shared/security_reports/mock_data';
import createFlash from '~/flash'; import createFlash from '~/flash';
...@@ -80,7 +80,7 @@ describe('Pipeline artifact Download', () => { ...@@ -80,7 +80,7 @@ describe('Pipeline artifact Download', () => {
}); });
it('renders the download dropdown', () => { it('renders the download dropdown', () => {
expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownProps); expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownPropsWithText);
}); });
}); });
......
...@@ -3,7 +3,7 @@ import Vue from 'vue'; ...@@ -3,7 +3,7 @@ import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import { import {
expectedDownloadDropdownProps, expectedDownloadDropdownPropsWithTitle,
securityReportMergeRequestDownloadPathsQueryResponse, securityReportMergeRequestDownloadPathsQueryResponse,
} from 'jest/vue_shared/security_reports/mock_data'; } from 'jest/vue_shared/security_reports/mock_data';
import createFlash from '~/flash'; import createFlash from '~/flash';
...@@ -80,7 +80,7 @@ describe('Merge request artifact Download', () => { ...@@ -80,7 +80,7 @@ describe('Merge request artifact Download', () => {
}); });
it('renders the download dropdown', () => { it('renders the download dropdown', () => {
expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownProps); expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownPropsWithTitle);
}); });
}); });
......
...@@ -40,14 +40,13 @@ describe('SecurityReportDownloadDropdown component', () => { ...@@ -40,14 +40,13 @@ describe('SecurityReportDownloadDropdown component', () => {
expect(findDropdown().props('loading')).toBe(false); expect(findDropdown().props('loading')).toBe(false);
}); });
it('renders a dropdown items for each artifact', () => { it('renders a dropdown item for each artifact', () => {
artifacts.forEach((artifact, i) => { artifacts.forEach((artifact, i) => {
const item = findDropdownItems().at(i); const item = findDropdownItems().at(i);
expect(item.text()).toContain(artifact.name); expect(item.text()).toContain(artifact.name);
expect(item.attributes()).toMatchObject({
href: artifact.path, expect(item.element.getAttribute('href')).toBe(artifact.path);
download: expect.any(String), expect(item.element.getAttribute('download')).toBeDefined();
});
}); });
}); });
}); });
...@@ -61,4 +60,32 @@ describe('SecurityReportDownloadDropdown component', () => { ...@@ -61,4 +60,32 @@ describe('SecurityReportDownloadDropdown component', () => {
expect(findDropdown().props('loading')).toBe(true); expect(findDropdown().props('loading')).toBe(true);
}); });
}); });
describe('given title props', () => {
beforeEach(() => {
createComponent({ artifacts: [], loading: true, title: 'test title' });
});
it('should render title', () => {
expect(findDropdown().attributes('title')).toBe('test title');
});
it('should not render text', () => {
expect(findDropdown().text().trim()).toBe('');
});
});
describe('given text props', () => {
beforeEach(() => {
createComponent({ artifacts: [], loading: true, text: 'test text' });
});
it('should not render title', () => {
expect(findDropdown().props().title).not.toBeDefined();
});
it('should render text', () => {
expect(findDropdown().props().text).toContain('test text');
});
});
}); });
...@@ -581,9 +581,18 @@ export const secretDetectionArtifacts = [ ...@@ -581,9 +581,18 @@ export const secretDetectionArtifacts = [
}, },
]; ];
export const expectedDownloadDropdownProps = { export const expectedDownloadDropdownPropsWithTitle = {
loading: false, loading: false,
artifacts: [...secretDetectionArtifacts, ...sastArtifacts], artifacts: [...secretDetectionArtifacts, ...sastArtifacts],
text: '',
title: 'Download results',
};
export const expectedDownloadDropdownPropsWithText = {
loading: false,
artifacts: [...secretDetectionArtifacts, ...sastArtifacts],
title: '',
text: 'Download results',
}; };
/** /**
......
...@@ -8,7 +8,7 @@ import createMockApollo from 'helpers/mock_apollo_helper'; ...@@ -8,7 +8,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import { trimText } from 'helpers/text_helper'; import { trimText } from 'helpers/text_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { import {
expectedDownloadDropdownProps, expectedDownloadDropdownPropsWithText,
securityReportMergeRequestDownloadPathsQueryNoArtifactsResponse, securityReportMergeRequestDownloadPathsQueryNoArtifactsResponse,
securityReportMergeRequestDownloadPathsQueryResponse, securityReportMergeRequestDownloadPathsQueryResponse,
sastDiffSuccessMock, sastDiffSuccessMock,
...@@ -99,7 +99,7 @@ describe('Security reports app', () => { ...@@ -99,7 +99,7 @@ describe('Security reports app', () => {
}); });
it('renders the download dropdown', () => { it('renders the download dropdown', () => {
expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownProps); expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownPropsWithText);
}); });
it('renders the expected message', () => { it('renders the expected message', () => {
...@@ -203,7 +203,7 @@ describe('Security reports app', () => { ...@@ -203,7 +203,7 @@ describe('Security reports app', () => {
}); });
it('renders the download dropdown', () => { it('renders the download dropdown', () => {
expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownProps); expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownPropsWithText);
}); });
}); });
...@@ -225,7 +225,7 @@ describe('Security reports app', () => { ...@@ -225,7 +225,7 @@ describe('Security reports app', () => {
}); });
it('renders the download dropdown', () => { it('renders the download dropdown', () => {
expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownProps); expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownPropsWithText);
}); });
}); });
...@@ -247,7 +247,7 @@ describe('Security reports app', () => { ...@@ -247,7 +247,7 @@ describe('Security reports app', () => {
}); });
it('renders the download dropdown', () => { it('renders the download dropdown', () => {
expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownProps); expect(findDownloadDropdown().props()).toEqual(expectedDownloadDropdownPropsWithText);
}); });
}); });
......
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