Commit d9f87ad2 by Attiya Ishaque Committed by GitHub

Merge pull request #14882 from edx/ai/TNL-5515-discussion-sorting

TNL-5515. Fix discussion topic navigation and sorting option.
parents 3daa07a2 25435cfc
......@@ -43,6 +43,7 @@
this.course_settings = options.course_settings;
this.is_commentable_cohorted = options.is_commentable_cohorted;
this.topicId = options.topicId;
this.discussionBoardView = options.discussionBoardView;
};
NewPostView.prototype.render = function() {
......@@ -161,8 +162,17 @@
},
error: DiscussionUtil.formErrorHandler(this.$('.post-errors')),
success: function(response) {
var thread;
var thread, discussionBreadcrumbsModel;
thread = new Thread(response.content);
// Update the breadcrumbs and discussion Id(s) related to current topic
if (self.discussionBoardView) {
discussionBreadcrumbsModel = self.discussionBoardView.breadcrumbs.model;
if (discussionBreadcrumbsModel.get('contents').length) {
discussionBreadcrumbsModel.set('contents', self.topicView.topicText.split('/'));
}
self.discussionBoardView.discussionThreadListView.discussionIds =
self.topicView.currentTopicId;
}
self.$el.addClass('is-hidden');
self.resetForm();
self.trigger('newPost:createPost');
......
......@@ -297,6 +297,22 @@ class DiscussionNavigationTest(BaseDiscussionTestCase):
self.thread_page.q(css=".breadcrumbs .nav-item")[0].click()
self.assertEqual(self.thread_page.q(css=".search-input").text[0], "")
def test_navigation_and_sorting(self):
"""
Test that after adding the post, user sorting preference is changing properly
and recently added post is shown.
"""
topic_button = self.thread_page.q(
css=".forum-nav-browse-menu-item[data-discussion-id='{}']".format(self.discussion_id)
)
self.assertTrue(topic_button.visible)
topic_button.click()
sort_page = DiscussionSortPreferencePage(self.browser, self.course_id)
for sort_type in ["votes", "comments", "activity"]:
sort_page.change_sort_preference(sort_type)
# Verify that recently added post titled "dummy thread title" is shown in each sorting preference
self.assertEqual(self.thread_page.q(css=".forum-nav-thread-title").text[0], 'dummy thread title')
@attr(shard=2)
class DiscussionTabSingleThreadTest(BaseDiscussionTestCase, DiscussionResponsePaginationTestMixin):
......
......@@ -57,6 +57,7 @@
el: $('.new-post-article'),
collection: discussion,
course_settings: courseSettings,
discussionBoardView: discussionBoardView,
mode: 'tab',
startHeader: 2
});
......
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