From eb14a07814db2b4ca9f2a240afc9ceac019141b1 Mon Sep 17 00:00:00 2001 From: JonahStanley Date: Tue, 11 Jun 2013 16:15:49 -0400 Subject: [PATCH] Added tests for course updates and handouts --- .../features/course-updates.feature | 44 ++++++++++ .../contentstore/features/course-updates.py | 82 +++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 cms/djangoapps/contentstore/features/course-updates.feature create mode 100644 cms/djangoapps/contentstore/features/course-updates.py diff --git a/cms/djangoapps/contentstore/features/course-updates.feature b/cms/djangoapps/contentstore/features/course-updates.feature new file mode 100644 index 0000000000..7266e4f9a6 --- /dev/null +++ b/cms/djangoapps/contentstore/features/course-updates.feature @@ -0,0 +1,44 @@ +Feature: Course updates + As a course author, I want to be able to provide updates to my students + + Scenario: Users can add updates + Given I have opened a new course in Studio + And I go to the course updates page + When I add a new update + And I make the text "Hello" + Then I should see the update "Hello" + + Scenario: Users can edit updates + Given I have opened a new course in Studio + And I go to the course updates page + When I add a new update + And I make the text "Hello" + And I click the "edit" button + And I make the text "Goodbye" + Then I should see the update "Goodbye" + + Scenario: Users can delete updates + Given I have opened a new course in Studio + And I go to the course updates page + And I add a new update + And I make the text "Hello" + When I will confirm all alerts + And I click the "delete" button + Then I should not see the update "Hello" + + + Scenario: Users can edit update dates + Given I have opened a new course in Studio + And I go to the course updates page + And I add a new update + And I make the text "Hello" + When I click the "edit" button + And I make the date "June 1, 2013" + Then I should see the date "June 1, 2013" + + Scenario: Users can change handouts + Given I have opened a new course in Studio + And I go to the course updates page + When I edit the handouts + And I make the text "
    Test
" + Then I see the handout "Test" diff --git a/cms/djangoapps/contentstore/features/course-updates.py b/cms/djangoapps/contentstore/features/course-updates.py new file mode 100644 index 0000000000..4d0b5ef174 --- /dev/null +++ b/cms/djangoapps/contentstore/features/course-updates.py @@ -0,0 +1,82 @@ +#pylint: disable=C0111 +#pylint: disable=W0621 + +from lettuce import world, step +from selenium.webdriver.common.keys import Keys + + +@step(u'I go to the course updates page') +def go_to_uploads(step): + menu_css = 'li.nav-course-courseware' + uploads_css = '.nav-course-courseware-updates' + world.css_find(menu_css).click() + world.css_find(uploads_css).click() + + +@step(u'I add a new update') +def add_update(step): + update_css = '.new-update-button' + world.css_find(update_css).click() + + +@step(u'I make the text "([^"]*)"$') +def change_text(step, text): + text_css = 'div.CodeMirror > div > textarea' + prev_css = 'div.CodeMirror-lines > div > div:last-child > pre' + all_lines = world.css_find(prev_css) + all_text = '' + for i in range(len(all_lines)): + all_text = all_lines[i].html + text_area = world.css_find(text_css) + for i in range(len(all_text)): + text_area._element.send_keys(Keys.END, Keys.BACK_SPACE) + text_area._element.send_keys(text) + save_css = '.save-button' + world.css_find(save_css).click() + + +@step(u'I should( not)? see the update "([^"]*)"$') +def check_update(step, doesnt, text): + update_css = '.update-contents' + update = world.css_find(update_css) + if doesnt: + assert len(update) == 0 or not text in update.html + else: + assert text in update.html + + +@step(u'I click the "([^"]*)" button$') +def click_button(step, edit_delete): + button_css = '.post-preview .%s-button' % edit_delete + world.css_find(button_css).click() + + +@step(u'I make the date "([^"]*)"$') +def change_date(step, new_date): + date_css = 'input.date' + date = world.css_find(date_css) + for i in range(len(date.value)): + date._element.send_keys(Keys.END, Keys.BACK_SPACE) + date._element.send_keys(new_date) + save_css = '.save-button' + world.css_find(save_css).click() + + +@step(u'I should see the date "([^"]*)"$') +def check_date(step, date): + date_css = '.date-display' + date_html = world.css_find(date_css) + assert date == date_html.html + + +@step(u'I edit the handouts') +def edit_handouts(step): + edit_css = '.course-handouts > .edit-button' + world.css_find(edit_css).click() + + +@step(u'I see the handout "([^"]*)"$') +def check_handout(step, handout): + handout_css = '.handouts-content' + handouts = world.css_find(handout_css) + assert handout in handouts.html