Merge pull request #12206 from CredoReference/impossible-to-click-check-without-answer
Make it impossible to click "final check" without selecting a choice
This commit is contained in:
@@ -6,6 +6,7 @@ See also lettuce tests in lms/djangoapps/courseware/features/problems.feature
|
||||
import random
|
||||
import textwrap
|
||||
|
||||
from nose import SkipTest
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from nose.plugins.attrib import attr
|
||||
from selenium.webdriver import ActionChains
|
||||
@@ -135,6 +136,8 @@ class ProblemTypeTestMixin(object):
|
||||
"""
|
||||
Test cases shared amongst problem types.
|
||||
"""
|
||||
can_submit_blank = False
|
||||
|
||||
@attr('shard_7')
|
||||
def test_answer_correctly(self):
|
||||
"""
|
||||
@@ -200,15 +203,34 @@ class ProblemTypeTestMixin(object):
|
||||
Then my "<ProblemType>" answer is marked "incorrect"
|
||||
And The "<ProblemType>" problem displays a "blank" answer
|
||||
"""
|
||||
if not self.can_submit_blank:
|
||||
raise SkipTest("Test incompatible with the current problem type")
|
||||
|
||||
self.problem_page.wait_for(
|
||||
lambda: self.problem_page.problem_name == self.problem_name,
|
||||
"Make sure the correct problem is on the page"
|
||||
)
|
||||
|
||||
# Leave the problem unchanged and click check.
|
||||
self.assertNotIn('is-disabled', self.problem_page.q(css='div.problem button.check').attrs('class')[0])
|
||||
self.problem_page.click_check()
|
||||
self.wait_for_status('incorrect')
|
||||
|
||||
@attr('shard_7')
|
||||
def test_cant_submit_blank_answer(self):
|
||||
"""
|
||||
Scenario: I can't submit a blank answer
|
||||
When I try to submit blank answer
|
||||
Then I can't check a problem
|
||||
"""
|
||||
if self.can_submit_blank:
|
||||
raise SkipTest("Test incompatible with the current problem type")
|
||||
|
||||
self.problem_page.wait_for(
|
||||
lambda: self.problem_page.problem_name == self.problem_name,
|
||||
"Make sure the correct problem is on the page"
|
||||
)
|
||||
self.assertIn('is-disabled', self.problem_page.q(css='div.problem button.check').attrs('class')[0])
|
||||
|
||||
@attr('a11y')
|
||||
def test_problem_type_a11y(self):
|
||||
"""
|
||||
@@ -236,6 +258,8 @@ class AnnotationProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
|
||||
|
||||
factory = AnnotationResponseXMLFactory()
|
||||
|
||||
can_submit_blank = True
|
||||
|
||||
factory_kwargs = {
|
||||
'title': 'Annotation Problem',
|
||||
'text': 'The text being annotated',
|
||||
@@ -686,6 +710,13 @@ class CodeProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
|
||||
"""
|
||||
pass
|
||||
|
||||
def test_cant_submit_blank_answer(self):
|
||||
"""
|
||||
Overridden for script test because the testing grader always responds
|
||||
with "correct"
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class ChoiceTextProbelmTypeTestBase(ProblemTypeTestBase):
|
||||
"""
|
||||
@@ -801,6 +832,8 @@ class ImageProblemTypeTest(ProblemTypeTestBase, ProblemTypeTestMixin):
|
||||
|
||||
factory = ImageResponseXMLFactory()
|
||||
|
||||
can_submit_blank = True
|
||||
|
||||
factory_kwargs = {
|
||||
'src': '/static/images/placeholder-image.png',
|
||||
'rectangle': '(0,0)-(50,50)',
|
||||
|
||||
Reference in New Issue
Block a user