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