Add i18n and update specs for ShaMismatch vue component

This commit is contained in:
George Tsiolis 2018-03-19 18:13:49 +02:00
parent a520ab64db
commit 39e92fd851
6 changed files with 36 additions and 15 deletions

View file

@ -17,8 +17,8 @@ export default {
/>
<div class="media-body space-children">
<span class="bold">
The source branch HEAD has recently changed.
Please reload the page and review the changes before merging.
{{ s__(`mrWidget|The source branch HEAD has recently changed.
Please reload the page and review the changes before merging`) }}
</span>
</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 conflictsComponent from '~/vue_merge_request_widget/components/states/mr_widget_conflicts.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import removeBreakLine from 'spec/helpers/vue_component_helper';
describe('MRWidgetConflicts', () => {
let Component;
@ -78,8 +79,9 @@ describe('MRWidgetConflicts', () => {
});
it('should tell you to rebase locally', () => {
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toContain('Fast-forward merge is not possible.');
expect(vm.$el.textContent.trim().replace(/\s\s+/g, ' ')).toContain('To merge this request, first rebase locally');
expect(
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 pipelineBlockedComponent from '~/vue_merge_request_widget/components/states/mr_widget_pipeline_blocked.vue';
import mountComponent from 'spec/helpers/vue_mount_component_helper';
import removeBreakLine from 'spec/helpers/vue_component_helper';
describe('MRWidgetPipelineBlocked', () => {
let vm;
@ -18,6 +19,8 @@ describe('MRWidgetPipelineBlocked', () => {
});
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 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('template', () => {
let vm;
beforeEach(() => {
const Component = Vue.extend(ShaMismatch);
const vm = new Component({
el: document.createElement('div'),
});
it('should have correct elements', () => {
expect(vm.$el.classList.contains('mr-widget-body')).toBeTruthy();
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.');
});
vm = mountComponent(Component);
});
afterEach(() => {
vm.$destroy();
});
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');
});
});