Commit 5e39ff65 by Jay Zoldak

Merge pull request #1463 from edx/zoldak/fix-tests

Improve problems acceptance tests
parents 031f3074 45f87b30
...@@ -126,11 +126,10 @@ Feature: LMS.Answer problems ...@@ -126,11 +126,10 @@ Feature: LMS.Answer problems
Scenario: I can view and hide the answer if the problem has it: Scenario: I can view and hide the answer if the problem has it:
Given I am viewing a "numerical" that shows the answer "always" Given I am viewing a "numerical" that shows the answer "always"
When I press the button with the label "Show Answer(s)" When I press the button with the label "Show Answer(s)"
Then the button with the label "Hide Answer(s)" does appear Then the Show/Hide button label is "Hide Answer(s)"
And the button with the label "Show Answer(s)" does not appear
And I should see "4.14159" somewhere in the page And I should see "4.14159" somewhere in the page
When I press the button with the label "Hide Answer(s)" When I press the button with the label "Hide Answer(s)"
Then the button with the label "Show Answer(s)" does appear Then the Show/Hide button label is "Show Answer(s)"
And I should not see "4.14159" anywhere on the page And I should not see "4.14159" anywhere on the page
Scenario: I can see my score on a problem when I answer it and after I reset it Scenario: I can see my score on a problem when I answer it and after I reset it
......
...@@ -9,6 +9,7 @@ from lettuce import world, step ...@@ -9,6 +9,7 @@ from lettuce import world, step
from lettuce.django import django_url from lettuce.django import django_url
from common import i_am_registered_for_the_course from common import i_am_registered_for_the_course
from problems_setup import PROBLEM_DICT, answer_problem, problem_has_answer, add_problem_to_course from problems_setup import PROBLEM_DICT, answer_problem, problem_has_answer, add_problem_to_course
from nose.tools import assert_equal
@step(u'I am viewing a "([^"]*)" problem with "([^"]*)" attempt') @step(u'I am viewing a "([^"]*)" problem with "([^"]*)" attempt')
...@@ -138,23 +139,28 @@ def press_the_button_with_label(_step, buttonname): ...@@ -138,23 +139,28 @@ def press_the_button_with_label(_step, buttonname):
@step(u'The "([^"]*)" button does( not)? appear') @step(u'The "([^"]*)" button does( not)? appear')
def action_button_present(_step, buttonname, doesnt_appear): def action_button_present(_step, buttonname, doesnt_appear):
button_css = 'section.action input[value*="%s"]' % buttonname button_css = 'section.action input[value*="%s"]' % buttonname
if doesnt_appear: if bool(doesnt_appear):
assert world.is_css_not_present(button_css) assert world.is_css_not_present(button_css)
else: else:
assert world.is_css_present(button_css) assert world.is_css_present(button_css)
@step(u'the button with the label "([^"]*)" does( not)? appear') @step(u'the Show/Hide button label is "([^"]*)"$')
def button_with_label_present(_step, buttonname, doesnt_appear): def show_hide_label_is(_step, label_name):
if doesnt_appear: # The label text is changed by static/xmodule_js/src/capa/display.js
assert world.browser.is_text_not_present(buttonname, wait_time=5) # so give it some time to change on the page.
else: label_css = 'button.show span.show-label'
assert world.browser.is_text_present(buttonname, wait_time=5) world.wait_for(lambda _: world.css_has_text(label_css, label_name))
@step(u'I should see a score of "([^"]*)"$') @step(u'I should see a score of "([^"]*)"$')
def see_score(_step, score): def see_score(_step, score):
assert world.browser.is_text_present(score) # The problem progress is changed by
# cms/static/xmodule_js/src/capa/display.js
# so give it some time to render on the page.
score_css = 'section.problem-progress'
expected_text = '({})'.format(score)
world.wait_for(lambda _: world.css_has_text(score_css, expected_text))
@step(u'[Mm]y "([^"]*)" answer is( NOT)? marked "([^"]*)"') @step(u'[Mm]y "([^"]*)" answer is( NOT)? marked "([^"]*)"')
...@@ -173,7 +179,7 @@ def assert_answer_mark(_step, problem_type, isnt_marked, correctness): ...@@ -173,7 +179,7 @@ def assert_answer_mark(_step, problem_type, isnt_marked, correctness):
# At least one of the correct selectors should be present # At least one of the correct selectors should be present
for sel in PROBLEM_DICT[problem_type][correctness]: for sel in PROBLEM_DICT[problem_type][correctness]:
if isnt_marked: if bool(isnt_marked):
has_expected = world.is_css_not_present(sel) has_expected = world.is_css_not_present(sel)
else: else:
has_expected = world.is_css_present(sel) has_expected = world.is_css_present(sel)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment