Commit c51c1038 by alisan617 Committed by GitHub

Merge pull request #14576 from edx/alisan/discussion-topic-TNL-6205

Discussion topic area section after Add Post
parents 28e043ae 4197ebf7
...@@ -186,11 +186,13 @@ ...@@ -186,11 +186,13 @@
}; };
NewPostView.prototype.resetForm = function() { NewPostView.prototype.resetForm = function() {
var $general;
this.$('.forum-new-post-form')[0].reset(); this.$('.forum-new-post-form')[0].reset();
DiscussionUtil.clearFormErrors(this.$('.post-errors')); DiscussionUtil.clearFormErrors(this.$('.post-errors'));
this.$('.wmd-preview p').html(''); this.$('.wmd-preview p').html('');
if (this.isTabMode()) { if (this.isTabMode()) {
this.topicView.setTopic(this.$('button.topic-title').first()); $general = this.$('.post-topic option:contains(General)');
this.topicView.setTopic($general || this.$('button.topic-title').first());
} }
}; };
......
...@@ -240,6 +240,66 @@ ...@@ -240,6 +240,66 @@
}); });
}); });
}); });
describe('default topic ', function() {
beforeEach(function() {
this.course_settings = new DiscussionCourseSettings({
allow_anonymous_to_peers: true,
allow_anonymous: true,
category_map: {
subcategories: {
'Week 1': {
subcategories: {},
children: [
['Topic-Level Student-Visible Label', 'entry']
],
entries: {
'Topic-Level Student-Visible Label': {
sort_key: null,
is_cohorted: false,
id: '2b3a858d0c884eb4b272dbbe3f2ffddd'
}
}
}
},
children: [
['First topic', 'entry'],
['Week 1', 'subcategory']
],
entries: {
'First topic': {
sort_key: 'First topic',
is_cohorted: false,
id: 'i4x-waqastest-waqastest-course-waqastest'
}
}
}
});
});
it('should be the first topic if General is not found', function() {
var eventSpy, view;
view = new NewPostView({
el: $('#fixture-element'),
collection: this.discussion,
course_settings: this.course_settings,
mode: 'tab'
});
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-question']").click();
view.$('.js-post-title').val('Test Title');
view.$('.js-post-body textarea').val('Test body');
view.$('.wmd-preview p').html('Test body');
view.$('input[name=follow]').prop('checked', false);
view.$('input[name=anonymous]').prop('checked', true);
view.$('input[name=anonymous_to_peers]').prop('checked', true);
view.$("a[data-discussion-id='2b3a858d0c884eb4b272dbbe3f2ffddd']").click();
view.$('.cancel').click();
expect(view.$('.post-topic option:selected').text()).toEqual('First topic');
});
});
it('posts to the correct URL', function() { it('posts to the correct URL', function() {
var topicId, view; var topicId, view;
topicId = 'test_topic'; topicId = 'test_topic';
......
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