Commit dcdc0591 authored by Peter Hegman's avatar Peter Hegman

Merge branch '350373-requirements-badge' into 'master'

Update icon prop for requirements badge

See merge request gitlab-org/gitlab!78412
parents a6c75718 0b6a3748
<script> <script>
import { GlBadge, GlIcon, GlTooltip } from '@gitlab/ui'; import { GlBadge, GlTooltip } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import timeagoMixin from '~/vue_shared/mixins/timeago'; import timeagoMixin from '~/vue_shared/mixins/timeago';
...@@ -8,7 +8,6 @@ import { TestReportStatus } from '../constants'; ...@@ -8,7 +8,6 @@ import { TestReportStatus } from '../constants';
export default { export default {
components: { components: {
GlBadge, GlBadge,
GlIcon,
GlTooltip, GlTooltip,
}, },
mixins: [timeagoMixin], mixins: [timeagoMixin],
...@@ -58,8 +57,7 @@ export default { ...@@ -58,8 +57,7 @@ export default {
<template> <template>
<component :is="elementType" class="requirement-status-badge"> <component :is="elementType" class="requirement-status-badge">
<gl-badge ref="testReportBadge" :variant="testReportBadge.variant"> <gl-badge ref="testReportBadge" :variant="testReportBadge.variant" :icon="testReportBadge.icon">
<gl-icon :name="testReportBadge.icon" class="mr-1" />
{{ testReportBadge.text }} {{ testReportBadge.text }}
</gl-badge> </gl-badge>
<gl-tooltip <gl-tooltip
......
import { GlBadge, GlIcon, GlTooltip } from '@gitlab/ui'; import { GlBadge, GlTooltip } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
...@@ -94,9 +94,8 @@ describe('RequirementStatusBadge', () => { ...@@ -94,9 +94,8 @@ describe('RequirementStatusBadge', () => {
expect(badgeEl.exists()).toBe(true); expect(badgeEl.exists()).toBe(true);
expect(badgeEl.props('variant')).toBe(badgeProps.variant); expect(badgeEl.props('variant')).toBe(badgeProps.variant);
expect(badgeEl.props('icon')).toBe(badgeProps.icon);
expect(badgeEl.text()).toBe(badgeProps.text); expect(badgeEl.text()).toBe(badgeProps.text);
expect(badgeEl.findComponent(GlIcon).exists()).toBe(true);
expect(badgeEl.findComponent(GlIcon).props('name')).toBe(badgeProps.icon);
}); });
it('renders GlTooltip component', () => { it('renders GlTooltip component', () => {
......
import { GlPagination, GlIcon } from '@gitlab/ui'; import { GlPagination, GlBadge } from '@gitlab/ui';
import { createLocalVue, shallowMount } from '@vue/test-utils'; import { createLocalVue, shallowMount } from '@vue/test-utils';
import { defaultDataIdFromObject } from 'apollo-cache-inmemory'; import { defaultDataIdFromObject } from 'apollo-cache-inmemory';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
...@@ -131,7 +131,7 @@ const createComponentWithApollo = ({ props = {}, requestHandlers = [] } = {}) => ...@@ -131,7 +131,7 @@ const createComponentWithApollo = ({ props = {}, requestHandlers = [] } = {}) =>
stubs: { stubs: {
RequirementItem, RequirementItem,
RequirementStatusBadge, RequirementStatusBadge,
GlIcon, GlBadge,
}, },
}), }),
); );
...@@ -142,7 +142,7 @@ describe('RequirementsRoot', () => { ...@@ -142,7 +142,7 @@ describe('RequirementsRoot', () => {
let trackingSpy; let trackingSpy;
const findRequirementEditForm = () => wrapper.findByTestId('edit-form'); const findRequirementEditForm = () => wrapper.findByTestId('edit-form');
const findFailedStatusIcon = () => wrapper.findByTestId('status_failed-icon'); const findBadge = () => wrapper.findComponent(GlBadge);
beforeEach(() => { beforeEach(() => {
wrapper = createComponent(); wrapper = createComponent();
...@@ -1106,12 +1106,13 @@ describe('RequirementsRoot', () => { ...@@ -1106,12 +1106,13 @@ describe('RequirementsRoot', () => {
}); });
it('renders a failed badge after the update', async () => { it('renders a failed badge after the update', async () => {
expect(findFailedStatusIcon().exists()).toBe(false); await nextTick();
expect(findBadge().props('icon')).toBe('status_success');
editRequirementToFailed(); editRequirementToFailed();
await waitForPromises(); await waitForPromises();
expect(findFailedStatusIcon().exists()).toBe(true); expect(findBadge().props('icon')).toBe('status_failed');
}); });
}); });
......
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