Merge pull request #6067 from mlkwaqas/waqas/tnl107-changing-pages-not-reposition

In user profile changing page should reposition window to top
This commit is contained in:
Waqas Khalid
2014-12-17 19:58:28 +05:00
3 changed files with 13 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ if Backbone?
@numPages = response.num_pages
@discussion.reset(response.discussion_data, {silent: false})
history.pushState({}, "", url)
$("html, body").animate({ scrollTop: 0 });
error: =>
DiscussionUtil.discussionAlert(
gettext("Sorry"),

View File

@@ -1,5 +1,6 @@
from contextlib import contextmanager
from bok_choy.javascript import wait_for_js
from bok_choy.page_object import PageObject
from bok_choy.promise import EmptyPromise, Promise
@@ -343,6 +344,10 @@ class DiscussionUserProfilePage(CoursePage):
self.q(css='section.user-profile div.sidebar-username').text[0] == self.username
)
@wait_for_js
def is_window_on_top(self):
return self.browser.execute_script("return $('html, body').offset().top") == 0
def get_shown_thread_ids(self):
elems = self.q(css="article.discussion-thread")
return [elem.get_attribute("id")[7:] for elem in elems]

View File

@@ -419,6 +419,7 @@ class DiscussionUserProfileTest(UniqueCourseTest):
current_page = 1
total_pages = max(num_threads - 1, 1) / self.PAGE_SIZE + 1
all_pages = range(1, total_pages + 1)
return page
def _check_page():
# ensure the page being displayed as "current" is the expected one
@@ -479,6 +480,12 @@ class DiscussionUserProfileTest(UniqueCourseTest):
def test_151_threads(self):
self.check_pages(151)
def test_pagination_window_reposition(self):
page = self.check_pages(50)
page.click_next_page()
page.wait_for_ajax()
self.assertTrue(page.is_window_on_top())
@attr('shard_1')
class DiscussionSearchAlertTest(UniqueCourseTest):