In user profile changing page should reposition window to top

When we change the page using pagination in the user
profile page the data gets updated but the position
of the window remains at pagination. It should change
position of window to top.

TNL-107
This commit is contained in:
Waqas Khalid
2014-11-26 16:00:54 +05:00
parent baaf5fa8a7
commit 0eab14a334
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):