Commit 68303997 by Awais Jibran

Fix Discussion blackout date still has Add a Response text box

TNL-5111
parent a52cfd86
......@@ -108,6 +108,12 @@ class DiscussionThreadPage(PageObject, DiscussionPageMixin):
"""Returns true if the add response button is visible, false otherwise"""
return self.is_element_visible(".add-response-btn")
def has_discussion_reply_editor(self):
"""
Returns true if the discussion reply editor is is visible
"""
return self.is_element_visible(".discussion-reply-new")
def click_add_response_button(self):
"""
Clicks the add response button and ensures that the response text
......@@ -152,6 +158,13 @@ class DiscussionThreadPage(PageObject, DiscussionPageMixin):
with self.secondary_action_menu_open(".response_{} .discussion-response".format(response_id)):
return self.is_element_visible(".response_{} .discussion-response .action-edit".format(response_id))
def is_response_deletable(self, response_id):
"""
Returns true if the delete response button is present, false otherwise
"""
with self.secondary_action_menu_open(".response_{} .discussion-response".format(response_id)):
return self.is_element_visible(".response_{} .discussion-response .action-delete".format(response_id))
def get_response_body(self, response_id):
return self._get_element_text(".response_{} .response-body".format(response_id))
......
......@@ -104,3 +104,10 @@ class TabNavPage(PageObject):
lambda: self._is_on_tab(tab_name),
"{0} is the current tab".format(tab_name)
)
def has_new_post_button_visible_on_tab(self):
"""
Check if new post button present and visible on course tab page
"""
new_post_btn = self.q(css='ol.course-tabs .new-post-btn')
return new_post_btn.present and new_post_btn.visible
......@@ -21,6 +21,7 @@ from common.test.acceptance.pages.lms.discussion import (
DiscussionSortPreferencePage,
)
from common.test.acceptance.pages.lms.learner_profile import LearnerProfilePage
from common.test.acceptance.pages.lms.tab_nav import TabNavPage
from common.test.acceptance.fixtures.course import CourseFixture, XBlockFixtureDesc
from common.test.acceptance.fixtures.discussion import (
......@@ -285,6 +286,7 @@ class DiscussionTabSingleThreadTest(BaseDiscussionTestCase, DiscussionResponsePa
def setUp(self):
super(DiscussionTabSingleThreadTest, self).setUp()
AutoAuthPage(self.browser, course_id=self.course_id).visit()
self.tab_nav = TabNavPage(self.browser)
def setup_thread_page(self, thread_id):
self.thread_page = self.create_single_thread_page(thread_id) # pylint: disable=attribute-defined-outside-init
......@@ -348,6 +350,53 @@ class DiscussionTabSingleThreadTest(BaseDiscussionTestCase, DiscussionResponsePa
self.assertTrue(self.thread_page.is_add_comment_visible(response_id))
self.assertFalse(self.thread_page.is_show_comments_visible(response_id))
def test_discussion_blackout_period(self):
"""
Verify that new discussion can not be started during course blackout period.
Blackout period is the period between which students cannot post new or contribute
to existing discussions.
"""
now = datetime.datetime.now(UTC)
# Update course advance settings with a valid blackout period.
self.course_fixture.add_advanced_settings(
{
u"discussion_blackouts": {
"value": [
[
(now - datetime.timedelta(days=14)).isoformat(),
(now + datetime.timedelta(days=2)).isoformat()
]
]
}
}
)
self.course_fixture._add_advanced_settings() # pylint: disable=protected-access
self.browser.refresh()
thread = Thread(id=uuid4().hex, commentable_id=self.discussion_id)
thread_fixture = SingleThreadViewFixture(thread)
thread_fixture.addResponse(
Response(id="response1"),
[Comment(id="comment1")])
thread_fixture.push()
self.setup_thread_page(thread.get("id")) # pylint: disable=no-member
# Verify that `Add a Post` is not visible on course tab nav.
self.assertFalse(self.tab_nav.has_new_post_button_visible_on_tab())
# Verify that `Add a response` button is not visible.
self.assertFalse(self.thread_page.has_add_response_button())
# Verify user can not add new responses or modify existing responses.
self.assertFalse(self.thread_page.has_discussion_reply_editor())
self.assertFalse(self.thread_page.is_response_editable("response1"))
self.assertFalse(self.thread_page.is_response_deletable("response1"))
# Verify that user can not add new comment to a response or modify existing responses.
self.assertFalse(self.thread_page.is_add_comment_visible("response1"))
self.assertFalse(self.thread_page.is_comment_editable("comment1"))
self.assertFalse(self.thread_page.is_comment_deletable("comment1"))
@attr(shard=2)
class DiscussionTabMultipleThreadTest(BaseDiscussionTestCase):
......
......@@ -6,6 +6,7 @@
<%inherit file="../main.html" />
<%namespace name='static' file='../static_content.html'/>
<%!
import json
from django.utils.translation import ugettext as _
from django.template.defaultfilters import escapejs
from django.core.urlresolvers import reverse
......@@ -48,11 +49,11 @@ DiscussionBoardFactory({
<%block name="content">
<section class="discussion discussion-board container" id="discussion-container"
data-course-id="${course_id}"
data-user-create-comment="${can_create_comment}"
data-user-create-subcomment="${can_create_subcomment}"
data-user-create-comment="${json.dumps(can_create_comment)}"
data-user-create-subcomment="${json.dumps(can_create_subcomment)}"
data-read-only="false"
data-sort-preference="${sort_preference}"
data-flag-moderator="${flag_moderator}"
data-flag-moderator="${json.dumps(flag_moderator)}"
data-user-cohort-id="${user_cohort}">
<header class="page-header has-secondary">
## Breadcrumb navigation
......
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