Commit 9d824900 authored by pburdette's avatar pburdette

Replace alert with GlAlert

Replace the alert in erased
block with GlAlert component.
parent 6dfb625c
<script> <script>
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { GlLink } from '@gitlab/ui'; import { GlAlert, GlLink } from '@gitlab/ui';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue'; import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
export default { export default {
components: { components: {
TimeagoTooltip, GlAlert,
GlLink, GlLink,
TimeagoTooltip,
}, },
props: { props: {
user: { user: {
...@@ -27,17 +28,18 @@ export default { ...@@ -27,17 +28,18 @@ export default {
}; };
</script> </script>
<template> <template>
<div class="gl-mt-3 js-build-erased"> <div class="gl-mt-3">
<div class="erased alert alert-warning"> <gl-alert variant="warning" :dismissible="false">
<template v-if="isErasedByUser"> <template v-if="isErasedByUser">
{{ s__('Job|Job has been erased by') }} {{ s__('Job|Job has been erased by') }}
<gl-link :href="user.web_url"> {{ user.username }} </gl-link> <gl-link :href="user.web_url">{{ user.username }}</gl-link>
</template> </template>
<template v-else> <template v-else>
{{ s__('Job|Job has been erased') }} {{ s__('Job|Job has been erased') }}
</template> </template>
<timeago-tooltip :time="erasedAt" /> <timeago-tooltip :time="erasedAt" />
</div> </gl-alert>
</div> </div>
</template> </template>
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Erased block with erased job renders alert with erased text and variant 1`] = `
<div
class="gl-mt-3"
>
<div
class="gl-alert gl-alert-warning"
role="alert"
>
<svg
aria-hidden="true"
class="gl-icon s16 gl-alert-icon gl-alert-icon-no-title"
data-testid="warning-icon"
>
<use
href="#warning"
/>
</svg>
<!---->
<!---->
<div
class="gl-alert-body"
>
Job has been erased
<time
class=""
datetime="2016-11-07T11:11:16.525Z"
title="Nov 7, 2016 11:11am GMT+0000"
>
4 years ago
</time>
</div>
<!---->
</div>
</div>
`;
exports[`Erased block with job erased by user renders alert with erased by text and variant 1`] = `
<div
class="gl-mt-3"
>
<div
class="gl-alert gl-alert-warning"
role="alert"
>
<svg
aria-hidden="true"
class="gl-icon s16 gl-alert-icon gl-alert-icon-no-title"
data-testid="warning-icon"
>
<use
href="#warning"
/>
</svg>
<!---->
<!---->
<div
class="gl-alert-body"
>
Job has been erased by
<a
class="gl-link"
href="gitlab.com/root"
>
root
</a>
<time
class=""
datetime="2016-11-07T11:11:16.525Z"
title="Nov 7, 2016 11:11am GMT+0000"
>
4 years ago
</time>
</div>
<!---->
</div>
</div>
`;
...@@ -10,6 +10,8 @@ describe('Erased block', () => { ...@@ -10,6 +10,8 @@ describe('Erased block', () => {
const timeago = getTimeago(); const timeago = getTimeago();
const formattedDate = timeago.format(erasedAt); const formattedDate = timeago.format(erasedAt);
const findLink = () => wrapper.find(GlLink);
const createComponent = (props) => { const createComponent = (props) => {
wrapper = mount(ErasedBlock, { wrapper = mount(ErasedBlock, {
propsData: props, propsData: props,
...@@ -31,8 +33,12 @@ describe('Erased block', () => { ...@@ -31,8 +33,12 @@ describe('Erased block', () => {
}); });
}); });
it('renders alert with erased by text and variant', () => {
expect(wrapper.element).toMatchSnapshot();
});
it('renders username and link', () => { it('renders username and link', () => {
expect(wrapper.find(GlLink).attributes('href')).toEqual('gitlab.com/root'); expect(findLink().attributes('href')).toEqual('gitlab.com/root');
expect(wrapper.text().trim()).toContain('Job has been erased by'); expect(wrapper.text().trim()).toContain('Job has been erased by');
expect(wrapper.text().trim()).toContain('root'); expect(wrapper.text().trim()).toContain('root');
...@@ -50,6 +56,10 @@ describe('Erased block', () => { ...@@ -50,6 +56,10 @@ describe('Erased block', () => {
}); });
}); });
it('renders alert with erased text and variant', () => {
expect(wrapper.element).toMatchSnapshot();
});
it('renders username and link', () => { it('renders username and link', () => {
expect(wrapper.text().trim()).toContain('Job has been erased'); expect(wrapper.text().trim()).toContain('Job has been erased');
}); });
......
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