From 0e237a85e60d1f4d448610bdf60a54daf203e4c9 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Thu, 19 Dec 2013 16:23:03 -0500 Subject: [PATCH] Add acceptance test of the Graphical Slider Tool [LMS-1641] --- .../courseware/features/gst.feature | 10 +++ lms/djangoapps/courseware/features/gst.py | 76 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 lms/djangoapps/courseware/features/gst.feature create mode 100644 lms/djangoapps/courseware/features/gst.py diff --git a/lms/djangoapps/courseware/features/gst.feature b/lms/djangoapps/courseware/features/gst.feature new file mode 100644 index 0000000000..f397c54bbc --- /dev/null +++ b/lms/djangoapps/courseware/features/gst.feature @@ -0,0 +1,10 @@ +@shard_2 +Feature: LMS.Graphical Slider Tool Module + As a student, I want to view a Graphical Slider Tool Component + + Scenario: The slider changes values on the page + Given that I have a course with a Graphical Slider Tool + When I view the Graphical Slider Tool + Then the displayed value should be 0 + And I move the slider to the right + Then the displayed value should be 10 \ No newline at end of file diff --git a/lms/djangoapps/courseware/features/gst.py b/lms/djangoapps/courseware/features/gst.py new file mode 100644 index 0000000000..a8693ead30 --- /dev/null +++ b/lms/djangoapps/courseware/features/gst.py @@ -0,0 +1,76 @@ + +from lettuce import world, steps +from nose.tools import assert_in, assert_equals, assert_true + +from common import i_am_registered_for_the_course, visit_scenario_item +from problems_setup import add_problem_to_course, answer_problem + + +DEFAULT_DATA = """\ + +

Test of the graphical slider tool

+
+ +
+
+ +
+
+ + + + + + a + + +""" + +@steps +class GraphicalSliderToolSteps(object): + COURSE_NUM = 'test_course' + + def setup_gst(self, step): + r'that I have a course with a Graphical Slider Tool$' + + i_am_registered_for_the_course(step, self.COURSE_NUM) + + world.scenario_dict['GST'] = world.ItemFactory( + parent_location=world.scenario_dict['SECTION'].location, + category='graphical_slider_tool', + display_name="Test GST", + data=DEFAULT_DATA + ) + + def view_gst(self, step): + r'I view the Graphical Slider Tool$' + visit_scenario_item('GST') + world.wait_for_js_variable_truthy('$(".xblock-student_view[data-type=GraphicalSliderTool]").data("initialized")') + world.wait_for_ajax_complete() + + def check_value(self, step, value): + r'the displayed value should be (?P\d+)$' + + assert_equals(world.css_text('.gst-value'), value) + + def move_slider(self, step): + r'I move the slider to the right$' + + handle_selector = '.gst-input .ui-slider-handle' + world.wait_for_visible(handle_selector) + world.wait_for_visible('.gst-value #value-display') + + def try_move(): + handle = world.css_find(handle_selector).first + slider = world.css_find('.gst-input .ui-slider').first + (handle.action_chains + .click_and_hold(handle._element) + .move_by_offset( + int(handle._element.location['x'] + 400), + 0 + ).release().perform()) + + world.retry_on_exception(try_move) + + +GraphicalSliderToolSteps() \ No newline at end of file