Commit 96e5bc59 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'file-mode-changes-in-mr-fix' into 'master'

File mode changes are not always visible in the merge request diff view

See merge request gitlab-org/gitlab!72937
parents 82e542cd 3fbaa336
...@@ -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) {
......
...@@ -241,18 +241,19 @@ describe('DiffFileHeader component', () => { ...@@ -241,18 +241,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],
}, },
}, },
}, },
...@@ -260,13 +261,14 @@ describe('DiffFileHeader component', () => { ...@@ -260,13 +261,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