Commit ef4e3b6e authored by Phil Hughes's avatar Phil Hughes

Moved legacy diff note check into util method

Un-commented out expect checks in mutation spec
parent f9e290b9
import Vue from 'vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { isLegacyDiffNote } from '~/notes/stores/utils';
import {
findDiffFile,
addLineReferences,
......@@ -90,8 +91,7 @@ export default {
const firstDiscussion = discussions[0];
const isDiffDiscussion = firstDiscussion.diff_discussion;
const hasLineCode = firstDiscussion.line_code;
const isResolvable =
firstDiscussion.resolvable || (!firstDiscussion.resolvable && !firstDiscussion.position);
const isResolvable = firstDiscussion.resolvable || isLegacyDiffNote(firstDiscussion);
const diffPosition = diffPositionByLineCode[firstDiscussion.line_code];
if (
......
......@@ -2,6 +2,7 @@ import AjaxCache from '~/lib/utils/ajax_cache';
const REGEX_QUICK_ACTIONS = /^\/\w+.*$/gm;
export const isLegacyDiffNote = note => !note.resolvable && !note.position;
export const findNoteObjectById = (notes, id) => notes.filter(n => n.id === id)[0];
export const getQuickActionText = note => {
......@@ -27,11 +28,7 @@ export const getQuickActionText = note => {
export const reduceDiscussionsToLineCodes = selectedDiscussions =>
selectedDiscussions.reduce((acc, note) => {
if (
note.diff_discussion &&
note.line_code &&
(note.resolvable || (!note.resolvable && !note.position))
) {
if (note.diff_discussion && note.line_code && (note.resolvable || isLegacyDiffNote(note))) {
// For context about line notes: there might be multiple notes with the same line code
const items = acc[note.line_code] || [];
items.push(note);
......
......@@ -290,11 +290,11 @@ describe('DiffsStoreMutations', () => {
diffPositionByLineCode,
});
// expect(state.diffFiles[0].parallelDiffLines[0].left.discussions.length).toEqual(2);
// expect(state.diffFiles[0].parallelDiffLines[0].left.discussions[1].id).toEqual(2);
expect(state.diffFiles[0].parallelDiffLines[0].left.discussions.length).toEqual(2);
expect(state.diffFiles[0].parallelDiffLines[0].left.discussions[1].id).toEqual(2);
// expect(state.diffFiles[0].highlightedDiffLines[0].discussions.length).toEqual(2);
// expect(state.diffFiles[0].highlightedDiffLines[0].discussions[1].id).toEqual(2);
expect(state.diffFiles[0].highlightedDiffLines[0].discussions.length).toEqual(2);
expect(state.diffFiles[0].highlightedDiffLines[0].discussions[1].id).toEqual(2);
});
});
......
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