diff --git a/cms/djangoapps/contentstore/features/static-pages.feature b/cms/djangoapps/contentstore/features/static-pages.feature new file mode 100644 index 0000000000..99a4e802dd --- /dev/null +++ b/cms/djangoapps/contentstore/features/static-pages.feature @@ -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" diff --git a/cms/djangoapps/contentstore/features/static-pages.py b/cms/djangoapps/contentstore/features/static-pages.py new file mode 100644 index 0000000000..2a1110de40 --- /dev/null +++ b/cms/djangoapps/contentstore/features/static-pages.py @@ -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 diff --git a/common/djangoapps/terrain/ui_helpers.py b/common/djangoapps/terrain/ui_helpers.py index ecd43eb719..c59d7030ff 100644 --- a/common/djangoapps/terrain/ui_helpers.py +++ b/common/djangoapps/terrain/ui_helpers.py @@ -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})