Merge branch 'update-unresolved-discussions-vue-component' into 'master'

Add i18n and update specs for ShaMismatch vue component

See merge request gitlab-org/gitlab-ce!17870
This commit is contained in:
Clement Ho 2018-03-27 19:15:42 +00:00
commit d352057333
6 changed files with 36 additions and 15 deletions

View file

@ -17,8 +17,8 @@ export default {
/> />
<div class="media-body space-children"> <div class="media-body space-children">
<span class="bold"> <span class="bold">
The source branch HEAD has recently changed. {{ s__(`mrWidget|The source branch HEAD has recently changed.
Please reload the page and review the changes before merging. Please reload the page and review the changes before merging`) }}
</span> </span>
</div> </div>
</div> </div>

View file

@ -0,0 +1,5 @@
---
title: Add i18n and update specs for ShaMismatch vue component
merge_request: 17870
author: George Tsiolis
type: performance

View file

@ -0,0 +1,3 @@
export default function removeBreakLine (data) {
return data.replace(/\r?\n|\r/g, ' ');
}

View file

@ -1,6 +1,7 @@
import Vue from 'vue'; import Vue from 'vue';
import conflictsComponent from '~/vue_merge_request_widget/components/states/mr_widget_conflicts.vue'; import conflictsComponent from '~/vue_merge_request_widget/components/states/mr_widget_conflicts.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
import removeBreakLine from 'spec/helpers/vue_component_helper';
describe('MRWidgetConflicts', () => { describe('MRWidgetConflicts', () => {
let Component; let Component;
@ -78,8 +79,9 @@ describe('MRWidgetConflicts', () => {
}); });
it('should tell you to rebase locally', () => { it('should tell you to rebase locally', () => {
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toContain('Fast-forward merge is not possible.'); expect(
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toContain('To merge this request, first rebase locally'); removeBreakLine(vm.$el.textContent).trim(),
).toContain('Fast-forward merge is not possible. To merge this request, first rebase locally.');
}); });
}); });
}); });

View file

@ -1,6 +1,7 @@
import Vue from 'vue'; import Vue from 'vue';
import pipelineBlockedComponent from '~/vue_merge_request_widget/components/states/mr_widget_pipeline_blocked.vue'; import pipelineBlockedComponent from '~/vue_merge_request_widget/components/states/mr_widget_pipeline_blocked.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper'; import mountComponent from 'spec/helpers/vue_mount_component_helper';
import removeBreakLine from 'spec/helpers/vue_component_helper';
describe('MRWidgetPipelineBlocked', () => { describe('MRWidgetPipelineBlocked', () => {
let vm; let vm;
@ -18,6 +19,8 @@ describe('MRWidgetPipelineBlocked', () => {
}); });
it('renders information text', () => { it('renders information text', () => {
expect(vm.$el.textContent.trim().replace(/[\r\n]+/g, ' ')).toContain('Pipeline blocked. The pipeline for this merge request requires a manual action to proceed'); expect(
removeBreakLine(vm.$el.textContent).trim(),
).toContain('Pipeline blocked. The pipeline for this merge request requires a manual action to proceed');
}); });
}); });

View file

@ -1,17 +1,25 @@
import Vue from 'vue'; import Vue from 'vue';
import ShaMismatch from '~/vue_merge_request_widget/components/states/sha_mismatch.vue'; import ShaMismatch from '~/vue_merge_request_widget/components/states/sha_mismatch.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import removeBreakLine from 'spec/helpers/vue_component_helper';
describe('ShaMismatch', () => { describe('ShaMismatch', () => {
describe('template', () => { let vm;
beforeEach(() => {
const Component = Vue.extend(ShaMismatch); const Component = Vue.extend(ShaMismatch);
const vm = new Component({ vm = mountComponent(Component);
el: document.createElement('div'), });
});
it('should have correct elements', () => { afterEach(() => {
expect(vm.$el.classList.contains('mr-widget-body')).toBeTruthy(); vm.$destroy();
expect(vm.$el.querySelector('button').getAttribute('disabled')).toBeTruthy(); });
expect(vm.$el.innerText).toContain('The source branch HEAD has recently changed.');
expect(vm.$el.innerText).toContain('Please reload the page and review the changes before merging.'); it('should render information message', () => {
}); expect(vm.$el.querySelector('button').disabled).toEqual(true);
expect(
removeBreakLine(vm.$el.textContent).trim(),
).toContain('The source branch HEAD has recently changed. Please reload the page and review the changes before merging');
}); });
}); });