forms: test is_hidden attribute on comment fields (#38685)

This commit is contained in:
Nicolas Roche 2019-12-23 13:57:47 +01:00 committed by Frédéric Péters
parent 283a37fb96
commit d5ff023e4f
1 changed files with 25 additions and 0 deletions

View File

@ -7127,3 +7127,28 @@ def test_choice_button_ignore_form_errors(pub):
resp = resp.form.submit('button_x2').follow()
assert '<span class="status">Status2' in resp.text
def test_form_comment_is_hidden_attribute(pub):
formdef = create_formdef()
formdef.fields = [
fields.PageField(id='0', label='1st page', type='page'),
fields.StringField(id='1', label='string 1', varname='choice1'),
fields.PageField(id='2', label='2nd page', type='page'),
fields.StringField(
id='3', label='string 2', varname='choice2',
condition={'type': 'django', 'value': 'form_var_choice1 == "1"'}),
fields.CommentField(
id='5', label='this should not be displayed', type='comment',
condition={'type': 'django', 'value': 'False and form_var_choice2 == "???"'}),
]
formdef.store()
resp = get_app(pub).get('/test/')
formdef.data_class().wipe()
resp.forms[0]['f1'] = '1'
resp = resp.forms[0].submit('submit')
comment = re.compile('.*comment-field.*"')
assert 'style="display: none"' in comment.search(resp.forms[0].text).group(0)
resp = resp.forms[0].submit('previous')
resp.forms[0]['f1'] = '2'
resp = resp.forms[0].submit('submit')
assert 'style="display: none"' in comment.search(resp.forms[0].text).group(0)