bump studio-frontend to 1.16.12 and update bokchoy tests
This commit is contained in:
@@ -21,7 +21,7 @@ UPLOAD_FILE_DIR = Path(__file__).abspath().dirname().dirname().dirname().dirname
|
||||
class AssetIndexPageStudioFrontend(CoursePage):
|
||||
"""The Files and Uploads page for a course in Studio"""
|
||||
|
||||
PAGINATION_PAGE_ELEMENT = ".pagination li"
|
||||
PAGINATION_PAGE_ELEMENT = ".pagination .page-item"
|
||||
TABLE_SORT_BUTTONS = 'th.sortable button.btn-header'
|
||||
TYPE_FILTER_ELEMENT = 'div[data-identifier="asset-filters"] .form-group'
|
||||
URL_PATH = "assets"
|
||||
@@ -289,27 +289,23 @@ class AssetIndexPageStudioFrontend(CoursePage):
|
||||
@wait_for_js
|
||||
def is_previous_button_on_page(self):
|
||||
"""Note: the two conditions cover when the button is and is not disabled."""
|
||||
return 'previous' in self.q(css=self.PAGINATION_PAGE_ELEMENT).first.text \
|
||||
or 'previous' in self.q(css=self.PAGINATION_PAGE_ELEMENT + ' span').first.text
|
||||
return 'previous' in self.q(css=self.PAGINATION_PAGE_ELEMENT + ' .previous').text
|
||||
|
||||
@property
|
||||
@wait_for_js
|
||||
def is_next_button_on_page(self):
|
||||
"""Note: the two conditions cover when the button is and is not disabled."""
|
||||
return 'next' in self.q(css=self.PAGINATION_PAGE_ELEMENT).nth(
|
||||
self.number_of_pagination_buttons - 1).text \
|
||||
or 'next' in self.q(css=self.PAGINATION_PAGE_ELEMENT + ' span').nth(
|
||||
self.number_of_pagination_buttons - 1).text
|
||||
return 'next' in self.q(css=self.PAGINATION_PAGE_ELEMENT + ' .next').text
|
||||
|
||||
@wait_for_js
|
||||
def click_pagination_page_button(self, index):
|
||||
"""
|
||||
Click pagination previous button.
|
||||
Click pagination page button.
|
||||
Return False if no pagination page button at specified index.
|
||||
"""
|
||||
self.wait_for_ajax()
|
||||
if index < self.number_of_pagination_page_buttons:
|
||||
self.q(css=self.PAGINATION_PAGE_ELEMENT + '.page-item').nth(index).click()
|
||||
if index <= self.number_of_pagination_buttons:
|
||||
self.q(css=self.PAGINATION_PAGE_ELEMENT + ' .page-link').nth(index)[0].click()
|
||||
self.wait_for_ajax()
|
||||
return True
|
||||
return False
|
||||
@@ -322,8 +318,7 @@ class AssetIndexPageStudioFrontend(CoursePage):
|
||||
"""
|
||||
self.wait_for_ajax()
|
||||
if self.is_next_button_enabled:
|
||||
self.q(css=self.PAGINATION_PAGE_ELEMENT).nth(
|
||||
self.number_of_pagination_buttons - 1).click()
|
||||
self.q(css=self.PAGINATION_PAGE_ELEMENT + ' .next.page-link')[0].click()
|
||||
self.wait_for_ajax()
|
||||
return True
|
||||
return False
|
||||
@@ -336,22 +331,16 @@ class AssetIndexPageStudioFrontend(CoursePage):
|
||||
"""
|
||||
self.wait_for_ajax()
|
||||
if self.is_previous_button_enabled:
|
||||
self.q(css=self.PAGINATION_PAGE_ELEMENT).first.click()
|
||||
self.q(css=self.PAGINATION_PAGE_ELEMENT + ' .previous.page-link')[0].click()
|
||||
self.wait_for_ajax()
|
||||
return True
|
||||
return False
|
||||
|
||||
@property
|
||||
@wait_for_js
|
||||
def number_of_pagination_page_buttons(self):
|
||||
"""Return the number of pagination pages."""
|
||||
return len(self.q(css=self.PAGINATION_PAGE_ELEMENT + '.page-item'))
|
||||
|
||||
@property
|
||||
@wait_for_js
|
||||
def number_of_pagination_buttons(self):
|
||||
"""Return the number of total pagination page buttons, including previous, pages, and next buttons."""
|
||||
return len(self.q(css=self.PAGINATION_PAGE_ELEMENT))
|
||||
return len(self.q(css=self.PAGINATION_PAGE_ELEMENT + ' .page-link'))
|
||||
|
||||
@wait_for_js
|
||||
def is_selected_page(self, index):
|
||||
@@ -360,11 +349,11 @@ class AssetIndexPageStudioFrontend(CoursePage):
|
||||
Return false if the pagination page at the current index does not exist
|
||||
or is not selected.
|
||||
|
||||
Note: this does not include the 'previous' and 'next' buttons
|
||||
Note: this *does* include the 'previous' and 'next' buttons
|
||||
Note: 0-indexed
|
||||
"""
|
||||
if index < self.number_of_pagination_page_buttons:
|
||||
return 'active' in self.q(css=self.PAGINATION_PAGE_ELEMENT + '.page-item').nth(index).attrs('class')[0]
|
||||
if index < self.number_of_pagination_buttons:
|
||||
return 'active' in self.q(css=self.PAGINATION_PAGE_ELEMENT).nth(index)[0].get_attribute('class')
|
||||
return False
|
||||
|
||||
@wait_for_js
|
||||
|
||||
@@ -198,9 +198,9 @@ class AssetIndexTestStudioFrontendPagination(StudioCourseTest):
|
||||
files.append(file_path)
|
||||
course_fixture.add_asset(files)
|
||||
|
||||
def assert_correct_number_of_page_buttons(self, count):
|
||||
"""Make sure the correct number of page buttons are on the page."""
|
||||
assert self.asset_page.number_of_pagination_page_buttons == count
|
||||
def assert_correct_number_of_buttons(self, count):
|
||||
"""Make sure the correct number of buttons are on the page; includes previous and next. """
|
||||
assert self.asset_page.number_of_pagination_buttons == count
|
||||
|
||||
def assert_correct_direction_buttons(self):
|
||||
"""Make sure the previous and next pagination buttons are on the page."""
|
||||
@@ -210,7 +210,7 @@ class AssetIndexTestStudioFrontendPagination(StudioCourseTest):
|
||||
def test_pagination_exists(self):
|
||||
"""Make sure the pagination elements are on the page."""
|
||||
self.asset_page.visit()
|
||||
self.assert_correct_number_of_page_buttons(2)
|
||||
self.assert_correct_number_of_buttons(4)
|
||||
self.assert_correct_direction_buttons()
|
||||
|
||||
def test_pagination_page_click(self):
|
||||
@@ -218,9 +218,8 @@ class AssetIndexTestStudioFrontendPagination(StudioCourseTest):
|
||||
self.asset_page.visit()
|
||||
|
||||
first_page_file_names = self.asset_page.asset_files_names
|
||||
|
||||
assert self.asset_page.click_pagination_page_button(1)
|
||||
assert self.asset_page.is_selected_page(1)
|
||||
assert self.asset_page.click_pagination_page_button(2)
|
||||
assert self.asset_page.is_selected_page(2)
|
||||
assert self.asset_page.number_of_asset_files == 1
|
||||
second_page_file_names = self.asset_page.asset_files_names
|
||||
|
||||
@@ -234,16 +233,15 @@ class AssetIndexTestStudioFrontendPagination(StudioCourseTest):
|
||||
self.asset_page.visit()
|
||||
|
||||
first_page_file_names = self.asset_page.asset_files_names
|
||||
|
||||
assert self.asset_page.click_pagination_next_button()
|
||||
assert self.asset_page.is_selected_page(1)
|
||||
assert self.asset_page.is_selected_page(2)
|
||||
assert self.asset_page.number_of_asset_files == 1
|
||||
next_page_file_names = self.asset_page.asset_files_names
|
||||
|
||||
assert first_page_file_names != next_page_file_names
|
||||
|
||||
assert self.asset_page.click_pagination_previous_button()
|
||||
assert self.asset_page.is_selected_page(0)
|
||||
assert self.asset_page.is_selected_page(1)
|
||||
assert self.asset_page.number_of_asset_files == 50
|
||||
previous_page_file_names = self.asset_page.asset_files_names
|
||||
|
||||
|
||||
Reference in New Issue
Block a user