Merge pull request #18810 from edx/awais/lett_2_bc_pages
TE-2626: Studio Pages bokchoy tests
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
"""
|
||||
Pages page for a course.
|
||||
"""
|
||||
|
||||
from common.test.acceptance.pages.common.utils import click_css, confirm_prompt
|
||||
from common.test.acceptance.pages.studio.course_page import CoursePage
|
||||
from bok_choy.promise import EmptyPromise
|
||||
from selenium.webdriver import ActionChains
|
||||
|
||||
|
||||
class PagesPage(CoursePage):
|
||||
@@ -14,3 +16,101 @@ class PagesPage(CoursePage):
|
||||
|
||||
def is_browser_on_page(self):
|
||||
return self.q(css='body.view-static-pages').present
|
||||
|
||||
def is_static_page_present(self):
|
||||
"""
|
||||
Checks for static tab's presence
|
||||
|
||||
Returns:
|
||||
bool: True if present
|
||||
"""
|
||||
return self.q(css='.wrapper.wrapper-component-action-header').present
|
||||
|
||||
def add_static_page(self):
|
||||
"""
|
||||
Adds a static page
|
||||
"""
|
||||
total_tabs = len(self.q(css='.course-nav-list>li'))
|
||||
click_css(self, '.add-pages .new-tab', require_notification=False)
|
||||
self.wait_for(
|
||||
lambda: len(self.q(css='.course-nav-list>li')) == total_tabs + 1,
|
||||
description="Static tab is added"
|
||||
)
|
||||
self.wait_for_element_visibility(
|
||||
'.tab-list :nth-child({}) .xblock-student_view'.format(total_tabs),
|
||||
'Static tab is visible'
|
||||
)
|
||||
# self.wait_for_ajax()
|
||||
|
||||
def delete_static_tab(self):
|
||||
"""
|
||||
Deletes a static page
|
||||
"""
|
||||
click_css(self, '.btn-default.delete-button.action-button', require_notification=False)
|
||||
confirm_prompt(self)
|
||||
|
||||
def click_edit_static_page(self):
|
||||
"""
|
||||
Clicks on edit button to open up the xblock modal
|
||||
"""
|
||||
self.q(css='.edit-button').first.click()
|
||||
EmptyPromise(
|
||||
lambda: self.q(css='.xblock-studio_view').present,
|
||||
'Wait for the Studio editor to be present'
|
||||
).fulfill()
|
||||
|
||||
def drag_and_drop_first_static_page_to_last(self):
|
||||
"""
|
||||
Drags and drops the first the static page to the last
|
||||
"""
|
||||
draggable_elements = self.q(css='.component .drag-handle').results
|
||||
source_element = draggable_elements[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):
|
||||
"""
|
||||
Return titles of all static tabs
|
||||
Returns:
|
||||
list: list of all the titles
|
||||
"""
|
||||
self.wait_for_element_visibility(
|
||||
'.wrapper-component-action-header .component-actions',
|
||||
"Tab's edit button is visible"
|
||||
)
|
||||
return self.q(css='div.xmodule_StaticTabModule').text
|
||||
|
||||
def open_settings_tab(self):
|
||||
"""
|
||||
Clicks settings tab
|
||||
"""
|
||||
self.q(css='.editor-modes .settings-button').first.click()
|
||||
self.wait_for_ajax()
|
||||
|
||||
def set_field_val(self, field_display_name, field_value):
|
||||
"""
|
||||
Set the value of a field in editor
|
||||
|
||||
Arguments:
|
||||
field_display_name(str): Display name of the field for which the value is to be changed
|
||||
field_value(str): New value for the field
|
||||
"""
|
||||
selector = '.xblock-studio_view li.field label:contains("{}") + input'.format(field_display_name)
|
||||
script = '$(arguments[0]).val(arguments[1]).change();'
|
||||
self.browser.execute_script(script, selector, field_value)
|
||||
|
||||
def save(self):
|
||||
"""
|
||||
Clicks save button.
|
||||
"""
|
||||
click_css(self, '.action-save')
|
||||
|
||||
def refresh_and_wait_for_load(self):
|
||||
"""
|
||||
Refresh the page and wait for all resources to load.
|
||||
"""
|
||||
self.browser.refresh()
|
||||
self.wait_for_page()
|
||||
|
||||
109
common/test/acceptance/tests/studio/test_studio_tabs.py
Normal file
109
common/test/acceptance/tests/studio/test_studio_tabs.py
Normal file
@@ -0,0 +1,109 @@
|
||||
"""
|
||||
Acceptance tests for Studio related to the Pages.
|
||||
"""
|
||||
from common.test.acceptance.tests.studio.base_studio_test import StudioCourseTest
|
||||
from common.test.acceptance.pages.studio.edit_tabs import PagesPage
|
||||
|
||||
|
||||
class PagesTest(StudioCourseTest):
|
||||
"""
|
||||
Test that Pages functionality is working properly on studio side
|
||||
"""
|
||||
|
||||
def setUp(self, is_staff=True): # pylint: disable=arguments-differ
|
||||
"""
|
||||
Install a course with no content using a fixture.
|
||||
"""
|
||||
super(PagesTest, self).setUp(is_staff)
|
||||
self.pages_page = PagesPage(
|
||||
self.browser,
|
||||
self.course_info['org'],
|
||||
self.course_info['number'],
|
||||
self.course_info['run']
|
||||
)
|
||||
self.pages_page.visit()
|
||||
|
||||
def test_user_can_add_static_tab(self):
|
||||
"""
|
||||
Scenario: Users can add static pages
|
||||
Given I have opened the pages page in a new course
|
||||
Then I should not see any static pages
|
||||
When I add a new static page
|
||||
Then I should see a static page named "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.assertTrue(
|
||||
self.pages_page.is_static_page_present(),
|
||||
'Static tab should be present on the page'
|
||||
)
|
||||
|
||||
def test_user_can_delete_static_tab(self):
|
||||
"""
|
||||
Scenario: Users can delete static pages
|
||||
Given I have created a static page
|
||||
When I "delete" the static page
|
||||
Then I am shown a prompt
|
||||
When I confirm the prompt
|
||||
Then I should not see any static pages
|
||||
"""
|
||||
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.delete_static_tab()
|
||||
self.assertFalse(
|
||||
self.pages_page.is_static_page_present(),
|
||||
'Static tab should not be present on the page after the deletion'
|
||||
)
|
||||
|
||||
def test_user_can_edit_static_tab(self):
|
||||
"""
|
||||
Scenario: Users can edit static pages
|
||||
Given I have created a static page
|
||||
When I "edit" the static page
|
||||
And I change the name to "New"
|
||||
Then I should see static page named "New"
|
||||
"""
|
||||
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.assertNotEqual(self.pages_page.static_tab_titles[0], "New")
|
||||
self.pages_page.click_edit_static_page()
|
||||
self.pages_page.open_settings_tab()
|
||||
self.pages_page.set_field_val("Display Name", "New")
|
||||
self.pages_page.save()
|
||||
self.assertEqual(self.pages_page.static_tab_titles[0], "New", "The title of the tab is not updated")
|
||||
|
||||
def test_user_can_reorder_static_tabs(self):
|
||||
"""
|
||||
Scenario: Users can reorder static pages
|
||||
Given I have created two different static pages
|
||||
When I drag the first static page to the last
|
||||
Then the static pages are switched
|
||||
And I reload the page
|
||||
Then the static pages are switched
|
||||
"""
|
||||
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()
|
||||
self.pages_page.drag_and_drop_first_static_page_to_last()
|
||||
self.pages_page.refresh_and_wait_for_load()
|
||||
static_tab_titles = self.pages_page.static_tab_titles
|
||||
self.assertEqual(
|
||||
static_tab_titles,
|
||||
['Empty', 'First'],
|
||||
'Order should be:["Empty", "First] but getting {} from the page'.format(static_tab_titles)
|
||||
)
|
||||
Reference in New Issue
Block a user