Commit 80d0c67c authored by Phil Hughes's avatar Phil Hughes

Merge branch '241061-show-failed-jobs-badge' into 'master'

Prepare a pipeline status badge

See merge request gitlab-org/gitlab!44716
parents 127e7947 bfb365f8
<script>
import { GlBadge, GlIcon } from '@gitlab/ui';
export default {
components: { GlBadge, GlIcon },
inject: {
pipelineSecurityBuildsFailedCount: { type: Number, required: false, default: 0 },
pipelineSecurityBuildsFailedPath: { type: String, required: false, default: '' },
},
};
</script>
<template>
<gl-badge variant="danger" :href="pipelineSecurityBuildsFailedPath">
<gl-icon name="status_failed" class="gl-mr-2" />
{{
n__('%d failed security job', '%d failed security jobs', pipelineSecurityBuildsFailedCount)
}}
</gl-badge>
</template>
......@@ -43,6 +43,8 @@ export default (el, dashboardType) => {
component = FirstClassProjectSecurityDashboard;
props.projectFullPath = el.dataset.projectFullPath;
provide.autoFixDocumentation = el.dataset.autoFixDocumentation;
provide.pipelineSecurityBuildsFailedCount = el.dataset.pipelineSecurityBuildsFailedCount;
provide.pipelineSecurityBuildsFailedPath = el.dataset.pipelineSecurityBuildsFailedPath;
} else if (dashboardType === DASHBOARD_TYPES.GROUP) {
component = FirstClassGroupSecurityDashboard;
props.groupFullPath = el.dataset.groupFullPath;
......
import { GlBadge } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import PipelineStatusBadge from 'ee/security_dashboard/components/pipeline_status_badge.vue';
describe('Pipeline status badge', () => {
const pipelineSecurityBuildsFailedPath = '/some/path/to/failed/jobs';
let wrapper;
const createWrapper = ({ pipelineSecurityBuildsFailedCount }) => {
wrapper = shallowMount(PipelineStatusBadge, {
provide: {
pipelineSecurityBuildsFailedCount,
pipelineSecurityBuildsFailedPath,
},
stubs: { GlBadge },
});
};
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('displays correct message for 5 failed jobs', () => {
createWrapper({ pipelineSecurityBuildsFailedCount: 5 });
expect(wrapper.text()).toBe('5 failed security jobs');
});
it('displays correct message for 1 failed job', () => {
createWrapper({ pipelineSecurityBuildsFailedCount: 1 });
expect(wrapper.text()).toBe('1 failed security job');
});
it('links to the correct path', () => {
createWrapper({ pipelineSecurityBuildsFailedCount: 5 });
expect(wrapper.find(GlBadge).attributes('href')).toBe(pipelineSecurityBuildsFailedPath);
});
});
......@@ -185,6 +185,11 @@ msgid_plural "%d failed"
msgstr[0] ""
msgstr[1] ""
msgid "%d failed security job"
msgid_plural "%d failed security jobs"
msgstr[0] ""
msgstr[1] ""
msgid "%d fixed test result"
msgid_plural "%d fixed test results"
msgstr[0] ""
......
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