Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
f9e290b9
Commit
f9e290b9
authored
Sep 11, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed diff store actions spec
Updated diff mutations and utils spec to check for legacy notes
parent
8064ab84
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
140 additions
and
1 deletion
+140
-1
changelogs/unreleased/mr-legacy-diff-notes.yml
changelogs/unreleased/mr-legacy-diff-notes.yml
+1
-1
spec/javascripts/diffs/store/actions_spec.js
spec/javascripts/diffs/store/actions_spec.js
+1
-0
spec/javascripts/diffs/store/mutations_spec.js
spec/javascripts/diffs/store/mutations_spec.js
+67
-0
spec/javascripts/diffs/store/utils_spec.js
spec/javascripts/diffs/store/utils_spec.js
+71
-0
No files found.
changelogs/unreleased/mr-legacy-diff-notes.yml
View file @
f9e290b9
---
---
title
:
Correctly show legacy diff notes in the merge request changes tab
title
:
Correctly show legacy diff notes in the merge request changes tab
merge_request
:
merge_request
:
21652
author
:
author
:
type
:
fixed
type
:
fixed
spec/javascripts/diffs/store/actions_spec.js
View file @
f9e290b9
...
@@ -157,6 +157,7 @@ describe('DiffsStoreActions', () => {
...
@@ -157,6 +157,7 @@ describe('DiffsStoreActions', () => {
newPath
:
'
file1
'
,
newPath
:
'
file1
'
,
oldLine
:
5
,
oldLine
:
5
,
oldPath
:
'
file2
'
,
oldPath
:
'
file2
'
,
lineCode
:
'
ABC_1_1
'
,
},
},
},
},
},
},
...
...
spec/javascripts/diffs/store/mutations_spec.js
View file @
f9e290b9
...
@@ -229,6 +229,73 @@ describe('DiffsStoreMutations', () => {
...
@@ -229,6 +229,73 @@ describe('DiffsStoreMutations', () => {
expect
(
state
.
diffFiles
[
0
].
highlightedDiffLines
[
0
].
discussions
.
length
).
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
[
1
].
id
).
toEqual
(
2
);
});
});
it
(
'
should add legacy discussions to the given line
'
,
()
=>
{
const
diffPosition
=
{
baseSha
:
'
ed13df29948c41ba367caa757ab3ec4892509910
'
,
headSha
:
'
b921914f9a834ac47e6fd9420f78db0f83559130
'
,
newLine
:
null
,
newPath
:
'
500-lines-4.txt
'
,
oldLine
:
5
,
oldPath
:
'
500-lines-4.txt
'
,
startSha
:
'
ed13df29948c41ba367caa757ab3ec4892509910
'
,
lineCode
:
'
ABC_1
'
,
};
const
state
=
{
diffFiles
:
[
{
fileHash
:
'
ABC
'
,
parallelDiffLines
:
[
{
left
:
{
lineCode
:
'
ABC_1
'
,
discussions
:
[],
},
right
:
{
lineCode
:
'
ABC_1
'
,
discussions
:
[],
},
},
],
highlightedDiffLines
:
[
{
lineCode
:
'
ABC_1
'
,
discussions
:
[],
},
],
},
],
};
const
discussions
=
[
{
id
:
1
,
line_code
:
'
ABC_1
'
,
diff_discussion
:
true
,
},
{
id
:
2
,
line_code
:
'
ABC_1
'
,
diff_discussion
:
true
,
},
];
const
diffPositionByLineCode
=
{
ABC_1
:
diffPosition
,
};
mutations
[
types
.
SET_LINE_DISCUSSIONS_FOR_FILE
](
state
,
{
fileHash
:
'
ABC
'
,
discussions
,
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].highlightedDiffLines[0].discussions.length).toEqual(2);
// expect(state.diffFiles[0].highlightedDiffLines[0].discussions[1].id).toEqual(2);
});
});
});
describe
(
'
REMOVE_LINE_DISCUSSIONS
'
,
()
=>
{
describe
(
'
REMOVE_LINE_DISCUSSIONS
'
,
()
=>
{
...
...
spec/javascripts/diffs/store/utils_spec.js
View file @
f9e290b9
...
@@ -3,6 +3,7 @@ import {
...
@@ -3,6 +3,7 @@ import {
LINE_POSITION_LEFT
,
LINE_POSITION_LEFT
,
LINE_POSITION_RIGHT
,
LINE_POSITION_RIGHT
,
TEXT_DIFF_POSITION_TYPE
,
TEXT_DIFF_POSITION_TYPE
,
LEGACY_DIFF_NOTE_TYPE
,
DIFF_NOTE_TYPE
,
DIFF_NOTE_TYPE
,
NEW_LINE_TYPE
,
NEW_LINE_TYPE
,
OLD_LINE_TYPE
,
OLD_LINE_TYPE
,
...
@@ -151,6 +152,63 @@ describe('DiffsStoreUtils', () => {
...
@@ -151,6 +152,63 @@ describe('DiffsStoreUtils', () => {
data
:
postData
,
data
:
postData
,
});
});
});
});
it
(
'
should create legacy note form data
'
,
()
=>
{
const
diffFile
=
getDiffFileMock
();
delete
diffFile
.
diffRefs
.
startSha
;
noteableDataMock
.
targetType
=
MERGE_REQUEST_NOTEABLE_TYPE
;
const
options
=
{
note
:
'
Hello world!
'
,
noteableData
:
noteableDataMock
,
noteableType
:
MERGE_REQUEST_NOTEABLE_TYPE
,
diffFile
,
noteTargetLine
:
{
lineCode
:
'
1c497fbb3a46b78edf04cc2a2fa33f67e3ffbe2a_1_3
'
,
metaData
:
null
,
newLine
:
3
,
oldLine
:
1
,
},
diffViewType
:
PARALLEL_DIFF_VIEW_TYPE
,
linePosition
:
LINE_POSITION_LEFT
,
};
const
position
=
JSON
.
stringify
({
base_sha
:
diffFile
.
diffRefs
.
baseSha
,
start_sha
:
undefined
,
head_sha
:
diffFile
.
diffRefs
.
headSha
,
old_path
:
diffFile
.
oldPath
,
new_path
:
diffFile
.
newPath
,
position_type
:
TEXT_DIFF_POSITION_TYPE
,
old_line
:
options
.
noteTargetLine
.
oldLine
,
new_line
:
options
.
noteTargetLine
.
newLine
,
});
const
postData
=
{
view
:
options
.
diffViewType
,
line_type
:
options
.
linePosition
===
LINE_POSITION_RIGHT
?
NEW_LINE_TYPE
:
OLD_LINE_TYPE
,
merge_request_diff_head_sha
:
diffFile
.
diffRefs
.
headSha
,
in_reply_to_discussion_id
:
''
,
note_project_id
:
''
,
target_type
:
options
.
noteableType
,
target_id
:
options
.
noteableData
.
id
,
note
:
{
noteable_type
:
options
.
noteableType
,
noteable_id
:
options
.
noteableData
.
id
,
commit_id
:
''
,
type
:
LEGACY_DIFF_NOTE_TYPE
,
line_code
:
options
.
noteTargetLine
.
lineCode
,
note
:
options
.
note
,
position
,
},
};
expect
(
utils
.
getNoteFormData
(
options
)).
toEqual
({
endpoint
:
options
.
noteableData
.
create_note_path
,
data
:
postData
,
});
});
});
});
describe
(
'
addLineReferences
'
,
()
=>
{
describe
(
'
addLineReferences
'
,
()
=>
{
...
@@ -300,5 +358,18 @@ describe('DiffsStoreUtils', () => {
...
@@ -300,5 +358,18 @@ describe('DiffsStoreUtils', () => {
utils
.
isDiscussionApplicableToLine
(
discussions
.
outDatedDiscussion1
,
diffPosition
),
utils
.
isDiscussionApplicableToLine
(
discussions
.
outDatedDiscussion1
,
diffPosition
),
).
toBe
(
false
);
).
toBe
(
false
);
});
});
it
(
'
returns true when line codes match and discussion does not contain position
'
,
()
=>
{
const
discussion
=
{
...
discussions
.
outDatedDiscussion1
,
line_code
:
'
ABC_1
'
};
delete
discussion
.
original_position
;
delete
discussion
.
position
;
expect
(
utils
.
isDiscussionApplicableToLine
(
discussion
,
{
...
diffPosition
,
lineCode
:
'
ABC_1
'
,
}),
).
toBe
(
true
);
});
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment