Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
3cf2481e
Commit
3cf2481e
authored
Sep 08, 2014
by
Greg Price
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5077 from edx/gprice/forum-cohort-selector-test
Test cohort selector in NewPostView
parents
47a412de
1de17fb7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
83 additions
and
66 deletions
+83
-66
common/static/coffee/spec/discussion/discussion_spec_helper.coffee
+7
-0
common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee
+0
-0
common/static/coffee/spec/discussion/view/discussion_view_spec_helper.coffee
+1
-0
common/static/coffee/spec/discussion/view/new_post_view_spec.coffee
+59
-54
common/static/coffee/src/discussion/discussion_router.coffee
+5
-1
common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
+8
-2
lms/templates/discussion/_thread_list_template.html
+3
-9
No files found.
common/static/coffee/spec/discussion/discussion_spec_helper.coffee
View file @
3cf2481e
...
...
@@ -9,6 +9,13 @@ class @DiscussionSpecHelper
@
makeModerator
=
()
->
DiscussionUtil
.
roleIds
[
"Moderator"
].
push
(
parseInt
(
window
.
user
.
id
))
@
makeAjaxSpy
=
(
fakeAjax
)
->
spyOn
(
$
,
"ajax"
).
andCallFake
(
(
params
)
->
fakeAjax
(
params
)
{
always
:
->
}
)
@
setUnderscoreFixtures
=
->
for
templateName
in
[
'thread-show'
]
templateFixture
=
readFixtures
(
'templates/discussion/'
+
templateName
+
'.underscore'
)
...
...
common/static/coffee/spec/discussion/view/discussion_thread_list_view_spec.coffee
View file @
3cf2481e
This diff is collapsed.
Click to expand it.
common/static/coffee/spec/discussion/view/discussion_view_spec_helper.coffee
View file @
3cf2481e
...
...
@@ -7,6 +7,7 @@ class @DiscussionViewSpecHelper
pinned
:
false
,
endorsed
:
false
,
votes
:
{
up_count
:
'0'
},
read
:
false
,
unread_comments_count
:
0
,
comments_count
:
0
,
abuse_flaggers
:
[],
...
...
common/static/coffee/spec/discussion/view/new_post_view_spec.coffee
View file @
3cf2481e
# -*- coding: utf-8 -*-
describe
"NewPostView"
,
->
beforeEach
->
setFixtures
(
"""
<div class="discussion-body">
<div class="discussion-column">
<article class="new-post-article" style="display: block;"></article>
</div>
</div>
<script aria-hidden="true" type="text/template" id="new-post-template">
<form class="forum-new-post-form">
<% if (mode=="tab") { %>
<div class="post-field">
<div class="field-label">
<span class="field-label-text">
Topic Area:
</span>
<div class="field-input post-topic">
<a href="#" class="post-topic-button">
<span class="sr">${_("Discussion topics; current selection is: ")}</span>
<span class="js-selected-topic"></span>
<span class="drop-arrow" aria-hidden="true">▾</span>
</a>
<div class="topic-menu-wrapper">
<ul class="topic-menu" role="menu"><%= topics_html %></ul>
</div>
</div>
</div>
</div>
<% } %>
<select class="js-group-select">
<option value="">All Groups</option>
<option value="1">Group 1</option>
<option value="2">Group 2</option>
</select>
</form>
</script>
<script aria-hidden="true" type="text/template" id="new-post-menu-entry-template">
<li role="menuitem">
<a href="#" class="topic-title" data-discussion-id="<%- id %>" data-cohorted="<%- is_cohorted %>"><%- text %></a>
</li>
</script>
<script aria-hidden="true" type="text/template" id="new-post-menu-category-template">
<li role="menuitem">
<span class="topic-title"><%- text %></span>
<ul role="menu" class="topic-submenu"><%= entries %></ul>
</li>
</script>
"""
)
DiscussionSpecHelper
.
setUpGlobals
()
DiscussionSpecHelper
.
setUnderscoreFixtures
()
window
.
$
$course_id
=
"edX/999/test"
spyOn
(
DiscussionUtil
,
"makeWmdEditor"
)
@
discussion
=
new
Discussion
([],
{
pages
:
1
})
...
...
@@ -77,10 +28,11 @@ describe "NewPostView", ->
"entries"
:
{}
},
"allow_anonymous"
:
true
,
"allow_anonymous_to_peers"
:
true
"allow_anonymous_to_peers"
:
true
,
"is_cohorted"
:
true
})
@
view
=
new
NewPostView
(
el
:
$
(
"
.new-post-article
"
),
el
:
$
(
"
#fixture-element
"
),
collection
:
@
discussion
,
course_settings
:
@
course_settings
,
mode
:
"tab"
...
...
@@ -144,6 +96,7 @@ describe "NewPostView", ->
}
}
)
DiscussionSpecHelper
.
makeModerator
()
view
.
render
()
expectCohortSelectorEnabled
=
(
view
,
enabled
)
->
...
...
@@ -163,6 +116,58 @@ describe "NewPostView", ->
@
view
.
$
(
"a.topic-title[data-discussion-id=non-cohorted]"
).
click
()
expectCohortSelectorEnabled
(
@
view
,
false
)
describe
"cohort selector"
,
->
beforeEach
->
@
course_settings
=
new
DiscussionCourseSettings
({
"category_map"
:
{
"children"
:
[
"Topic"
],
"entries"
:
{
"Topic"
:
{
"is_cohorted"
:
true
,
"id"
:
"topic"
}}
},
"allow_anonymous"
:
false
,
"allow_anonymous_to_peers"
:
false
,
"is_cohorted"
:
true
,
"cohorts"
:
[
{
"id"
:
1
,
"name"
:
"Cohort1"
},
{
"id"
:
2
,
"name"
:
"Cohort2"
}
]
})
@
view
=
new
NewPostView
(
el
:
$
(
"#fixture-element"
),
collection
:
@
discussion
,
course_settings
:
@
course_settings
,
mode
:
"tab"
)
expectCohortSelectorVisible
=
(
view
,
visible
)
->
expect
(
view
.
$
(
".js-group-select"
).
is
(
":visible"
)).
toEqual
(
visible
)
it
"is not visible to students"
,
->
@
view
.
render
()
expectCohortSelectorVisible
(
@
view
,
false
)
it
"allows moderators to select visibility"
,
->
DiscussionSpecHelper
.
makeModerator
()
@
view
.
render
()
expectCohortSelectorVisible
(
@
view
,
true
)
expect
(
@
view
.
$
(
".js-group-select"
).
prop
(
"disabled"
)).
toEqual
(
false
)
expectedGroupId
=
null
DiscussionSpecHelper
.
makeAjaxSpy
(
(
params
)
->
expect
(
params
.
data
.
group_id
).
toEqual
(
expectedGroupId
)
)
_
.
each
(
[
"1"
,
"2"
,
""
],
(
groupIdStr
)
=>
expectedGroupId
=
groupIdStr
@
view
.
$
(
".js-group-select"
).
val
(
groupIdStr
)
@
view
.
$
(
".js-post-title"
).
val
(
"dummy title"
)
@
view
.
$
(
".js-post-body textarea"
).
val
(
"dummy body"
)
@
view
.
$
(
".forum-new-post-form"
).
submit
()
expect
(
$
.
ajax
).
toHaveBeenCalled
()
$
.
ajax
.
reset
()
)
it
"posts to the correct URL"
,
->
topicId
=
"test_topic"
spyOn
(
$
,
"ajax"
).
andCallFake
(
...
...
@@ -171,7 +176,7 @@ describe "NewPostView", ->
{
always
:
->
}
)
view
=
new
NewPostView
(
el
:
$
(
"
.new-post-article
"
),
el
:
$
(
"
#fixture-element
"
),
collection
:
@
discussion
,
course_settings
:
new
DiscussionCourseSettings
({
allow_anonymous
:
false
,
...
...
common/static/coffee/src/discussion/discussion_router.coffee
View file @
3cf2481e
...
...
@@ -8,7 +8,11 @@ if Backbone?
@
discussion
=
options
[
'discussion'
]
@
course_settings
=
options
[
'course_settings'
]
@
nav
=
new
DiscussionThreadListView
(
collection
:
@
discussion
,
el
:
$
(
".forum-nav"
))
@
nav
=
new
DiscussionThreadListView
(
collection
:
@
discussion
,
el
:
$
(
".forum-nav"
),
courseSettings
:
@
course_settings
)
@
nav
.
on
"thread:selected"
,
@
navigateToThread
@
nav
.
on
"thread:removed"
,
@
navigateToAllThreads
@
nav
.
on
"threads:rendered"
,
@
setActiveThread
...
...
common/static/coffee/src/discussion/views/discussion_thread_list_view.coffee
View file @
3cf2481e
...
...
@@ -13,7 +13,8 @@ if Backbone?
"change .forum-nav-filter-main-control"
:
"chooseFilter"
"change .forum-nav-filter-cohort-control"
:
"chooseCohort"
initialize
:
->
initialize
:
(
options
)
->
@
courseSettings
=
options
.
courseSettings
@
displayedCollection
=
new
Discussion
(
@
collection
.
models
,
pages
:
@
collection
.
pages
)
@
collection
.
on
"change"
,
@
reloadDisplayedCollection
@
discussionIds
=
""
...
...
@@ -121,7 +122,12 @@ if Backbone?
render
:
->
@
timer
=
0
@
$el
.
html
(
@
template
())
@
$el
.
html
(
@
template
({
isCohorted
:
@
courseSettings
.
get
(
"is_cohorted"
),
isPrivilegedUser
:
DiscussionUtil
.
isPrivilegedUser
()
})
)
@
$
(
".forum-nav-sort-control"
).
val
(
@
collection
.
sort_preference
)
$
(
window
).
bind
"load"
,
@
updateSidebar
...
...
lms/templates/discussion/_thread_list_template.html
View file @
3cf2481e
...
...
@@ -37,22 +37,16 @@
<
option
value
=
"flagged"
>
$
{
_
(
"Flagged"
)}
<
/option
>
%
endif
<
/select
>
<
/label>
\
%
if
is_course_cohorted
and
is_moderator
:
##
Lack
of
indentation
is
intentional
to
avoid
whitespace
between
this
and
siblings
<
label
class
=
"forum-nav-filter-cohort"
>
<
/label>${"<% if
(
isCohorted && isPrivilegedUser
)
{ %>"}<label class="forum-nav-filter-cohort"
>
##
Translators
:
This
labels
a
cohort
menu
in
forum
navigation
<
span
class
=
"sr"
>
$
{
_
(
"Cohort:"
)}
<
/span
>
<
select
class
=
"forum-nav-filter-cohort-control"
>
<
option
value
=
"
all
"
>
$
{
_
(
"in all cohorts"
)}
<
/option
>
<
option
value
=
""
>
$
{
_
(
"in all cohorts"
)}
<
/option
>
%
for
c
in
cohorts
:
<
option
value
=
"${c['id']}"
>
$
{
c
[
'name'
]}
<
/option
>
%
endfor
<
/select
>
<
/label>
\
%
endif
##
Lack
of
indentation
is
intentional
to
avoid
whitespace
between
this
and
siblings
<
label
class
=
"forum-nav-sort"
>
<
/label>${"<% } %>"}<label class="forum-nav-sort"
>
##
Translators
:
This
labels
a
sort
menu
in
forum
navigation
<
span
class
=
"sr"
>
$
{
_
(
"Sort:"
)}
<
/span
>
<
select
class
=
"forum-nav-sort-control"
>
...
...
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