Commit 3fbaa336 authored by HypeMC's avatar HypeMC

Fix file mode changes not always visible in MRs

File mode changes in MRs weren't visible when the content was changed
or file renamed.

Changelog: fixed
parent 817d5d87
...@@ -14,7 +14,6 @@ import { ...@@ -14,7 +14,6 @@ import {
import { escape } from 'lodash'; import { escape } from 'lodash';
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import { IdState } from 'vendor/vue-virtual-scroller'; import { IdState } from 'vendor/vue-virtual-scroller';
import { diffViewerModes } from '~/ide/constants';
import { scrollToElement } from '~/lib/utils/common_utils'; import { scrollToElement } from '~/lib/utils/common_utils';
import { truncateSha } from '~/lib/utils/text_utility'; import { truncateSha } from '~/lib/utils/text_utility';
import { __, s__, sprintf } from '~/locale'; import { __, s__, sprintf } from '~/locale';
...@@ -181,7 +180,7 @@ export default { ...@@ -181,7 +180,7 @@ export default {
return this.diffFile.renamed_file; return this.diffFile.renamed_file;
}, },
isModeChanged() { isModeChanged() {
return this.diffFile.viewer.name === diffViewerModes.mode_changed; return this.diffFile.mode_changed;
}, },
expandDiffToFullFileTitle() { expandDiffToFullFileTitle() {
if (this.diffFile.isShowingFullFile) { if (this.diffFile.isShowingFullFile) {
......
...@@ -240,18 +240,19 @@ describe('DiffFileHeader component', () => { ...@@ -240,18 +240,19 @@ describe('DiffFileHeader component', () => {
}); });
describe('for any file', () => { describe('for any file', () => {
const otherModes = Object.keys(diffViewerModes).filter((m) => m !== 'mode_changed'); const allModes = Object.keys(diffViewerModes).map((m) => [m]);
it('for mode_changed file mode displays mode changes', () => { it.each(allModes)('for %s file mode displays mode changes', (mode) => {
createComponent({ createComponent({
props: { props: {
diffFile: { diffFile: {
...diffFile, ...diffFile,
mode_changed: true,
a_mode: 'old-mode', a_mode: 'old-mode',
b_mode: 'new-mode', b_mode: 'new-mode',
viewer: { viewer: {
...diffFile.viewer, ...diffFile.viewer,
name: diffViewerModes.mode_changed, name: diffViewerModes[mode],
}, },
}, },
}, },
...@@ -259,13 +260,14 @@ describe('DiffFileHeader component', () => { ...@@ -259,13 +260,14 @@ describe('DiffFileHeader component', () => {
expect(findModeChangedLine().text()).toMatch(/old-mode.+new-mode/); expect(findModeChangedLine().text()).toMatch(/old-mode.+new-mode/);
}); });
it.each(otherModes.map((m) => [m]))( it.each(allModes.filter((m) => m[0] !== 'mode_changed'))(
'for %s file mode does not display mode changes', 'for %s file mode does not display mode changes',
(mode) => { (mode) => {
createComponent({ createComponent({
props: { props: {
diffFile: { diffFile: {
...diffFile, ...diffFile,
mode_changed: false,
a_mode: 'old-mode', a_mode: 'old-mode',
b_mode: 'new-mode', b_mode: 'new-mode',
viewer: { viewer: {
......
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