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
16b15a11
Commit
16b15a11
authored
Aug 09, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ci skip] Adds unit tests for issue comment form spec
parent
3372ae8b
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
113 additions
and
36 deletions
+113
-36
issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+1
-1
issue_note_actions.vue
...ssets/javascripts/notes/components/issue_note_actions.vue
+2
-2
issue_comment_form_spec.js
spec/javascripts/notes/components/issue_comment_form_spec.js
+69
-31
issue_discussion_spec.js
spec/javascripts/notes/components/issue_discussion_spec.js
+0
-1
issue_note_actions_spec.js
spec/javascripts/notes/components/issue_note_actions_spec.js
+0
-0
issue_note_awards_list_spec.js
...vascripts/notes/components/issue_note_awards_list_spec.js
+0
-0
issue_note_body_spec.js
spec/javascripts/notes/components/issue_note_body_spec.js
+0
-0
issue_note_form_spec.js
spec/javascripts/notes/components/issue_note_form_spec.js
+0
-1
issue_note_spec.js
spec/javascripts/notes/components/issue_note_spec.js
+0
-0
mock_data.js
spec/javascripts/notes/mock_data.js
+41
-0
No files found.
app/assets/javascripts/notes/components/issue_comment_form.vue
View file @
16b15a11
...
@@ -204,7 +204,7 @@
...
@@ -204,7 +204,7 @@
<div>
<div>
<issue-note-signed-out-widget
v-if=
"!isLoggedIn"
/>
<issue-note-signed-out-widget
v-if=
"!isLoggedIn"
/>
<ul
<ul
v-
if=
"isLoggedIn"
v-
else
class=
"notes notes-form timeline new-note"
>
class=
"notes notes-form timeline new-note"
>
<li
class=
"timeline-entry"
ref=
"commentForm"
>
<li
class=
"timeline-entry"
ref=
"commentForm"
>
<div
class=
"timeline-entry-inner"
>
<div
class=
"timeline-entry-inner"
>
...
...
app/assets/javascripts/notes/components/issue_note_actions.vue
View file @
16b15a11
...
@@ -74,8 +74,8 @@
...
@@ -74,8 +74,8 @@
},
},
onDelete
()
{
onDelete
()
{
this
.
$emit
(
'deleteHandler'
);
this
.
$emit
(
'deleteHandler'
);
}
}
,
}
}
,
};
};
</
script
>
</
script
>
...
...
spec/javascripts/notes/components/issue_comment_form_spec.js
View file @
16b15a11
import
Vue
from
'vue'
;
import
store
from
'~/notes/stores'
;
import
issueCommentForm
from
'~/notes/components/issue_comment_form.vue'
;
import
{
loggedOutIssueData
,
notesDataMock
,
userDataMock
,
issueDataMock
}
from
'../mock_data'
;
import
{
keyboardDownEvent
}
from
'../../issue_show/helpers'
;
describe
(
'issue_comment_form component'
,
()
=>
{
describe
(
'issue_comment_form component'
,
()
=>
{
let
vm
;
const
Component
=
Vue
.
extend
(
issueCommentForm
);
let
mountComponent
;
beforeEach
(()
=>
{
mountComponent
=
()
=>
new
Component
({
store
,
}).
$mount
();
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'user is logged in'
,
()
=>
{
describe
(
'user is logged in'
,
()
=>
{
it
(
'should render user avatar with link'
,
()
=>
{
beforeEach
(()
=>
{
store
.
dispatch
(
'setUserData'
,
userDataMock
);
store
.
dispatch
(
'setIssueData'
,
issueDataMock
);
store
.
dispatch
(
'setNotesData'
,
notesDataMock
);
vm
=
mountComponent
();
});
it
(
'should render user avatar with link'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.timeline-icon .user-avatar-link'
).
getAttribute
(
'href'
)).
toEqual
(
userDataMock
.
path
);
});
});
describe
(
'textarea'
,
()
=>
{
describe
(
'textarea'
,
()
=>
{
it
(
'should render textarea with placeholder'
,
()
=>
{
it
(
'should render textarea with placeholder'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.js-main-target-form textarea'
).
getAttribute
(
'placeholder'
),
).
toEqual
(
'Write a comment or drag your files here...'
);
});
});
it
(
'should support quick actions'
,
()
=>
{
it
(
'should support quick actions'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.js-main-target-form textarea'
).
getAttribute
(
'data-supports-quick-actions'
),
).
toEqual
(
'true'
);
});
});
it
(
'should link to markdown docs'
,
()
=>
{
it
(
'should link to markdown docs'
,
()
=>
{
const
{
markdownDocs
}
=
notesDataMock
;
expect
(
vm
.
$el
.
querySelector
(
`a[href="
${
markdownDocs
}
"]`
).
textContent
.
trim
()).
toEqual
(
'Markdown'
);
});
});
it
(
'should link to quick actions docs'
,
()
=>
{
it
(
'should link to quick actions docs'
,
()
=>
{
const
{
quickActionsDocs
}
=
notesDataMock
;
expect
(
vm
.
$el
.
querySelector
(
`a[href="
${
quickActionsDocs
}
"]`
).
textContent
.
trim
()).
toEqual
(
'quick actions'
);
});
});
describe
(
'edit mode'
,
()
=>
{
describe
(
'edit mode'
,
()
=>
{
it
(
'should enter edit mode when arrow up is pressed'
,
()
=>
{
it
(
'should enter edit mode when arrow up is pressed'
,
()
=>
{
spyOn
(
vm
,
'editCurrentUserLastNote'
).
and
.
callThrough
();
vm
.
$el
.
querySelector
(
'.js-main-target-form textarea'
).
value
=
'Foo'
;
vm
.
$el
.
querySelector
(
'.js-main-target-form textarea'
).
dispatchEvent
(
keyboardDownEvent
(
38
,
true
));
});
expect
(
vm
.
editCurrentUserLastNote
).
toHaveBeenCalled
();
});
describe
(
'preview mode'
,
()
=>
{
it
(
'should be possible to preview the note'
,
()
=>
{
});
});
});
});
describe
(
'event enter'
,
()
=>
{
describe
(
'event enter'
,
()
=>
{
it
(
'should save note when cmd/ctrl+enter is pressed'
,
()
=>
{
it
(
'should save note when cmd/ctrl+enter is pressed'
,
()
=>
{
spyOn
(
vm
,
'handleSave'
).
and
.
callThrough
();
vm
.
$el
.
querySelector
(
'.js-main-target-form textarea'
).
value
=
'Foo'
;
vm
.
$el
.
querySelector
(
'.js-main-target-form textarea'
).
dispatchEvent
(
keyboardDownEvent
(
13
,
true
));
expect
(
vm
.
handleSave
).
toHaveBeenCalled
();
});
});
});
});
});
});
describe
(
'actions'
,
()
=>
{
describe
(
'actions'
,
()
=>
{
describe
(
'with empty note'
,
()
=>
{
it
(
'should be possible to close the issue'
,
()
=>
{
it
(
'should render dropdown as disabled'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.btn-comment-and-close'
).
textContent
.
trim
()).
toEqual
(
'Close issue'
);
});
});
});
describe
(
'with note'
,
()
=>
{
it
(
'should render comment button as disabled'
,
()
=>
{
it
(
'should render enabled dropdown with 2 actions'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.js-comment-submit-button'
).
getAttribute
(
'disabled'
)).
toEqual
(
'disabled'
);
});
});
it
(
'should render be possible to discard draft'
,
()
=>
{
it
(
'should enable comment button if it has note'
,
(
done
)
=>
{
vm
.
note
=
'Foo'
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.js-comment-submit-button'
).
getAttribute
(
'disabled'
)).
toEqual
(
null
);
done
();
});
});
});
});
describe
(
'with open issue'
,
()
=>
{
it
(
'should update buttons texts when it has note'
,
(
done
)
=>
{
it
(
'should be possible to close the issue'
,
()
=>
{
vm
.
note
=
'Foo'
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'.btn-comment-and-close'
).
textContent
.
trim
()).
toEqual
(
'Comment & close issue'
);
expect
(
vm
.
$el
.
querySelector
(
'.js-note-discard'
)).
toBeDefined
();
done
();
});
});
});
});
describe
(
'with closed issue'
,
()
=>
{
it
(
'should be possible to reopen the issue'
,
()
=>
{
});
});
});
});
});
describe
(
'user is not logged in'
,
()
=>
{
beforeEach
(()
=>
{
store
.
dispatch
(
'setUserData'
,
null
);
store
.
dispatch
(
'setIssueData'
,
loggedOutIssueData
);
store
.
dispatch
(
'setNotesData'
,
notesDataMock
);
vm
=
mountComponent
();
});
});
describe
(
'user is not logged in'
,
()
=>
{
it
(
'should render signed out widget'
,
()
=>
{
it
(
'should render signed out widget'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
.
replace
(
/
\s
+/g
,
' '
).
trim
()).
toEqual
(
'Please register or sign in to reply'
);
});
});
it
(
'should not render submission form'
,
()
=>
{
it
(
'should not render submission form'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'textarea'
)).
toEqual
(
null
);
});
});
});
});
});
});
spec/javascripts/notes/components/issue_discussion_spec.js
View file @
16b15a11
describe
(
'issue_discussion component'
,
()
=>
{
describe
(
'issue_discussion component'
,
()
=>
{
it
(
'should render user avatar'
,
()
=>
{
it
(
'should render user avatar'
,
()
=>
{
});
});
...
...
spec/javascripts/notes/components/issue_note_actions_spec.js
View file @
16b15a11
spec/javascripts/notes/components/issue_note_awards_list_spec.js
View file @
16b15a11
spec/javascripts/notes/components/issue_note_body_spec.js
View file @
16b15a11
spec/javascripts/notes/components/issue_note_form_spec.js
View file @
16b15a11
describe
(
'issue_note_form component'
,
()
=>
{
describe
(
'issue_note_form component'
,
()
=>
{
describe
(
'conflicts editing'
,
()
=>
{
describe
(
'conflicts editing'
,
()
=>
{
it
(
'should show conflict message if note changes outside the component'
,
()
=>
{
it
(
'should show conflict message if note changes outside the component'
,
()
=>
{
...
...
spec/javascripts/notes/components/issue_note_spec.js
View file @
16b15a11
spec/javascripts/notes/mock_data.js
View file @
16b15a11
...
@@ -221,6 +221,47 @@ export const discussionMock = {
...
@@ -221,6 +221,47 @@ export const discussionMock = {
individual_note
:
false
,
individual_note
:
false
,
};
};
export
const
loggedOutIssueData
=
{
"id"
:
98
,
"iid"
:
26
,
"author_id"
:
1
,
"description"
:
""
,
"lock_version"
:
1
,
"milestone_id"
:
null
,
"state"
:
"opened"
,
"title"
:
"asdsa"
,
"updated_by_id"
:
1
,
"created_at"
:
"2017-02-07T10:11:18.395Z"
,
"updated_at"
:
"2017-08-08T10:22:51.564Z"
,
"deleted_at"
:
null
,
"time_estimate"
:
0
,
"total_time_spent"
:
0
,
"human_time_estimate"
:
null
,
"human_total_time_spent"
:
null
,
"milestone"
:
null
,
"labels"
:
[],
"branch_name"
:
null
,
"confidential"
:
false
,
"assignees"
:
[{
"id"
:
1
,
"name"
:
"Root"
,
"username"
:
"root"
,
"state"
:
"active"
,
"avatar_url"
:
null
,
"web_url"
:
"http://localhost:3000/root"
}],
"due_date"
:
null
,
"moved_to_id"
:
null
,
"project_id"
:
2
,
"web_url"
:
"/gitlab-org/gitlab-ce/issues/26"
,
"current_user"
:
{
"can_create_note"
:
false
,
"can_update"
:
false
},
"create_note_path"
:
"/gitlab-org/gitlab-ce/notes?target_id=98&target_type=issue"
,
"preview_note_path"
:
"/gitlab-org/gitlab-ce/preview_markdown?quick_actions_target_id=98&quick_actions_target_type=Issue"
}
export
const
individualNoteServerResponse
=
[{
export
const
individualNoteServerResponse
=
[{
"id"
:
"0fb4e0e3f9276e55ff32eb4195add694aece4edd"
,
"id"
:
"0fb4e0e3f9276e55ff32eb4195add694aece4edd"
,
"reply_id"
:
"0fb4e0e3f9276e55ff32eb4195add694aece4edd"
,
"reply_id"
:
"0fb4e0e3f9276e55ff32eb4195add694aece4edd"
,
...
...
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