Commit 423fcb47 authored by Murat Dogan's avatar Murat Dogan Committed by Phil Hughes

mergeError message has been binded using v-html directive

parent d94b1621
<script>
import { n__ } from '~/locale';
import { stripHtml } from '~/lib/utils/text_utility';
import statusIcon from '../mr_widget_status_icon.vue';
import eventHub from '../../event_hub';
......@@ -27,6 +28,9 @@ export default {
},
computed: {
mergeError() {
return this.mr.mergeError ? stripHtml(this.mr.mergeError, ' ').trim() : '';
},
timerText() {
return n__(
'Refreshing in a second to show the updated status...',
......@@ -83,9 +87,9 @@ export default {
<span class="bold">
<span
class="has-error-message"
v-if="mr.mergeError"
v-if="mergeError"
>
{{ mr.mergeError }}.
{{ mergeError }}.
</span>
<span v-else>
{{ s__("mrWidget|Merge failed.") }}
......
---
title: mergeError message has been binded using v-html directive
merge_request: 19058
author: Murat Dogan
type: fixed
......@@ -6,6 +6,7 @@ import mountComponent from 'spec/helpers/vue_mount_component_helper';
describe('MRWidgetFailedToMerge', () => {
const dummyIntervalId = 1337;
let Component;
let mr;
let vm;
beforeEach(() => {
......@@ -13,10 +14,11 @@ describe('MRWidgetFailedToMerge', () => {
spyOn(eventHub, '$emit');
spyOn(window, 'setInterval').and.returnValue(dummyIntervalId);
spyOn(window, 'clearInterval').and.stub();
mr = {
mergeError: 'Merge error happened',
};
vm = mountComponent(Component, {
mr: {
mergeError: 'Merge error happened.',
},
mr,
});
});
......@@ -44,6 +46,19 @@ describe('MRWidgetFailedToMerge', () => {
expect(vm.timerText).toEqual('Refreshing in a second to show the updated status...');
});
});
describe('mergeError', () => {
it('removes forced line breaks', done => {
mr.mergeError = 'contains<br />line breaks<br />';
Vue.nextTick()
.then(() => {
expect(vm.mergeError).toBe('contains line breaks');
})
.then(done)
.catch(done.fail);
});
});
});
describe('created', () => {
......@@ -103,7 +118,7 @@ describe('MRWidgetFailedToMerge', () => {
it('renders given error', () => {
expect(vm.$el.querySelector('.has-error-message').textContent.trim()).toEqual(
'Merge error happened..',
'Merge error happened.',
);
});
......
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