Skip to content
Snippets Groups Projects
Unverified Commit d8a9dd43 authored by Agha Awais's avatar Agha Awais Committed by GitHub
Browse files

Merge pull request #19584 from edx/awais/lett_2_bc_pages_II

Remaining bokchoy tests for pages
parents 74a47cda c5caa17a
No related merge requests found
......@@ -70,6 +70,19 @@ class PagesPage(CoursePage):
action.drag_and_drop(source_element, target_element).perform()
self.wait_for_ajax()
def drag_and_drop(self, default_tab=False):
"""
Drags and drops the first static page to the last
"""
css_selector = '.component .drag-handle'
if default_tab:
css_selector = '.drag-handle.action'
source_element = self.q(css=css_selector).results[0]
target_element = self.q(css='.new-component-item').results[0]
action = ActionChains(self.browser)
action.drag_and_drop(source_element, target_element).perform()
self.wait_for_ajax()
@property
def static_tab_titles(self):
"""
......@@ -83,6 +96,15 @@ class PagesPage(CoursePage):
)
return self.q(css='div.xmodule_StaticTabModule').text
@property
def built_in_page_titles(self):
"""
Gets the default tab title
Returns:
list: list of all the titles
"""
return self.q(css='.course-nav-list.ui-sortable h3').text
def open_settings_tab(self):
"""
Clicks settings tab
......@@ -90,6 +112,27 @@ class PagesPage(CoursePage):
self.q(css='.editor-modes .settings-button').first.click()
self.wait_for_ajax()
def is_tab_visible(self, tab_name):
"""
Checks for the tab's visibility
Args:
tab_name(string): Name of the tab for which visibility is to be checked
Returns:
true(bool): if tab is visible
false(bool): if tab is not visible
"""
css_selector = '[data-tab-id="{}"] .toggle-checkbox'.format(tab_name)
return True if not self.q(css=css_selector).selected else False
def toggle_tab(self, tab_name):
"""
Toggles the visibility on tab
Args:
tab_name(string): Name of the tab to be toggled
"""
css_selector = '[data-tab-id="{}"] .action-visible'.format(tab_name)
return self.q(css=css_selector).first.click()
def set_field_val(self, field_display_name, field_value):
"""
Set the value of a field in editor
......
......@@ -99,7 +99,7 @@ class PagesTest(StudioCourseTest):
self.pages_page.set_field_val("Display Name", "First")
self.pages_page.save()
self.pages_page.add_static_page()
self.pages_page.drag_and_drop_first_static_page_to_last()
self.pages_page.drag_and_drop()
self.pages_page.refresh_and_wait_for_load()
static_tab_titles = self.pages_page.static_tab_titles
self.assertEqual(
......@@ -107,3 +107,78 @@ class PagesTest(StudioCourseTest):
['Empty', 'First'],
'Order should be:["Empty", "First] but getting {} from the page'.format(static_tab_titles)
)
def test_user_can_reorder_builtin_tabs(self):
"""
Scenario: Users can reorder built-in pages
Given I have opened the pages page in a new course
Then the built-in pages are in the default order
When I drag the first page to the last
Then the built-in pages are switched
And I reload the page
Then the built-in pages are switched
"""
default_order = ['Home', 'Course', 'Discussion', 'Wiki', 'Progress']
new_order = ['Home', 'Course', 'Wiki', 'Progress', 'Discussion']
self.assertEqual(
self.pages_page.built_in_page_titles,
default_order,
'Tabs are not in the default order'
)
self.pages_page.drag_and_drop(default_tab=True)
built_in_page_titles = self.pages_page.built_in_page_titles
self.assertEqual(
built_in_page_titles,
new_order,
'Tabs are not in the new order'
)
self.pages_page.refresh_and_wait_for_load()
self.assertEqual(
built_in_page_titles,
new_order,
'Tabs are not in the new order'
)
def test_users_can_toggle_visibility(self):
"""
Scenario: Users can toggle visibility on hideable pages
Given I have opened the pages page in a new course
Then I should see the "wiki" page as "visible"
When I toggle the visibility of the "wiki" page
Then I should see the "wiki" page as "hidden"
And I reload the page
Then I should see the "wiki" page as "hidden"
When I toggle the visibility of the "wiki" page
Then I should see the "wiki" page as "visible"
And I reload the page
Then I should see the "wiki" page as "visible"
"""
tab = 'wiki'
self.assertTrue(self.pages_page.is_tab_visible(tab))
self.pages_page.toggle_tab(tab)
self.assertFalse(self.pages_page.is_tab_visible(tab))
self.pages_page.refresh_and_wait_for_load()
self.assertFalse(self.pages_page.is_tab_visible(tab))
self.pages_page.toggle_tab(tab)
self.assertTrue(self.pages_page.is_tab_visible(tab))
self.pages_page.refresh_and_wait_for_load()
self.assertTrue(self.pages_page.is_tab_visible(tab))
def test_default_order_with_static_pages(self):
"""
Scenario: Users can reorder built-in pages amongst static pages
Given I have created two different static pages
Then the pages are in the default order
"""
expected_order = ['Home', 'Course', 'Discussion', 'Wiki', 'Progress', 'First', 'Empty']
self.assertFalse(
self.pages_page.is_static_page_present(),
'Static tab should not be present on the page for a newly created course'
)
self.pages_page.add_static_page()
self.pages_page.click_edit_static_page()
self.pages_page.set_field_val("Display Name", "First")
self.pages_page.save()
self.pages_page.add_static_page()
tab_names = self.pages_page.built_in_page_titles + self.pages_page.static_tab_titles
self.assertEqual(tab_names, expected_order)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment