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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
686f7f5f
Commit
686f7f5f
authored
Apr 08, 2021
by
Thomas Randolph
Committed by
Phil Hughes
Apr 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass a pseudo Diff File from the notes app to the noteable discussion component
parent
6cd65aa2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
17 deletions
+139
-17
app/assets/javascripts/notes/components/discussion_notes.vue
app/assets/javascripts/notes/components/discussion_notes.vue
+2
-0
app/assets/javascripts/notes/components/noteable_note.vue
app/assets/javascripts/notes/components/noteable_note.vue
+13
-2
changelogs/unreleased/tor-defect-overview-placeholder-message-overview-file-source.yml
...ect-overview-placeholder-message-overview-file-source.yml
+6
-0
spec/frontend/notes/components/noteable_note_spec.js
spec/frontend/notes/components/noteable_note_spec.js
+118
-15
No files found.
app/assets/javascripts/notes/components/discussion_notes.vue
View file @
686f7f5f
...
@@ -121,6 +121,7 @@ export default {
...
@@ -121,6 +121,7 @@ export default {
:is=
"componentName(firstNote)"
:is=
"componentName(firstNote)"
:note=
"componentData(firstNote)"
:note=
"componentData(firstNote)"
:line=
"line || diffLine"
:line=
"line || diffLine"
:discussion-file=
"discussion.diff_file"
:commit=
"commit"
:commit=
"commit"
:help-page-path=
"helpPagePath"
:help-page-path=
"helpPagePath"
:show-reply-button=
"userCanReply"
:show-reply-button=
"userCanReply"
...
@@ -167,6 +168,7 @@ export default {
...
@@ -167,6 +168,7 @@ export default {
v-for=
"(note, index) in discussion.notes"
v-for=
"(note, index) in discussion.notes"
:key=
"note.id"
:key=
"note.id"
:note=
"componentData(note)"
:note=
"componentData(note)"
:discussion-file=
"discussion.diff_file"
:help-page-path=
"helpPagePath"
:help-page-path=
"helpPagePath"
:line=
"diffLine"
:line=
"diffLine"
:discussion-root=
"index === 0"
:discussion-root=
"index === 0"
...
...
app/assets/javascripts/notes/components/noteable_note.vue
View file @
686f7f5f
...
@@ -48,6 +48,11 @@ export default {
...
@@ -48,6 +48,11 @@ export default {
required
:
false
,
required
:
false
,
default
:
null
,
default
:
null
,
},
},
discussionFile
:
{
type
:
Object
,
required
:
false
,
default
:
null
,
},
helpPagePath
:
{
helpPagePath
:
{
type
:
String
,
type
:
String
,
required
:
false
,
required
:
false
,
...
@@ -167,12 +172,18 @@ export default {
...
@@ -167,12 +172,18 @@ export default {
return
commentLineOptions
(
lines
,
this
.
commentLineStart
,
this
.
line
.
line_code
);
return
commentLineOptions
(
lines
,
this
.
commentLineStart
,
this
.
line
.
line_code
);
},
},
diffFile
()
{
diffFile
()
{
let
fileResolvedFromAvailableSource
;
if
(
this
.
commentLineStart
.
line_code
)
{
if
(
this
.
commentLineStart
.
line_code
)
{
const
lineCode
=
this
.
commentLineStart
.
line_code
.
split
(
'
_
'
)[
0
];
const
lineCode
=
this
.
commentLineStart
.
line_code
.
split
(
'
_
'
)[
0
];
return
this
.
getDiffFileByHash
(
lineCode
);
fileResolvedFromAvailableSource
=
this
.
getDiffFileByHash
(
lineCode
);
}
if
(
!
fileResolvedFromAvailableSource
&&
this
.
discussionFile
)
{
fileResolvedFromAvailableSource
=
this
.
discussionFile
;
}
}
return
null
;
return
fileResolvedFromAvailableSource
||
null
;
},
},
},
},
created
()
{
created
()
{
...
...
changelogs/unreleased/tor-defect-overview-placeholder-message-overview-file-source.yml
0 → 100644
View file @
686f7f5f
---
title
:
Fill in all placeholder values in the apply suggestion commit message placeholder
text
merge_request
:
58136
author
:
type
:
other
spec/frontend/notes/components/noteable_note_spec.js
View file @
686f7f5f
import
{
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
escape
}
from
'
lodash
'
;
import
{
escape
}
from
'
lodash
'
;
import
Vue
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
DiffsModule
from
'
~/diffs/store/modules
'
;
import
NoteActions
from
'
~/notes/components/note_actions.vue
'
;
import
NoteActions
from
'
~/notes/components/note_actions.vue
'
;
import
NoteBody
from
'
~/notes/components/note_body.vue
'
;
import
NoteBody
from
'
~/notes/components/note_body.vue
'
;
import
NoteHeader
from
'
~/notes/components/note_header.vue
'
;
import
NoteHeader
from
'
~/notes/components/note_header.vue
'
;
import
issueNote
from
'
~/notes/components/noteable_note.vue
'
;
import
issueNote
from
'
~/notes/components/noteable_note.vue
'
;
import
createStore
from
'
~/notes/stores
'
;
import
NotesModule
from
'
~/notes/stores/modules
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
UserAvatarLink
from
'
~/vue_shared/components/user_avatar/user_avatar_link.vue
'
;
import
{
noteableDataMock
,
notesDataMock
,
note
}
from
'
../mock_data
'
;
import
{
noteableDataMock
,
notesDataMock
,
note
}
from
'
../mock_data
'
;
Vue
.
use
(
Vuex
);
const
singleLineNotePosition
=
{
line_range
:
{
start
:
{
line_code
:
'
abc_1_1
'
,
type
:
null
,
old_line
:
'
1
'
,
new_line
:
'
1
'
,
},
end
:
{
line_code
:
'
abc_1_1
'
,
type
:
null
,
old_line
:
'
1
'
,
new_line
:
'
1
'
,
},
},
};
describe
(
'
issue_note
'
,
()
=>
{
describe
(
'
issue_note
'
,
()
=>
{
let
store
;
let
store
;
let
wrapper
;
let
wrapper
;
const
findMultilineComment
=
()
=>
wrapper
.
find
(
'
[data-testid="multiline-comment"]
'
);
const
findMultilineComment
=
()
=>
wrapper
.
find
(
'
[data-testid="multiline-comment"]
'
);
const
createWrapper
=
(
props
=
{})
=>
{
const
createWrapper
=
(
props
=
{},
storeUpdater
=
(
s
)
=>
s
)
=>
{
store
=
createStore
();
store
=
new
Vuex
.
Store
(
storeUpdater
({
modules
:
{
notes
:
NotesModule
(),
diffs
:
DiffsModule
(),
},
}),
);
store
.
dispatch
(
'
setNoteableData
'
,
noteableDataMock
);
store
.
dispatch
(
'
setNoteableData
'
,
noteableDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
store
.
dispatch
(
'
setNotesData
'
,
notesDataMock
);
const
localVue
=
createLocalVue
();
wrapper
=
mount
(
issueNote
,
{
wrapper
=
mount
(
localVue
.
extend
(
issueNote
),
{
store
,
store
,
propsData
:
{
propsData
:
{
note
,
note
,
...
props
,
...
props
,
},
},
localVue
,
stubs
:
[
stubs
:
[
'
note-header
'
,
'
note-header
'
,
'
user-avatar-link
'
,
'
user-avatar-link
'
,
...
@@ -216,10 +249,14 @@ describe('issue_note', () => {
...
@@ -216,10 +249,14 @@ describe('issue_note', () => {
const
noteBodyComponent
=
wrapper
.
findComponent
(
NoteBody
);
const
noteBodyComponent
=
wrapper
.
findComponent
(
NoteBody
);
store
.
hotUpdate
({
store
.
hotUpdate
({
modules
:
{
notes
:
{
actions
:
{
actions
:
{
updateNote
()
{},
updateNote
()
{},
setSelectedCommentPositionHover
()
{},
setSelectedCommentPositionHover
()
{},
},
},
},
},
});
});
noteBodyComponent
.
vm
.
$emit
(
'
handleFormUpdate
'
,
noteBody
,
null
,
()
=>
{});
noteBodyComponent
.
vm
.
$emit
(
'
handleFormUpdate
'
,
noteBody
,
null
,
()
=>
{});
...
@@ -238,9 +275,13 @@ describe('issue_note', () => {
...
@@ -238,9 +275,13 @@ describe('issue_note', () => {
it
(
'
restores content of updated note
'
,
async
()
=>
{
it
(
'
restores content of updated note
'
,
async
()
=>
{
const
updatedText
=
'
updated note text
'
;
const
updatedText
=
'
updated note text
'
;
store
.
hotUpdate
({
store
.
hotUpdate
({
modules
:
{
notes
:
{
actions
:
{
actions
:
{
updateNote
()
{},
updateNote
()
{},
},
},
},
},
});
});
const
noteBody
=
wrapper
.
findComponent
(
NoteBody
);
const
noteBody
=
wrapper
.
findComponent
(
NoteBody
);
noteBody
.
vm
.
resetAutoSave
=
()
=>
{};
noteBody
.
vm
.
resetAutoSave
=
()
=>
{};
...
@@ -267,10 +308,14 @@ describe('issue_note', () => {
...
@@ -267,10 +308,14 @@ describe('issue_note', () => {
const
updateActions
=
()
=>
{
const
updateActions
=
()
=>
{
store
.
hotUpdate
({
store
.
hotUpdate
({
modules
:
{
notes
:
{
actions
:
{
actions
:
{
updateNote
,
updateNote
,
setSelectedCommentPositionHover
()
{},
setSelectedCommentPositionHover
()
{},
},
},
},
},
});
});
};
};
...
@@ -299,4 +344,62 @@ describe('issue_note', () => {
...
@@ -299,4 +344,62 @@ describe('issue_note', () => {
expect
(
updateNote
.
mock
.
calls
[
0
][
1
].
note
.
note
.
position
).
toBe
(
expectation
);
expect
(
updateNote
.
mock
.
calls
[
0
][
1
].
note
.
note
.
position
).
toBe
(
expectation
);
});
});
});
});
describe
(
'
diffFile
'
,
()
=>
{
it
.
each
`
scenario | files | noteDef
${
'
the note has no position
'
}
|
${
undefined
}
|
${
note
}
${
'
the Diffs store has no data
'
}
|
${[]}
|
${{
...
note
,
position
:
singleLineNotePosition
}
}
`
(
'
returns `null` when $scenario and no diff file is provided as a prop
'
,
({
noteDef
,
diffs
})
=>
{
const
storeUpdater
=
(
rawStore
)
=>
{
const
updatedStore
=
{
...
rawStore
};
if
(
diffs
)
{
updatedStore
.
modules
.
diffs
.
state
.
diffFiles
=
diffs
;
}
return
updatedStore
;
};
createWrapper
({
note
:
noteDef
,
discussionFile
:
null
},
storeUpdater
);
expect
(
wrapper
.
vm
.
diffFile
).
toBe
(
null
);
},
);
it
(
"
returns the correct diff file from the Diffs store if it's available
"
,
()
=>
{
createWrapper
(
{
note
:
{
...
note
,
position
:
singleLineNotePosition
},
},
(
rawStore
)
=>
{
const
updatedStore
=
{
...
rawStore
};
updatedStore
.
modules
.
diffs
.
state
.
diffFiles
=
[
{
file_hash
:
'
abc
'
,
testId
:
'
diffFileTest
'
},
];
return
updatedStore
;
},
);
expect
(
wrapper
.
vm
.
diffFile
.
testId
).
toBe
(
'
diffFileTest
'
);
});
it
(
'
returns the provided diff file if the more robust getters fail
'
,
()
=>
{
createWrapper
(
{
note
:
{
...
note
,
position
:
singleLineNotePosition
},
discussionFile
:
{
testId
:
'
diffFileTest
'
},
},
(
rawStore
)
=>
{
const
updatedStore
=
{
...
rawStore
};
updatedStore
.
modules
.
diffs
.
state
.
diffFiles
=
[];
return
updatedStore
;
},
);
expect
(
wrapper
.
vm
.
diffFile
.
testId
).
toBe
(
'
diffFileTest
'
);
});
});
});
});
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