Commit 6f447d0b by noraiz-anwar

Hide Add a post during discussion blackout period

parent ff66781a
...@@ -567,6 +567,12 @@ class InlineDiscussionPage(PageObject, DiscussionPageMixin): ...@@ -567,6 +567,12 @@ class InlineDiscussionPage(PageObject, DiscussionPageMixin):
) )
self._find_within(selector).click() self._find_within(selector).click()
def is_new_post_button_visible(self):
"""
Check if new post button present and visible
"""
return self._is_element_visible('.new-post-btn')
@wait_for_js @wait_for_js
def _is_element_visible(self, selector): def _is_element_visible(self, selector):
query = self._find_within(selector) query = self._find_within(selector)
......
...@@ -1054,6 +1054,15 @@ class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMix ...@@ -1054,6 +1054,15 @@ class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMix
# Add a Post link is present # Add a Post link is present
self.assertTrue(self.discussion_page.q(css='.new-post-btn').present) self.assertTrue(self.discussion_page.q(css='.new-post-btn').present)
def test_add_post_not_present_if_discussion_blackout_period_started(self):
"""
If discussion blackout period has started Add a post button should not appear.
"""
self.start_discussion_blackout_period()
self.browser.refresh()
self.discussion_page.expand_discussion()
self.assertFalse(self.discussion_page.is_new_post_button_visible())
def test_initial_render(self): def test_initial_render(self):
self.assertFalse(self.discussion_page.is_discussion_expanded()) self.assertFalse(self.discussion_page.is_discussion_expanded())
...@@ -1077,20 +1086,7 @@ class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMix ...@@ -1077,20 +1086,7 @@ class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMix
self.check_anonymous_to_peers(False) self.check_anonymous_to_peers(False)
def test_discussion_blackout_period(self): def test_discussion_blackout_period(self):
now = datetime.datetime.now(UTC) self.start_discussion_blackout_period()
self.course_fix.add_advanced_settings(
{
u"discussion_blackouts": {
"value": [
[
(now - datetime.timedelta(days=14)).isoformat(),
(now + datetime.timedelta(days=2)).isoformat()
]
]
}
}
)
self.course_fix._add_advanced_settings()
self.browser.refresh() self.browser.refresh()
thread = Thread(id=uuid4().hex, commentable_id=self.discussion_id) thread = Thread(id=uuid4().hex, commentable_id=self.discussion_id)
thread_fixture = SingleThreadViewFixture(thread) thread_fixture = SingleThreadViewFixture(thread)
...@@ -1159,6 +1155,25 @@ class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMix ...@@ -1159,6 +1155,25 @@ class InlineDiscussionTest(UniqueCourseTest, DiscussionResponsePaginationTestMix
self.assertIsNone(self.discussion_page.new_post_form) self.assertIsNone(self.discussion_page.new_post_form)
self.assertIsNone(self.additional_discussion_page.new_post_form) self.assertIsNone(self.additional_discussion_page.new_post_form)
def start_discussion_blackout_period(self):
"""
Start discussion blackout period, starting 14 days before now to 2 days ago.
"""
now = datetime.datetime.now(UTC)
self.course_fix.add_advanced_settings(
{
u"discussion_blackouts": {
"value": [
[
(now - datetime.timedelta(days=14)).isoformat(),
(now + datetime.timedelta(days=2)).isoformat()
]
]
}
}
)
self.course_fix._add_advanced_settings() # pylint: disable=protected-access
@attr(shard=2) @attr(shard=2)
class DiscussionUserProfileTest(UniqueCourseTest): class DiscussionUserProfileTest(UniqueCourseTest):
......
...@@ -26,6 +26,7 @@ var $$course_id = "${course_id | n, js_escaped_string}"; ...@@ -26,6 +26,7 @@ var $$course_id = "${course_id | n, js_escaped_string}";
function DiscussionInlineBlock(runtime, element) { function DiscussionInlineBlock(runtime, element) {
'use strict'; 'use strict';
new DiscussionInlineView({ el: $(element).find('.discussion-module') }); var el = $(element).find('.discussion-module');
new DiscussionInlineView({ el: el, readOnly: el.data('read-only') });
} }
</script> </script>
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