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
Léo-Paul Géneau
gitlab-ce
Commits
106f0df3
Commit
106f0df3
authored
Aug 11, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken spec for issuable shortcuts and notes
parent
e7d87446
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
16 deletions
+32
-16
app/assets/javascripts/notes/components/issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+11
-1
app/assets/javascripts/notes/components/issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+2
-2
app/assets/javascripts/shortcuts_issuable.js
app/assets/javascripts/shortcuts_issuable.js
+1
-0
spec/javascripts/notes/components/issue_note_app_spec.js
spec/javascripts/notes/components/issue_note_app_spec.js
+4
-0
spec/javascripts/notes_spec.js
spec/javascripts/notes_spec.js
+5
-4
spec/javascripts/shortcuts_issuable_spec.js
spec/javascripts/shortcuts_issuable_spec.js
+9
-9
No files found.
app/assets/javascripts/notes/components/issue_comment_form.vue
View file @
106f0df3
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
import
'
../../autosave
'
;
import
'
../../autosave
'
;
export
default
{
export
default
{
name
:
'
issueCommentForm
'
,
data
()
{
data
()
{
return
{
return
{
note
:
''
,
note
:
''
,
...
@@ -92,7 +93,7 @@
...
@@ -92,7 +93,7 @@
'
saveNote
'
,
'
saveNote
'
,
]),
]),
setIsSubmitButtonDisabled
(
note
,
isSubmitting
)
{
setIsSubmitButtonDisabled
(
note
,
isSubmitting
)
{
if
(
!
_
.
isEmpty
(
note
)
&&
!
isSubmitting
)
{
if
(
!
_
.
isEmpty
(
note
)
&&
!
isSubmitting
)
{
this
.
isSubmitButtonDisabled
=
false
;
this
.
isSubmitButtonDisabled
=
false
;
}
else
{
}
else
{
this
.
isSubmitButtonDisabled
=
true
;
this
.
isSubmitButtonDisabled
=
true
;
...
@@ -187,6 +188,13 @@
...
@@ -187,6 +188,13 @@
initAutoSave
()
{
initAutoSave
()
{
this
.
autosave
=
new
Autosave
(
$
(
this
.
$refs
.
textarea
),
[
'
Note
'
,
'
Issue
'
,
this
.
getIssueData
.
id
]);
this
.
autosave
=
new
Autosave
(
$
(
this
.
$refs
.
textarea
),
[
'
Note
'
,
'
Issue
'
,
this
.
getIssueData
.
id
]);
},
},
initTaskList
()
{
return
new
TaskList
({
dataType
:
'
note
'
,
fieldName
:
'
note
'
,
selector
:
'
.notes
'
,
});
}
},
},
mounted
()
{
mounted
()
{
// jQuery is needed here because it is a custom event being dispatched with jQuery.
// jQuery is needed here because it is a custom event being dispatched with jQuery.
...
@@ -195,6 +203,7 @@
...
@@ -195,6 +203,7 @@
});
});
this
.
initAutoSave
();
this
.
initAutoSave
();
this
.
initTaskList
();
},
},
};
};
</
script
>
</
script
>
...
@@ -227,6 +236,7 @@
...
@@ -227,6 +236,7 @@
:quick-actions-docs=
"quickActionsDocsUrl"
:quick-actions-docs=
"quickActionsDocsUrl"
:add-spacing-classes=
"false"
>
:add-spacing-classes=
"false"
>
<textarea
<textarea
id=
"note-body"
name=
"note[note]"
name=
"note[note]"
class=
"note-textarea js-vue-comment-form js-gfm-input js-autosize markdown-area"
class=
"note-textarea js-vue-comment-form js-gfm-input js-autosize markdown-area"
data-supports-quick-actions=
"true"
data-supports-quick-actions=
"true"
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
View file @
106f0df3
<
script
>
<
script
>
/* global Flash */
/* global Flash */
import
{
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
{
mapGetters
,
mapActions
}
from
'
vuex
'
;
import
store
from
'
../stores/
'
;
import
store
from
'
../stores/
'
;
import
*
as
constants
from
'
../constants
'
;
import
*
as
constants
from
'
../constants
'
;
...
@@ -13,7 +12,7 @@
...
@@ -13,7 +12,7 @@
import
loadingIcon
from
'
../../vue_shared/components/loading_icon.vue
'
;
import
loadingIcon
from
'
../../vue_shared/components/loading_icon.vue
'
;
export
default
{
export
default
{
name
:
'
IssueNotes
'
,
name
:
'
issueNotesApp
'
,
props
:
{
props
:
{
issueData
:
{
issueData
:
{
type
:
Object
,
type
:
Object
,
...
@@ -114,6 +113,7 @@
...
@@ -114,6 +113,7 @@
},
},
mounted
()
{
mounted
()
{
this
.
fetchNotes
();
this
.
fetchNotes
();
const
parentElement
=
this
.
$el
.
parentElement
;
const
parentElement
=
this
.
$el
.
parentElement
;
if
(
parentElement
&&
if
(
parentElement
&&
...
...
app/assets/javascripts/shortcuts_issuable.js
View file @
106f0df3
...
@@ -63,6 +63,7 @@ import './shortcuts_navigation';
...
@@ -63,6 +63,7 @@ import './shortcuts_navigation';
quote
=
_
.
map
(
selected
.
split
(
"
\n
"
),
function
(
val
)
{
quote
=
_
.
map
(
selected
.
split
(
"
\n
"
),
function
(
val
)
{
return
(
"
>
"
+
val
).
trim
()
+
"
\n
"
;
return
(
"
>
"
+
val
).
trim
()
+
"
\n
"
;
});
});
// If replyField already has some content, add a newline before our quote
// If replyField already has some content, add a newline before our quote
separator
=
replyField
.
val
().
trim
()
!==
""
&&
"
\n\n
"
||
''
;
separator
=
replyField
.
val
().
trim
()
!==
""
&&
"
\n\n
"
||
''
;
replyField
.
val
(
function
(
a
,
current
)
{
replyField
.
val
(
function
(
a
,
current
)
{
...
...
spec/javascripts/notes/components/issue_note_app_spec.js
View file @
106f0df3
...
@@ -261,4 +261,8 @@ describe('issue_note_app', () => {
...
@@ -261,4 +261,8 @@ describe('issue_note_app', () => {
it
(
'
should show flash error message when new comment failed to be posted
'
,
()
=>
{});
it
(
'
should show flash error message when new comment failed to be posted
'
,
()
=>
{});
it
(
'
should show flash error message when comment failed to be updated
'
,
()
=>
{});
it
(
'
should show flash error message when comment failed to be updated
'
,
()
=>
{});
});
});
describe
(
'
shortcuts issuable spec
'
,
()
=>
{
});
});
});
spec/javascripts/notes_spec.js
View file @
106f0df3
...
@@ -53,17 +53,18 @@ import '~/notes';
...
@@ -53,17 +53,18 @@ import '~/notes';
it
(
'
modifies the Markdown field
'
,
function
()
{
it
(
'
modifies the Markdown field
'
,
function
()
{
const
changeEvent
=
document
.
createEvent
(
'
HTMLEvents
'
);
const
changeEvent
=
document
.
createEvent
(
'
HTMLEvents
'
);
changeEvent
.
initEvent
(
'
change
'
,
true
,
true
);
changeEvent
.
initEvent
(
'
change
'
,
true
,
true
);
$
(
'
input[type=checkbox]
'
).
attr
(
'
checked
'
,
true
)[
0
].
dispatchEvent
(
changeEvent
);
$
(
'
input[type=checkbox]
'
).
attr
(
'
checked
'
,
true
)[
1
].
dispatchEvent
(
changeEvent
);
expect
(
$
(
'
.js-task-list-field
'
).
val
()).
toBe
(
'
- [x] Task List Item
'
);
expect
(
$
(
'
.js-task-list-field.original-task-list
'
).
val
()).
toBe
(
'
- [x] Task List Item
'
);
});
});
it
(
'
submits an ajax request on tasklist:changed
'
,
function
()
{
it
(
'
submits an ajax request on tasklist:changed
'
,
function
()
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
spyOn
(
jQuery
,
'
ajax
'
).
and
.
callFake
(
function
(
req
)
{
expect
(
req
.
type
).
toBe
(
'
PATCH
'
);
expect
(
req
.
type
).
toBe
(
'
PATCH
'
);
expect
(
req
.
url
).
toBe
(
'
http://test.host/frontend-fixtures/merge-requests-project/
notes/3
'
);
expect
(
req
.
url
).
toBe
(
'
http://test.host/frontend-fixtures/merge-requests-project/
merge_requests/1.json
'
);
return
expect
(
req
.
data
.
note
).
not
.
toBe
(
null
);
return
expect
(
req
.
data
.
note
).
not
.
toBe
(
null
);
});
});
$
(
'
.js-task-list-field
'
).
trigger
(
'
tasklist:changed
'
);
$
(
'
.js-task-list-field
.original-task-list
'
).
trigger
(
'
tasklist:changed
'
);
});
});
});
});
...
...
spec/javascripts/shortcuts_issuable_spec.js
View file @
106f0df3
...
@@ -9,7 +9,7 @@ describe('ShortcutsIssuable', () => {
...
@@ -9,7 +9,7 @@ describe('ShortcutsIssuable', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
loadFixtures
(
fixtureName
);
loadFixtures
(
fixtureName
);
document
.
querySelector
(
'
.js-new-note-form
'
).
classList
.
add
(
'
js-main-target-form
'
);
document
.
querySelector
(
'
.js-new-note-form
'
).
classList
.
add
(
'
js-main-target-form
'
);
this
.
shortcut
=
new
ShortcutsIssuable
();
this
.
shortcut
=
new
ShortcutsIssuable
(
true
);
});
});
describe
(
'
replyWithSelectedText
'
,
()
=>
{
describe
(
'
replyWithSelectedText
'
,
()
=>
{
// Stub window.gl.utils.getSelectedFragment to return a node with the provided HTML.
// Stub window.gl.utils.getSelectedFragment to return a node with the provided HTML.
...
@@ -21,15 +21,15 @@ describe('ShortcutsIssuable', () => {
...
@@ -21,15 +21,15 @@ describe('ShortcutsIssuable', () => {
};
};
};
};
beforeEach
(()
=>
{
beforeEach
(()
=>
{
this
.
selector
=
'
form.js-main-target-form textarea#note-body
'
;
this
.
selector
=
'
.js-main-target-form #note_note
'
;
});
});
describe
(
'
with empty selection
'
,
()
=>
{
describe
(
'
with empty selection
'
,
()
=>
{
it
(
'
does not return an error
'
,
()
=>
{
it
(
'
does not return an error
'
,
()
=>
{
this
.
shortcut
.
replyWithSelectedText
();
this
.
shortcut
.
replyWithSelectedText
(
true
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
''
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
''
);
});
});
it
(
'
triggers `focus`
'
,
()
=>
{
it
(
'
triggers `focus`
'
,
()
=>
{
this
.
shortcut
.
replyWithSelectedText
();
this
.
shortcut
.
replyWithSelectedText
(
true
);
expect
(
document
.
activeElement
).
toBe
(
document
.
querySelector
(
this
.
selector
));
expect
(
document
.
activeElement
).
toBe
(
document
.
querySelector
(
this
.
selector
));
});
});
});
});
...
@@ -40,7 +40,7 @@ describe('ShortcutsIssuable', () => {
...
@@ -40,7 +40,7 @@ describe('ShortcutsIssuable', () => {
it
(
'
leaves existing input intact
'
,
()
=>
{
it
(
'
leaves existing input intact
'
,
()
=>
{
$
(
this
.
selector
).
val
(
'
This text was already here.
'
);
$
(
this
.
selector
).
val
(
'
This text was already here.
'
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
'
This text was already here.
'
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
'
This text was already here.
'
);
this
.
shortcut
.
replyWithSelectedText
();
this
.
shortcut
.
replyWithSelectedText
(
true
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
'
This text was already here.
\n\n
> Selected text.
\n\n
'
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
'
This text was already here.
\n\n
> Selected text.
\n\n
'
);
});
});
it
(
'
triggers `input`
'
,
()
=>
{
it
(
'
triggers `input`
'
,
()
=>
{
...
@@ -48,25 +48,25 @@ describe('ShortcutsIssuable', () => {
...
@@ -48,25 +48,25 @@ describe('ShortcutsIssuable', () => {
$
(
this
.
selector
).
on
(
'
input
'
,
()
=>
{
$
(
this
.
selector
).
on
(
'
input
'
,
()
=>
{
triggered
=
true
;
triggered
=
true
;
});
});
this
.
shortcut
.
replyWithSelectedText
();
this
.
shortcut
.
replyWithSelectedText
(
true
);
expect
(
triggered
).
toBe
(
true
);
expect
(
triggered
).
toBe
(
true
);
});
});
it
(
'
triggers `focus`
'
,
()
=>
{
it
(
'
triggers `focus`
'
,
()
=>
{
this
.
shortcut
.
replyWithSelectedText
();
this
.
shortcut
.
replyWithSelectedText
(
true
);
expect
(
document
.
activeElement
).
toBe
(
document
.
querySelector
(
this
.
selector
));
expect
(
document
.
activeElement
).
toBe
(
document
.
querySelector
(
this
.
selector
));
});
});
});
});
describe
(
'
with a one-line selection
'
,
()
=>
{
describe
(
'
with a one-line selection
'
,
()
=>
{
it
(
'
quotes the selection
'
,
()
=>
{
it
(
'
quotes the selection
'
,
()
=>
{
stubSelection
(
'
<p>This text has been selected.</p>
'
);
stubSelection
(
'
<p>This text has been selected.</p>
'
);
this
.
shortcut
.
replyWithSelectedText
();
this
.
shortcut
.
replyWithSelectedText
(
true
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
'
> This text has been selected.
\n\n
'
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
'
> This text has been selected.
\n\n
'
);
});
});
});
});
describe
(
'
with a multi-line selection
'
,
()
=>
{
describe
(
'
with a multi-line selection
'
,
()
=>
{
it
(
'
quotes the selected lines as a group
'
,
()
=>
{
it
(
'
quotes the selected lines as a group
'
,
()
=>
{
stubSelection
(
'
<p>Selected line one.</p>
\n\n
<p>Selected line two.</p>
\n\n
<p>Selected line three.</p>
'
);
stubSelection
(
'
<p>Selected line one.</p>
\n\n
<p>Selected line two.</p>
\n\n
<p>Selected line three.</p>
'
);
this
.
shortcut
.
replyWithSelectedText
();
this
.
shortcut
.
replyWithSelectedText
(
true
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
'
> Selected line one.
\n
>
\n
> Selected line two.
\n
>
\n
> Selected line three.
\n\n
'
);
expect
(
$
(
this
.
selector
).
val
()).
toBe
(
'
> Selected line one.
\n
>
\n
> Selected line two.
\n
>
\n
> Selected line three.
\n\n
'
);
});
});
});
});
...
...
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