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
2ee08f47
Commit
2ee08f47
authored
Feb 07, 2018
by
Simon Knox
Committed by
Fatih Acet
Feb 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Cancelling a second comment edit doesn't return its state to before the edit"
parent
071b0ef3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
47 deletions
+72
-47
app/assets/javascripts/notes/components/noteable_note.vue
app/assets/javascripts/notes/components/noteable_note.vue
+1
-0
changelogs/unreleased/42462-edit-note.yml
changelogs/unreleased/42462-edit-note.yml
+5
-0
spec/javascripts/notes/components/note_app_spec.js
spec/javascripts/notes/components/note_app_spec.js
+45
-47
spec/javascripts/notes/components/noteable_note_spec.js
spec/javascripts/notes/components/noteable_note_spec.js
+21
-0
No files found.
app/assets/javascripts/notes/components/noteable_note.vue
View file @
2ee08f47
...
@@ -102,6 +102,7 @@
...
@@ -102,6 +102,7 @@
.
then
(()
=>
{
.
then
(()
=>
{
this
.
isEditing
=
false
;
this
.
isEditing
=
false
;
this
.
isRequesting
=
false
;
this
.
isRequesting
=
false
;
this
.
oldContent
=
null
;
$
(
this
.
$refs
.
noteBody
.
$el
).
renderGFM
();
$
(
this
.
$refs
.
noteBody
.
$el
).
renderGFM
();
this
.
$refs
.
noteBody
.
resetAutoSave
();
this
.
$refs
.
noteBody
.
resetAutoSave
();
callback
();
callback
();
...
...
changelogs/unreleased/42462-edit-note.yml
0 → 100644
View file @
2ee08f47
---
title
:
Fix cnacel edit note button reverting changes
merge_request
:
42462
author
:
type
:
fixed
spec/javascripts/notes/components/note_app_spec.js
View file @
2ee08f47
...
@@ -2,14 +2,29 @@ import _ from 'underscore';
...
@@ -2,14 +2,29 @@ import _ from 'underscore';
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
notesApp
from
'
~/notes/components/notes_app.vue
'
;
import
notesApp
from
'
~/notes/components/notes_app.vue
'
;
import
service
from
'
~/notes/services/notes_service
'
;
import
service
from
'
~/notes/services/notes_service
'
;
import
'
~/render_gfm
'
;
import
*
as
mockData
from
'
../mock_data
'
;
import
*
as
mockData
from
'
../mock_data
'
;
import
getSetTimeoutPromise
from
'
../../helpers/set_timeout_promise_helper
'
;
const
vueMatchers
=
{
toIncludeElement
()
{
return
{
compare
(
vm
,
selector
)
{
const
result
=
{
pass
:
vm
.
$el
.
querySelector
(
selector
)
!==
null
,
};
return
result
;
},
};
},
};
describe
(
'
note_app
'
,
()
=>
{
describe
(
'
note_app
'
,
()
=>
{
let
mountComponent
;
let
mountComponent
;
let
vm
;
let
vm
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
jasmine
.
addMatchers
(
vueMatchers
);
const
IssueNotesApp
=
Vue
.
extend
(
notesApp
);
const
IssueNotesApp
=
Vue
.
extend
(
notesApp
);
mountComponent
=
(
data
)
=>
{
mountComponent
=
(
data
)
=>
{
...
@@ -105,7 +120,7 @@ describe('note_app', () => {
...
@@ -105,7 +120,7 @@ describe('note_app', () => {
});
});
it
(
'
should render loading icon
'
,
()
=>
{
it
(
'
should render loading icon
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-loading
'
)).
toBeDefined
(
);
expect
(
vm
).
toIncludeElement
(
'
.js-loading
'
);
});
});
it
(
'
should render form
'
,
()
=>
{
it
(
'
should render form
'
,
()
=>
{
...
@@ -118,10 +133,14 @@ describe('note_app', () => {
...
@@ -118,10 +133,14 @@ describe('note_app', () => {
describe
(
'
update note
'
,
()
=>
{
describe
(
'
update note
'
,
()
=>
{
describe
(
'
individual note
'
,
()
=>
{
describe
(
'
individual note
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
((
done
)
=>
{
Vue
.
http
.
interceptors
.
push
(
mockData
.
individualNoteInterceptor
);
Vue
.
http
.
interceptors
.
push
(
mockData
.
individualNoteInterceptor
);
spyOn
(
service
,
'
updateNote
'
).
and
.
callThrough
();
spyOn
(
service
,
'
updateNote
'
).
and
.
callThrough
();
vm
=
mountComponent
();
vm
=
mountComponent
();
setTimeout
(()
=>
{
vm
.
$el
.
querySelector
(
'
.js-note-edit
'
).
click
();
Vue
.
nextTick
(
done
);
},
0
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -131,40 +150,32 @@ describe('note_app', () => {
...
@@ -131,40 +150,32 @@ describe('note_app', () => {
);
);
});
});
it
(
'
renders edit form
'
,
(
done
)
=>
{
it
(
'
renders edit form
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
vm
).
toIncludeElement
(
'
.js-vue-issue-note-form
'
);
vm
.
$el
.
querySelector
(
'
.js-note-edit
'
).
click
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-vue-issue-note-form
'
)).
toBeDefined
();
done
();
});
},
0
);
});
});
it
(
'
calls the service to update the note
'
,
(
done
)
=>
{
it
(
'
calls the service to update the note
'
,
(
done
)
=>
{
getSetTimeoutPromise
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.js-note-edit
'
).
click
();
})
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.js-vue-issue-note-form
'
).
value
=
'
this is a note
'
;
vm
.
$el
.
querySelector
(
'
.js-vue-issue-note-form
'
).
value
=
'
this is a note
'
;
vm
.
$el
.
querySelector
(
'
.js-vue-issue-save
'
).
click
();
vm
.
$el
.
querySelector
(
'
.js-vue-issue-save
'
).
click
();
expect
(
service
.
updateNote
).
toHaveBeenCalled
();
expect
(
service
.
updateNote
).
toHaveBeenCalled
();
})
// Wait for the requests to finish before destroying
// Wait for the requests to finish before destroying
.
then
(
Vue
.
nextTick
)
Vue
.
nextTick
(
)
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
});
});
describe
(
'
dicussion note
'
,
()
=>
{
describe
(
'
di
s
cussion note
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
((
done
)
=>
{
Vue
.
http
.
interceptors
.
push
(
mockData
.
discussionNoteInterceptor
);
Vue
.
http
.
interceptors
.
push
(
mockData
.
discussionNoteInterceptor
);
spyOn
(
service
,
'
updateNote
'
).
and
.
callThrough
();
spyOn
(
service
,
'
updateNote
'
).
and
.
callThrough
();
vm
=
mountComponent
();
vm
=
mountComponent
();
setTimeout
(()
=>
{
vm
.
$el
.
querySelector
(
'
.js-note-edit
'
).
click
();
Vue
.
nextTick
(
done
);
},
0
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -174,30 +185,17 @@ describe('note_app', () => {
...
@@ -174,30 +185,17 @@ describe('note_app', () => {
);
);
});
});
it
(
'
renders edit form
'
,
(
done
)
=>
{
it
(
'
renders edit form
'
,
()
=>
{
setTimeout
(()
=>
{
expect
(
vm
).
toIncludeElement
(
'
.js-vue-issue-note-form
'
);
vm
.
$el
.
querySelector
(
'
.js-note-edit
'
).
click
();
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
.js-vue-issue-note-form
'
)).
toBeDefined
();
done
();
});
},
0
);
});
});
it
(
'
updates the note and resets the edit form
'
,
(
done
)
=>
{
it
(
'
updates the note and resets the edit form
'
,
(
done
)
=>
{
getSetTimeoutPromise
()
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.js-note-edit
'
).
click
();
})
.
then
(
Vue
.
nextTick
)
.
then
(()
=>
{
vm
.
$el
.
querySelector
(
'
.js-vue-issue-note-form
'
).
value
=
'
this is a note
'
;
vm
.
$el
.
querySelector
(
'
.js-vue-issue-note-form
'
).
value
=
'
this is a note
'
;
vm
.
$el
.
querySelector
(
'
.js-vue-issue-save
'
).
click
();
vm
.
$el
.
querySelector
(
'
.js-vue-issue-save
'
).
click
();
expect
(
service
.
updateNote
).
toHaveBeenCalled
();
expect
(
service
.
updateNote
).
toHaveBeenCalled
();
})
// Wait for the requests to finish before destroying
// Wait for the requests to finish before destroying
.
then
(
Vue
.
nextTick
)
Vue
.
nextTick
(
)
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
...
...
spec/javascripts/notes/components/noteable_note_spec.js
View file @
2ee08f47
...
@@ -56,4 +56,25 @@ describe('issue_note', () => {
...
@@ -56,4 +56,25 @@ describe('issue_note', () => {
done
();
done
();
},
0
);
},
0
);
});
});
describe
(
'
cancel edit
'
,
()
=>
{
it
(
'
restores content of updated note
'
,
(
done
)
=>
{
const
noteBody
=
'
updated note text
'
;
vm
.
updateNote
=
()
=>
Promise
.
resolve
();
vm
.
formUpdateHandler
(
noteBody
,
null
,
$
.
noop
);
setTimeout
(()
=>
{
expect
(
vm
.
note
.
note_html
).
toEqual
(
noteBody
);
vm
.
formCancelHandler
();
setTimeout
(()
=>
{
expect
(
vm
.
note
.
note_html
).
toEqual
(
noteBody
);
done
();
});
});
});
});
});
});
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