diff --git a/common/test/acceptance/pages/lms/discussion.py b/common/test/acceptance/pages/lms/discussion.py index a512e94588..0a221fe897 100644 --- a/common/test/acceptance/pages/lms/discussion.py +++ b/common/test/acceptance/pages/lms/discussion.py @@ -552,3 +552,25 @@ class DiscussionTabHomePage(CoursePage, DiscussionPageMixin): lambda: _match_messages(text).results == [], "waiting for dismissed alerts to disappear" ).fulfill() + + def click_new_post_button(self): + """ + Clicks the 'New Post' button. + """ + self.new_post_button.click() + EmptyPromise( + lambda: ( + self.new_post_form + ), + "New post action succeeded" + ).fulfill() + + @property + def new_post_button(self): + elements = self.q(css="ol.course-tabs .new-post-btn") + return elements.first if elements.visible and len(elements) == 1 else None + + @property + def new_post_form(self): + elements = self.q(css=".forum-new-post-form") + return elements[0] if elements.visible and len(elements) == 1 else None diff --git a/common/test/acceptance/tests/discussion/test_discussion.py b/common/test/acceptance/tests/discussion/test_discussion.py index f82c0152a9..9efcadb629 100644 --- a/common/test/acceptance/tests/discussion/test_discussion.py +++ b/common/test/acceptance/tests/discussion/test_discussion.py @@ -111,6 +111,33 @@ class DiscussionResponsePaginationTestMixin(BaseDiscussionMixin): self.assertFalse(self.thread_page.has_add_response_button()) +@attr('shard_1') +class DiscussionHomePageTest(UniqueCourseTest): + """ + Tests for the discussion home page. + """ + + SEARCHED_USERNAME = "gizmo" + + def setUp(self): + super(DiscussionHomePageTest, self).setUp() + CourseFixture(**self.course_info).install() + AutoAuthPage(self.browser, course_id=self.course_id).visit() + self.page = DiscussionTabHomePage(self.browser, self.course_id) + self.page.visit() + + def test_new_post_button(self): + """ + Scenario: I can create new posts from the Discussion home page. + Given that I am on the Discussion home page + When I click on the 'New Post' button + Then I should be shown the new post form + """ + self.assertIsNotNone(self.page.new_post_button) + self.page.click_new_post_button() + self.assertIsNotNone(self.page.new_post_form) + + @attr('shard_1') class DiscussionTabSingleThreadTest(UniqueCourseTest, DiscussionResponsePaginationTestMixin): """ diff --git a/lms/templates/courseware/course_navigation.html b/lms/templates/courseware/course_navigation.html index 32606658d8..a2982b2e71 100644 --- a/lms/templates/courseware/course_navigation.html +++ b/lms/templates/courseware/course_navigation.html @@ -78,6 +78,7 @@ def url_class(is_active): % endfor + <%block name="extratabs" />