Commit 96c77a7f by Jim Abramson

Merge pull request #4271 from edx/jsa/fix-new-post-view-spec

update NewPostViewSpec to correctly initialize NewPostView
parents 3f2a6d1e 59e2a6dd
......@@ -7,28 +7,86 @@ describe "NewPostView", ->
<div class="inner-wrapper">
<form class="new-post-form">
<div class="left-column" >
<div class="form-topic-drop">
<a href="#" aria-labelledby="topic-dropdown-label" class="topic_dropdown_button">… / TA Feedba …
<span class="drop-arrow">▾</span></a>
<div class="topic_menu_wrapper">
<ul class="topic_menu" role="menu">
<li role="menuitem">
<a href="#"><span class="category-menu-span">Basic Question Types</span></a>
<ul role="menu">
<li role="menuitem"><a href="#" class="topic"
data-discussion_id="a22e81688d154e059f9a2012a26b27af"
aria-describedby="topic-name-span-a22e81688d154e059f9a2012a26b27af"
cohorted="False">Selection from Options</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</form>
</div>
</article>
<script aria-hidden="true" type="text/template" id="new-post-tab-template">
<div class="inner-wrapper">
<form class="new-post-form">
<div class="left-column">
'<%= topic_dropdown_html %>
'<%= options_html %>'
</div>
</form>
</div>
</script>
<script aria-hidden="true" type="text/template" id="new-post-menu-entry-template">
<li role="menuitem"><a href="#" class="topic" data-discussion_id="<%- id %>" aria-describedby="topic-name-span-<%- id %>" cohorted="<%- is_cohorted %>"><%- text %></a></li>
</script>
<script aria-hidden="true" type="text/template" id="new-post-menu-category-template">
<li role="menuitem">
<a href="#"><span class="category-menu-span"><%- text %></span></a>
<ul role="menu"><%= entries %></ul>
</li>
</script>
<script aria-hidden="true" type="text/template" id="new-post-topic-dropdown-template">
<span class="topic-dropdown-label" id="topic-dropdown-label">Create new post about:</span>
<div class="form-topic-drop">
<a href="#" aria-labelledby="topic-dropdown-label" class="topic_dropdown_button">${_("Show All Discussions")}<span class="drop-arrow" aria-hidden="true">▾</span></a>
<div class="topic_menu_wrapper">
<div class="topic_menu_search" role="menu">
<label class="sr" for="browse-topic-newpost">Filter List</label>
<input type="text" id="browse-topic-newpost" class="form-topic-drop-search-input" placeholder="Filter discussion areas">
</div>
<ul class="topic_menu" role="menu"><%= topics_html %></ul>
</div>
</div>
</script>
<script aria-hidden="true" type="text/template" id="new-post-options-template">
<div class="options">
<input type="checkbox" name="follow" class="discussion-follow" id="new-post-follow" checked><label for="new-post-follow">follow this post</label>
<% if (allow_anonymous) { %>
<br>
<input type="checkbox" name="anonymous" class="discussion-anonymous" id="new-post-anonymous">
<label for="new-post-anonymous">post anonymously</label>
<% } %>
<% if (allow_anonymous_to_peers) { %>
<br>
<input type="checkbox" name="anonymous_to_peers" class="discussion-anonymous-to-peers" id="new-post-anonymous-to-peers">
<label for="new-post-anonymous-to-peers">post anonymously to classmates</label>
<% } %>
<% if (cohort_options) { %>
<div class="form-group-label choose-cohort">
## Translators: This labels the selector for which group of students can view a post
Make visible to:
<select class="group-filter-select new-post-group" name="group_id">
<option value="">All Groups</option>
<% _.each(cohort_options, function(opt) { %>
<option value="<%= opt.value %>" <% if (opt.selected) { %>selected<% } %>><%- opt.text %></option>
<% }); %>
</select>
</div>
<% } %>
</div>
</script>
<script aria-hidden="true" type="text/template" id="new-post-editor-template">
<div class="form-row">
<label class="sr" for="new-post-title">new post title</label>
<input type="text" id="new-post-title" class="new-post-title" name="title" placeholder="Title">
</div>
<div class="form-row">
<div class="new-post-body" name="body" placeholder="Enter your question or comment…"></div>
</div>
<input type="submit" id="new-post-submit" class="submit" value="Add post">
<a href="#" class="new-post-cancel">Cancel</a>
</script>
"""
)
window.$$course_id = "edX/999/test"
......@@ -37,9 +95,32 @@ describe "NewPostView", ->
@view = new NewPostView(
el: $(".new-post-article"),
collection: @discussion,
course_settings: new DiscussionCourseSettings({
"category_map": {
"subcategories": {
"Basic Question Types": {
"subcategories": {},
"children": ["Selection From Options"],
"entries": {
"Selection From Options": {
"sort_key": null,
"is_cohorted": true,
"id": "cba3e4cd91d0466b9ac50926e495b76f"
}
},
},
},
"children": ["Basic Question Types"],
"entries": {}
},
"allow_anonymous": true,
"allow_anonymous_to_peers": true
}),
mode: "tab"
)
@parent_category_text = @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[0].text
@selected_option_text = @view.$el.find( "ul.topic_menu li[role='menuitem'] > a" )[1].text
@view.render()
@parent_category_text = "Basic Question Types"
@selected_option_text = "Selection From Options"
describe "Drop down works correct", ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment