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
44363495
Commit
44363495
authored
Aug 13, 2015
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix JS unit tests for discussion.
parent
98b2e753
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
146 deletions
+2
-146
common/static/coffee/spec/discussion/view/new_post_view_spec.coffee
+2
-146
No files found.
common/static/coffee/spec/discussion/view/new_post_view_spec.coffee
View file @
44363495
...
@@ -74,31 +74,12 @@ describe "NewPostView", ->
...
@@ -74,31 +74,12 @@ describe "NewPostView", ->
# It should be visible and enabled once more.
# It should be visible and enabled once more.
checkVisibility
(
@
view
,
true
,
false
,
false
)
checkVisibility
(
@
view
,
true
,
false
,
false
)
checkVisibility
=
(
view
,
expectedVisible
)
=>
view
.
render
()
expect
(
view
.
$
(
".js-group-select"
).
is
(
":visible"
)).
toEqual
(
expectedVisible
)
if
expectedVisible
expect
(
view
.
$
(
".js-group-select"
).
prop
(
"disabled"
)).
toEqual
(
false
)
it
"is not visible to students"
,
->
checkVisibility
(
@
view
,
false
)
it
"allows TAs to see the cohort selector"
,
->
DiscussionSpecHelper
.
makeTA
()
checkVisibility
(
@
view
,
true
)
it
"allows moderators to see the cohort selector"
,
->
DiscussionSpecHelper
.
makeModerator
()
checkVisibility
(
@
view
,
true
)
it
"allows the user to make a cohort selection"
,
->
it
"allows the user to make a cohort selection"
,
->
DiscussionSpecHelper
.
makeModerator
()
DiscussionSpecHelper
.
makeModerator
()
@
view
.
render
()
@
view
.
render
()
expectedGroupId
=
null
expectedGroupId
=
null
DiscussionSpecHelper
.
makeAjaxSpy
(
DiscussionSpecHelper
.
makeAjaxSpy
(
(
params
)
=>
(
params
)
->
expect
(
params
.
data
.
group_id
).
toEqual
(
expectedGroupId
)
expect
(
params
.
data
.
group_id
).
toEqual
(
expectedGroupId
)
@
view
.
$
(
".forum-new-post-form"
).
removeAttr
(
"disabled"
)
)
)
_
.
each
(
_
.
each
(
...
@@ -111,6 +92,7 @@ describe "NewPostView", ->
...
@@ -111,6 +92,7 @@ describe "NewPostView", ->
@
view
.
$
(
".forum-new-post-form"
).
submit
()
@
view
.
$
(
".forum-new-post-form"
).
submit
()
expect
(
$
.
ajax
).
toHaveBeenCalled
()
expect
(
$
.
ajax
).
toHaveBeenCalled
()
$
.
ajax
.
reset
()
$
.
ajax
.
reset
()
@
view
.
$
(
".forum-new-post-form"
).
prop
(
'disabled'
,
false
)
)
)
describe
"always cohort inline discussions "
,
->
describe
"always cohort inline discussions "
,
->
...
@@ -226,132 +208,6 @@ describe "NewPostView", ->
...
@@ -226,132 +208,6 @@ describe "NewPostView", ->
checkPostCancelReset
(
mode
,
@
discussion
,
@
course_settings
)
checkPostCancelReset
(
mode
,
@
discussion
,
@
course_settings
)
)
)
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"
)
it
"is not visible to students"
,
->
checkVisibility
(
@
view
,
false
)
it
"allows TAs to see the cohort selector"
,
->
DiscussionSpecHelper
.
makeTA
()
checkVisibility
(
@
view
,
true
)
it
"allows moderators to see the cohort selector"
,
->
DiscussionSpecHelper
.
makeModerator
()
checkVisibility
(
@
view
,
true
)
it
"allows the user to make a cohort selection"
,
->
DiscussionSpecHelper
.
makeModerator
()
@
view
.
render
()
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
()
)
describe
"cancel post resets form "
,
->
beforeEach
->
@
course_settings
=
new
DiscussionCourseSettings
({
"allow_anonymous_to_peers"
:
true
,
"allow_anonymous"
:
true
,
"category_map"
:
{
"subcategories"
:
{
"Week 1"
:
{
"subcategories"
:
{},
"children"
:
[
"Topic-Level Student-Visible Label"
],
"entries"
:
{
"Topic-Level Student-Visible Label"
:
{
"sort_key"
:
null
,
"is_cohorted"
:
false
,
"id"
:
"2b3a858d0c884eb4b272dbbe3f2ffddd"
}
}
}
},
"children"
:
[
"General"
,
"Week 1"
],
"entries"
:
{
"General"
:
{
"sort_key"
:
"General"
,
"is_cohorted"
:
false
,
"id"
:
"i4x-waqastest-waqastest-course-waqastest"
}
}
}
})
checkPostCancelReset
=
(
mode
,
discussion
,
course_settings
)
->
view
=
new
NewPostView
(
el
:
$
(
"#fixture-element"
),
collection
:
discussion
,
course_settings
:
course_settings
,
mode
:
mode
)
view
.
render
()
eventSpy
=
jasmine
.
createSpy
(
'eventSpy'
)
view
.
listenTo
(
view
,
"newPost:cancel"
,
eventSpy
)
view
.
$
(
".post-errors"
).
html
(
"<li class='post-error'>Title can't be empty</li>"
)
view
.
$
(
"label[for$='post-type-discussion']"
).
click
()
view
.
$
(
".js-post-title"
).
val
(
"Test Title"
)
view
.
$
(
".js-post-body textarea"
).
val
(
"Test body"
)
view
.
$
(
".wmd-preview p"
).
html
(
"Test body"
)
view
.
$
(
".js-follow"
).
prop
(
"checked"
,
false
)
view
.
$
(
".js-anon"
).
prop
(
"checked"
,
true
)
view
.
$
(
".js-anon-peers"
).
prop
(
"checked"
,
true
)
if
mode
==
"tab"
view
.
$
(
"a[data-discussion-id='2b3a858d0c884eb4b272dbbe3f2ffddd']"
).
click
()
view
.
$
(
".cancel"
).
click
()
expect
(
eventSpy
).
toHaveBeenCalled
()
expect
(
view
.
$
(
".post-errors"
).
html
()).
toEqual
(
""
);
expect
(
$
(
"input[id$='post-type-question']"
)).
toBeChecked
()
expect
(
$
(
"input[id$='post-type-discussion']"
)).
not
.
toBeChecked
()
expect
(
view
.
$
(
".js-post-title"
).
val
()).
toEqual
(
""
);
expect
(
view
.
$
(
".js-post-body textarea"
).
val
()).
toEqual
(
""
);
expect
(
view
.
$
(
".js-follow"
)).
toBeChecked
()
expect
(
view
.
$
(
".js-anon"
)).
not
.
toBeChecked
()
expect
(
view
.
$
(
".js-anon-peers"
)).
not
.
toBeChecked
()
if
mode
==
"tab"
expect
(
view
.
$
(
".js-selected-topic"
).
text
()).
toEqual
(
"General"
)
_
.
each
([
"tab"
,
"inline"
],
(
mode
)
=>
it
"resets the form in
#{
mode
}
mode"
,
->
checkPostCancelReset
(
mode
,
@
discussion
,
@
course_settings
)
)
it
"posts to the correct URL"
,
->
it
"posts to the correct URL"
,
->
topicId
=
"test_topic"
topicId
=
"test_topic"
spyOn
(
$
,
"ajax"
).
andCallFake
(
spyOn
(
$
,
"ajax"
).
andCallFake
(
...
...
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