BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
25fcee16
Commit
25fcee16
authored
Aug 07, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Init adding tests
parent
fecb1a2f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
279 additions
and
26 deletions
+279
-26
autosave.js
app/assets/javascripts/autosave.js
+0
-5
issue_notes_app.vue
app/assets/javascripts/notes/components/issue_notes_app.vue
+7
-5
actions.js
app/assets/javascripts/notes/stores/actions.js
+1
-1
issue_note_app_spec.js
spec/javascripts/notes/components/issue_note_app_spec.js
+172
-12
mock_data.js
spec/javascripts/notes/mock_data.js
+99
-3
No files found.
app/assets/javascripts/autosave.js
View file @
25fcee16
...
@@ -2,11 +2,6 @@
...
@@ -2,11 +2,6 @@
import
AccessorUtilities
from
'./lib/utils/accessor'
;
import
AccessorUtilities
from
'./lib/utils/accessor'
;
window
.
Autosave
=
(
function
()
{
window
.
Autosave
=
(
function
()
{
/**
*
* @param {*} field the textarea
* @param {Array} key Array with: ['Note', type, id, ]
*/
function
Autosave
(
field
,
key
)
{
function
Autosave
(
field
,
key
)
{
this
.
field
=
field
;
this
.
field
=
field
;
this
.
isLocalStorageAvailable
=
AccessorUtilities
.
isLocalStorageAccessSafe
();
this
.
isLocalStorageAvailable
=
AccessorUtilities
.
isLocalStorageAccessSafe
();
...
...
app/assets/javascripts/notes/components/issue_notes_app.vue
View file @
25fcee16
...
@@ -114,10 +114,12 @@
...
@@ -114,10 +114,12 @@
this
.
fetchNotes
();
this
.
fetchNotes
();
this
.
initPolling
();
this
.
initPolling
();
this
.
$el
.
parentElement
.
addEventListener
(
'toggleAward'
,
(
event
)
=>
{
if
(
this
.
$el
.
parentElement
)
{
const
{
awardName
,
noteId
}
=
event
.
detail
;
this
.
$el
.
parentElement
.
addEventListener
(
'toggleAward'
,
(
event
)
=>
{
this
.
actionToggleAward
({
awardName
,
noteId
});
const
{
awardName
,
noteId
}
=
event
.
detail
;
});
this
.
actionToggleAward
({
awardName
,
noteId
});
});
}
},
},
};
};
</
script
>
</
script
>
...
@@ -126,7 +128,7 @@
...
@@ -126,7 +128,7 @@
<div
id=
"notes"
>
<div
id=
"notes"
>
<div
<div
v-if=
"isLoading"
v-if=
"isLoading"
class=
"loading"
>
class=
"
js-loading
loading"
>
<loading-icon
/>
<loading-icon
/>
</div>
</div>
...
...
app/assets/javascripts/notes/stores/actions.js
View file @
25fcee16
...
@@ -134,7 +134,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
...
@@ -134,7 +134,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
};
};
const
pollSuccessCallBack
=
(
resp
,
commit
,
state
,
getters
)
=>
{
const
pollSuccessCallBack
=
(
resp
,
commit
,
state
,
getters
)
=>
{
if
(
resp
.
notes
.
length
)
{
if
(
resp
.
notes
&&
resp
.
notes
.
length
)
{
const
{
notesById
}
=
getters
;
const
{
notesById
}
=
getters
;
resp
.
notes
.
forEach
((
note
)
=>
{
resp
.
notes
.
forEach
((
note
)
=>
{
...
...
spec/javascripts/notes/components/issue_note_app_spec.js
View file @
25fcee16
describe
(
'issue_note_app'
,
()
=>
{
import
Vue
from
'vue'
;
import
issueNotesApp
from
'~/notes/components/issue_notes_app.vue'
;
import
*
as
mockData
from
'../mock_data'
;
it
(
'should set notes data'
,
()
=>
{
fdescribe
(
'issue_note_app'
,
()
=>
{
let
mountComponent
;
beforeEach
(()
=>
{
const
IssueNotesApp
=
Vue
.
extend
(
issueNotesApp
);
mountComponent
=
props
=>
new
IssueNotesApp
({
propsData
:
props
,
}).
$mount
();
});
});
it
(
'should set issue data'
,
()
=>
{
describe
(
'set data'
,
()
=>
{
let
vm
;
const
responseInterceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
([]),
{
status
:
200
,
}));
};
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
responseInterceptor
);
vm
=
mountComponent
({
issueData
:
mockData
.
issueDataMock
,
notesData
:
mockData
.
notesDataMock
,
userData
:
mockData
.
userDataMock
,
});
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
responseInterceptor
);
});
it
(
'should set notes data'
,
()
=>
{
expect
(
vm
.
$store
.
state
.
notesData
).
toEqual
(
mockData
.
notesDataMock
);
});
it
(
'should set issue data'
,
()
=>
{
expect
(
vm
.
$store
.
state
.
issueData
).
toEqual
(
mockData
.
issueDataMock
);
});
it
(
'should set user data'
,
()
=>
{
expect
(
vm
.
$store
.
state
.
userData
).
toEqual
(
mockData
.
userDataMock
);
});
it
(
'should fetch notes'
,
()
=>
{
expect
(
vm
.
$store
.
state
.
notes
).
toEqual
([]);
});
});
});
it
(
'should set user data'
,
()
=>
{
fdescribe
(
'render'
,
()
=>
{
let
vm
;
const
responseInterceptor
=
(
request
,
next
)
=>
{
next
(
request
.
respondWith
(
JSON
.
stringify
(
mockData
.
discussionResponse
),
{
status
:
200
,
}));
};
beforeEach
(()
=>
{
Vue
.
http
.
interceptors
.
push
(
responseInterceptor
);
vm
=
mountComponent
({
issueData
:
mockData
.
issueDataMock
,
notesData
:
mockData
.
notesDataMock
,
userData
:
mockData
.
userDataMock
,
});
});
afterEach
(()
=>
{
Vue
.
http
.
interceptors
=
_
.
without
(
Vue
.
http
.
interceptors
,
responseInterceptor
);
});
it
(
'should render list of notes'
,
()
=>
{
console
.
log
(
vm
);
});
it
(
'should render form'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.js-main-target-form'
).
tagName
).
toEqual
(
'FORM'
);
expect
(
vm
.
$el
.
querySelector
(
'.js-main-target-form textarea'
).
getAttribute
(
'placeholder'
),
).
toEqual
(
'Write a comment or drag your files here...'
);
});
});
});
it
(
'should fetch notes'
,
()
=>
{
describe
(
'while fetching data'
,
()
=>
{
let
vm
;
beforeEach
(()
=>
{
vm
=
mountComponent
({
issueData
:
mockData
.
issueDataMock
,
notesData
:
mockData
.
notesDataMock
,
userData
:
mockData
.
userDataMock
,
});
});
it
(
'should render loading icon'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.js-loading'
)).
toBeDefined
();
});
it
(
'should render form'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.js-main-target-form'
).
tagName
).
toEqual
(
'FORM'
);
expect
(
vm
.
$el
.
querySelector
(
'.js-main-target-form textarea'
).
getAttribute
(
'placeholder'
),
).
toEqual
(
'Write a comment or drag your files here...'
);
});
});
});
it
(
'should render list of notes'
,
()
=>
{
describe
(
'update note'
,
()
=>
{
describe
(
'individual note'
,
()
=>
{
describe
(
'shortup up key'
,
()
=>
{
it
(
'shows correct editing form when user clicks up'
,
()
=>
{
});
});
describe
(
'dropdown'
,
()
=>
{
it
(
'renders edit form'
,
()
=>
{
});
});
it
(
'updates the note and resets the edit form'
,
()
=>
{});
});
describe
(
'dicussion note note'
,
()
=>
{
describe
(
'shortup up key'
,
()
=>
{
it
(
'shows correct editing form when user clicks up'
,
()
=>
{
});
});
describe
(
'dropdown'
,
()
=>
{
it
(
'renders edit form'
,
()
=>
{
});
});
it
(
'updates the note and resets the edit form'
,
()
=>
{});
});
});
});
it
(
'should render form'
,
()
=>
{
describe
(
'set target hash'
,
()
=>
{
it
(
'updates the URL when the note date is clicked'
,
()
=>
{
});
it
(
'stores the correct hash'
,
()
=>
{
});
it
(
'updates visually the target note'
,
()
=>
{
});
});
});
describe
(
'while fetching'
,
()
=>
{
describe
(
'create new note'
,
()
=>
{
it
(
'should render loading icon'
,
()
=>
{
it
(
'should show placeholder note while new comment is being posted'
,
()
=>
{});
it
(
'should remove placeholder note when new comment is done posting'
,
()
=>
{});
it
(
'should show actual note element when new comment is done posting'
,
()
=>
{});
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'
,
()
=>
{});
});
describe
(
'quick actions'
,
()
=>
{
it
(
'should return executing quick action description when note has single quick action'
,
()
=>
{
});
});
it
(
'should render form'
,
()
=>
{
it
(
'should return generic multiple quick action description when note has multiple quick actions'
,
()
=>
{
});
it
(
'should return generic quick action description when available quick actions list is not populated'
,
()
=>
{
});
});
});
});
});
\ No newline at end of file
describe
(
'new note form'
,
()
=>
{
it
(
'should render markdown docs url'
,
()
=>
{
});
it
(
'should render quick action docs url'
,
()
=>
{
});
it
(
'should preview markdown'
,
()
=>
{
});
describe
(
'discard draft'
,
()
=>
{
it
(
'should reset form when reset button is clicked'
,
()
=>
{
});
});
});
describe
(
'edit form'
,
()
=>
{
it
(
'should render markdown docs url'
,
()
=>
{});
it
(
'should not render quick actions docs url'
,
()
=>
{});
});
});
spec/javascripts/notes/mock_data.js
View file @
25fcee16
/* eslint disable */
export
const
notesDataMock
=
{
export
const
notesDataMock
=
{
discussionsPath
:
'/gitlab-org/gitlab-ce/issues/26/discussions.json'
,
discussionsPath
:
'/gitlab-org/gitlab-ce/issues/26/discussions.json'
,
lastFetchedAt
:
'1501862675'
,
lastFetchedAt
:
'1501862675'
,
...
@@ -17,7 +19,7 @@ export const userDataMock = {
...
@@ -17,7 +19,7 @@ export const userDataMock = {
username
:
'root'
,
username
:
'root'
,
};
};
export
const
issueData
=
{
export
const
issueData
Mock
=
{
assignees
:
[],
assignees
:
[],
author_id
:
1
,
author_id
:
1
,
branch_name
:
null
,
branch_name
:
null
,
...
@@ -218,4 +220,98 @@ export const discussionMock = {
...
@@ -218,4 +220,98 @@ export const discussionMock = {
path
:
'/gitlab-org/gitlab-ce/notes/1437'
,
path
:
'/gitlab-org/gitlab-ce/notes/1437'
,
}],
}],
individual_note
:
false
,
individual_note
:
false
,
};
};
\ No newline at end of file
export
const
discussionResponse
=
[{
"id"
:
"0fb4e0e3f9276e55ff32eb4195add694aece4edd"
,
"reply_id"
:
"0fb4e0e3f9276e55ff32eb4195add694aece4edd"
,
"expanded"
:
true
,
"notes"
:
[{
"id"
:
1390
,
"attachment"
:
{
"url"
:
null
,
"filename"
:
null
,
"image"
:
false
},
"author"
:
{
"id"
:
1
,
"name"
:
"Root"
,
"username"
:
"root"
,
"state"
:
"active"
,
"avatar_url"
:
null
,
"path"
:
"/root"
},
"created_at"
:
"2017-08-01T17:09:33.762Z"
,
"updated_at"
:
"2017-08-01T17:09:33.762Z"
,
"system"
:
false
,
"noteable_id"
:
98
,
"noteable_type"
:
"Issue"
,
"type"
:
null
,
"human_access"
:
"Owner"
,
"note"
:
"sdfdsaf"
,
"note_html"
:
"
\
u003cp dir=
\"
auto
\"
\
u003esdfdsaf
\
u003c/p
\
u003e"
,
"current_user"
:
{
"can_edit"
:
true
},
"discussion_id"
:
"0fb4e0e3f9276e55ff32eb4195add694aece4edd"
,
"emoji_awardable"
:
true
,
"award_emoji"
:
[{
"name"
:
"baseball"
,
"user"
:
{
"id"
:
1
,
"name"
:
"Root"
,
"username"
:
"root"
}
},
{
"name"
:
"art"
,
"user"
:
{
"id"
:
1
,
"name"
:
"Root"
,
"username"
:
"root"
}
}],
"toggle_award_path"
:
"/gitlab-org/gitlab-ce/notes/1390/toggle_award_emoji"
,
"report_abuse_path"
:
"/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1390
\
u0026user_id=1"
,
"path"
:
"/gitlab-org/gitlab-ce/notes/1390"
}],
"individual_note"
:
true
},
{
"id"
:
"70d5c92a4039a36c70100c6691c18c27e4b0a790"
,
"reply_id"
:
"70d5c92a4039a36c70100c6691c18c27e4b0a790"
,
"expanded"
:
true
,
"notes"
:
[{
"id"
:
1391
,
"attachment"
:
{
"url"
:
null
,
"filename"
:
null
,
"image"
:
false
},
"author"
:
{
"id"
:
1
,
"name"
:
"Root"
,
"username"
:
"root"
,
"state"
:
"active"
,
"avatar_url"
:
null
,
"path"
:
"/root"
},
"created_at"
:
"2017-08-02T10:51:38.685Z"
,
"updated_at"
:
"2017-08-02T10:51:38.685Z"
,
"system"
:
false
,
"noteable_id"
:
98
,
"noteable_type"
:
"Issue"
,
"type"
:
null
,
"human_access"
:
"Owner"
,
"note"
:
"New note!"
,
"note_html"
:
"
\
u003cp dir=
\"
auto
\"
\
u003eNew note!
\
u003c/p
\
u003e"
,
"current_user"
:
{
"can_edit"
:
true
},
"discussion_id"
:
"70d5c92a4039a36c70100c6691c18c27e4b0a790"
,
"emoji_awardable"
:
true
,
"award_emoji"
:
[],
"toggle_award_path"
:
"/gitlab-org/gitlab-ce/notes/1391/toggle_award_emoji"
,
"report_abuse_path"
:
"/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1391
\
u0026user_id=1"
,
"path"
:
"/gitlab-org/gitlab-ce/notes/1391"
}],
"individual_note"
:
true
}];
\ No newline at end of file
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