Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc improvements to make lettuce testing a bit saner #491

Merged
merged 1 commit into from
Jul 25, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cms/djangoapps/contentstore/features/advanced-settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#pylint: disable=W0621

from lettuce import world, step
from nose.tools import assert_false, assert_equal, assert_regexp_matches, assert_true
from nose.tools import assert_false, assert_equal, assert_regexp_matches
from common import type_in_codemirror, press_the_notification_button

KEY_CSS = '.key input.policy-key'
Expand Down Expand Up @@ -90,18 +90,18 @@ def the_policy_key_value_is_changed(step):

############# HELPERS ###############
def assert_policy_entries(expected_keys, expected_values):
for counter in range(len(expected_keys)):
index = get_index_of(expected_keys[counter])
assert_false(index == -1, "Could not find key: " + expected_keys[counter])
assert_equal(expected_values[counter], world.css_find(VALUE_CSS)[index].value, "value is incorrect")
for key, value in zip(expected_keys, expected_values):
index = get_index_of(key)
assert_false(index == -1, "Could not find key: {key}".format(key=key))
assert_equal(value, world.css_find(VALUE_CSS)[index].value, "value is incorrect")


def get_index_of(expected_key):
for counter in range(len(world.css_find(KEY_CSS))):
# Sometimes get stale reference if I hold on to the array of elements
key = world.css_value(KEY_CSS, index=counter)
for i, element in enumerate(world.css_find(KEY_CSS)):
# Sometimes get stale reference if I hold on to the array of elements
key = world.css_value(KEY_CSS, index=i)
if key == expected_key:
return counter
return i

return -1

Expand Down
11 changes: 6 additions & 5 deletions cms/static/js/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ $(document).ready(function() {
$('.nav-dd .nav-item .title').removeClass('is-selected');
});

$('.nav-dd .nav-item .title').click(function(e) {
$('.nav-dd .nav-item').click(function(e) {

$subnav = $(this).parent().find('.wrapper-nav-sub');
$title = $(this).parent().find('.title');
e.preventDefault();
e.stopPropagation();
$subnav = $(this).find('.wrapper-nav-sub');
$title = $(this).find('.title');

if ($subnav.hasClass('is-shown')) {
$subnav.removeClass('is-shown');
Expand All @@ -75,6 +73,9 @@ $(document).ready(function() {
$('.nav-dd .nav-item .wrapper-nav-sub').removeClass('is-shown');
$title.addClass('is-selected');
$subnav.addClass('is-shown');
// if propogation is not stopped, the event will bubble up to the
// body element, which will close the dropdown.
e.stopPropagation();
}
});

Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/terrain/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def initial_setup(server):
# If we were unable to get a valid session within the limit of attempts,
# then we cannot run the tests.
if not success:
raise IOError("Could not acquire valid ChromeDriver browser session.")
raise IOError("Could not acquire valid {driver} browser session.".format(driver=browser_driver))

# Set the browser size to 1280x1024
world.browser.driver.set_window_size(1280, 1024)
Expand Down
9 changes: 3 additions & 6 deletions common/djangoapps/terrain/ui_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,22 +216,19 @@ def save_the_html(path='/tmp'):
@world.absorb
def click_course_content():
course_content_css = 'li.nav-course-courseware'
if world.browser.is_element_present_by_css(course_content_css):
world.css_click(course_content_css)
world.css_click(course_content_css)


@world.absorb
def click_course_settings():
course_settings_css = 'li.nav-course-settings'
if world.browser.is_element_present_by_css(course_settings_css):
world.css_click(course_settings_css)
world.css_click(course_settings_css)


@world.absorb
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.css_click(tools_css)


@world.absorb
Expand Down
4 changes: 2 additions & 2 deletions requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ nosexcover==1.0.7
pep8==1.4.5
pylint==0.28
rednose==0.3
selenium==2.31.0
splinter==0.5.0
selenium==2.33.0
splinter==0.5.4
django_nose==1.1
django-jasmine==0.3.2
django_debug_toolbar
Expand Down