Skip to content

Commit

Permalink
Discussion thread response show dual vote count
Browse files Browse the repository at this point in the history
When the responses of the thread is loaded it shows
dual vote count one with simple text and one with
button whereas only text should be shown when thread
is closed and only button when thread is open.

TNL-1016
  • Loading branch information
Waqas Khalid authored and e-kolpakov committed Feb 3, 2015
1 parent 55006bf commit 30a7318
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ if Backbone?
closed: (closed) ->
@updateButtonState(".action-close", closed)
@$(".post-label-closed").toggleClass("is-hidden", not closed)
@$(".action-vote").toggle(not closed)
@$(".display-vote").toggle(closed)
})

toggleSecondaryActions: (event) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ if Backbone?
@$('.comment-form').closest('li').toggle(not closed)
@$(".action-vote").toggle(not closed)
@$(".display-vote").toggle(closed)
# @$(".display-vote").toggle(closed)
@renderAddResponseButton()
})

Expand Down Expand Up @@ -256,6 +255,7 @@ if Backbone?
comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), votes: { up_count: 0 }, abuse_flaggers:[], endorsed: false, user_id: window.user.get("id"))
comment.set('thread', @model.get('thread'))
@renderResponseToList(comment, ".js-response-list")
@renderAttrs()
@model.addComment()
@renderAddResponseButton()

Expand Down
4 changes: 4 additions & 0 deletions common/test/acceptance/pages/lms/discussion.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ def is_browser_on_page(self):
def __getattr__(self, name):
return getattr(self.thread_page, name)

def close_open_thread(self):
with self.thread_page._secondary_action_menu_open(".forum-thread-main-wrapper"):
self._find_within(".forum-thread-main-wrapper .action-close").first.click()


class InlineDiscussionPage(PageObject):
url = None
Expand Down
50 changes: 50 additions & 0 deletions common/test/acceptance/tests/discussion/test_discussion.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,56 @@ def test_marked_answer_comments(self):
self.assertFalse(self.thread_page.is_show_comments_visible(response_id))


@attr('shard_1')
class DiscussionOpenClosedThreadTest(UniqueCourseTest):
"""
Tests for checking the display of attributes on open and closed threads
"""

def setUp(self):
super(DiscussionOpenClosedThreadTest, self).setUp()

# Create a course to register for
CourseFixture(**self.course_info).install()
self.thread_id = "test_thread_{}".format(uuid4().hex)

def setup_user(self, roles=[]):
roles_str = ','.join(roles)
self.user_id = AutoAuthPage(self.browser, course_id=self.course_id, roles=roles_str).visit().get_user_id()

def setup_view(self, **thread_kwargs):
view = SingleThreadViewFixture(
Thread(id=self.thread_id, **thread_kwargs)
)
view.addResponse(Response(id="response1"))
view.push()

def setup_openclosed_thread_page(self, closed=False):
self.setup_user(roles=['Moderator'])
if closed:
self.setup_view(closed=True)
else:
self.setup_view()
page = DiscussionTabSingleThreadPage(self.browser, self.course_id, self.thread_id)
page.visit()
page.close_open_thread()
return page

def test_originally_open_thread_vote_display(self):
page = self.setup_openclosed_thread_page()
self.assertFalse(page._is_element_visible('.forum-thread-main-wrapper .action-vote'))
self.assertTrue(page._is_element_visible('.forum-thread-main-wrapper .display-vote'))
self.assertFalse(page._is_element_visible('.response_response1 .action-vote'))
self.assertTrue(page._is_element_visible('.response_response1 .display-vote'))

def test_originally_closed_thread_vote_display(self):
page = self.setup_openclosed_thread_page(True)
self.assertTrue(page._is_element_visible('.forum-thread-main-wrapper .action-vote'))
self.assertFalse(page._is_element_visible('.forum-thread-main-wrapper .display-vote'))
self.assertTrue(page._is_element_visible('.response_response1 .action-vote'))
self.assertFalse(page._is_element_visible('.response_response1 .display-vote'))


@attr('shard_1')
class DiscussionCommentDeletionTest(UniqueCourseTest):
"""
Expand Down

0 comments on commit 30a7318

Please sign in to comment.