Added tests for static pages
Also added in drag and drop helper. Please be careful using this method as it is truly a hack to obtain the visual effects. As of this commit, selenium does not support drag and drop for jQuery sortable items
This commit is contained in:
34
cms/djangoapps/contentstore/features/static-pages.feature
Normal file
34
cms/djangoapps/contentstore/features/static-pages.feature
Normal file
@@ -0,0 +1,34 @@
|
||||
Feature: Static Pages
|
||||
As a course author, I want to be able to add static pages
|
||||
|
||||
Scenario: Users can add static pages
|
||||
Given I have opened a new course in Studio
|
||||
And I go to the static pages page
|
||||
When I add a new page
|
||||
Then I should see a "Empty" static page
|
||||
|
||||
Scenario: Users can delete static pages
|
||||
Given I have opened a new course in Studio
|
||||
And I go to the static pages page
|
||||
And I add a new page
|
||||
When I will confirm all alerts
|
||||
And I "delete" the "Empty" page
|
||||
Then I should not see a "Empty" static page
|
||||
|
||||
Scenario: Users can edit static pages
|
||||
Given I have opened a new course in Studio
|
||||
And I go to the static pages page
|
||||
And I add a new page
|
||||
When I "edit" the "Empty" page
|
||||
And I change the name to "New"
|
||||
Then I should see a "New" static page
|
||||
|
||||
Scenario: Users can reorder static pages
|
||||
Given I have opened a new course in Studio
|
||||
And I go to the static pages page
|
||||
And I add a new page
|
||||
And I "edit" the "Empty" page
|
||||
And I change the name to "New"
|
||||
And I add a new page
|
||||
When I move "New" after "Empty"
|
||||
Then I see the order is "Empty New"
|
||||
76
cms/djangoapps/contentstore/features/static-pages.py
Normal file
76
cms/djangoapps/contentstore/features/static-pages.py
Normal file
@@ -0,0 +1,76 @@
|
||||
#pylint: disable=C0111
|
||||
#pylint: disable=W0621
|
||||
|
||||
from lettuce import world, step
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
|
||||
|
||||
@step(u'I go to the static pages page')
|
||||
def go_to_uploads(step):
|
||||
menu_css = 'li.nav-course-courseware'
|
||||
uploads_css = '.nav-course-courseware-pages'
|
||||
world.css_find(menu_css).click()
|
||||
world.css_find(uploads_css).click()
|
||||
|
||||
|
||||
@step(u'I add a new page')
|
||||
def add_page(step):
|
||||
button_css = '.new-button'
|
||||
world.css_find(button_css).click()
|
||||
|
||||
|
||||
@step(u'I should( not)? see a "([^"]*)" static page$')
|
||||
def see_page(step, doesnt, page):
|
||||
index = get_index(page)
|
||||
if doesnt:
|
||||
assert index == -1
|
||||
else:
|
||||
assert index != -1
|
||||
|
||||
|
||||
@step(u'I "([^"]*)" the "([^"]*)" page$')
|
||||
def click_edit_delete(step, edit_delete, page):
|
||||
button_css = '.%s-button' % edit_delete
|
||||
index = get_index(page)
|
||||
assert index != -1
|
||||
world.css_find(button_css)[index].click()
|
||||
|
||||
|
||||
@step(u'I change the name to "([^"]*)"$')
|
||||
def change_name(step, new_name):
|
||||
settings_css = '#settings-mode'
|
||||
world.css_find(settings_css).click()
|
||||
input_css = '.setting-input'
|
||||
name_input = world.css_find(input_css)
|
||||
old_name = name_input.value
|
||||
for count in range(len(old_name)):
|
||||
name_input._element.send_keys(Keys.END, Keys.BACK_SPACE)
|
||||
name_input._element.send_keys(new_name)
|
||||
save_button = '.save-button'
|
||||
world.css_find(save_button).click()
|
||||
|
||||
|
||||
@step(u'I move "([^"]*)" after "([^"]*)"$')
|
||||
def change_list(step, item1, item2):
|
||||
index1 = get_index(item1)
|
||||
index2 = get_index(item2)
|
||||
assert index1 != -1 and index2 != -1
|
||||
world.drag_sortable_after(".component", index1, index2, ".ui-sortable")
|
||||
|
||||
|
||||
@step(u'I see the order is "([^"]*)"$')
|
||||
def check_order(step, items):
|
||||
items = items.split(' ')
|
||||
name_css = 'section[data-type="HTMLModule"]'
|
||||
all_elements = world.css_find(name_css)
|
||||
for i in range(len(items)):
|
||||
assert all_elements[i].html == '\n %s\n' % items[i]
|
||||
|
||||
|
||||
def get_index(name):
|
||||
page_name_css = 'section[data-type="HTMLModule"]'
|
||||
all_pages = world.css_find(page_name_css)
|
||||
for i in range(len(all_pages)):
|
||||
if all_pages[i].html == '\n %s\n' % name:
|
||||
return i
|
||||
return -1
|
||||
@@ -158,3 +158,15 @@ def click_tools():
|
||||
tools_css = 'li.nav-course-tools'
|
||||
if world.browser.is_element_present_by_css(tools_css):
|
||||
world.css_click(tools_css)
|
||||
|
||||
|
||||
@world.absorb
|
||||
def drag_sortable_after(item_css, index1, index2, sortable_css):
|
||||
"""
|
||||
This is a hack in order to simulate jQuery's sortable list dragging as Selenium cannot currently do it with action_chains
|
||||
Please note that this is very finnicky with keeping the changes after refreshing the page so be careful when testing persistant changes
|
||||
Also note that this is mainly for visualization of the sortable list and the true sortable drag and drop fires many events
|
||||
"""
|
||||
world.browser.execute_script('$("%(item_css)s:eq(%(index_one)s)").insertAfter($("%(item_css)s:eq(%(index_two)s)"));\
|
||||
$("%(sortable_css)s").trigger("sortupdate")' %
|
||||
{'item_css': item_css, 'index_one': index1, 'index_two': index2, 'sortable_css': sortable_css})
|
||||
|
||||
Reference in New Issue
Block a user