tests: add markup to string field value to check it's escaped properly (#61391)
This commit is contained in:
parent
ce69ea73d2
commit
abae3b1a70
|
@ -137,7 +137,7 @@ WCS_CARDS_DATA = {
|
|||
'text': 'aa',
|
||||
'url': '/backoffice/data/card_model_1/11/',
|
||||
'fields': {
|
||||
'fielda': 'a',
|
||||
'fielda': '<i>a</i>',
|
||||
'fieldb': True,
|
||||
'fieldc': '2020-09-28',
|
||||
'fieldd': {'filename': 'file.pdf', 'url': 'http://127.0.0.1:8999/download?f=42'},
|
||||
|
@ -2449,7 +2449,7 @@ def test_card_cell_render(mock_send, context, app):
|
|||
mock_send.reset_mock()
|
||||
result = cell.render(context)
|
||||
assert '<h2>Card Model 1 - aa</h2>' in result
|
||||
assert PyQuery(result).find('.label:contains("Field A") + .value').text() == 'a'
|
||||
assert PyQuery(result).find('.label:contains("Field A") + .value').text() == '<i>a</i>'
|
||||
assert PyQuery(result).find('.label:contains("Field B") + .value').text() == 'yes'
|
||||
assert PyQuery(result).find('.label:contains("Field C") + .value').text() == 'Sept. 28, 2020'
|
||||
assert PyQuery(result).find('.label:contains("Related") + .value').text() == 'Foo Bar'
|
||||
|
@ -2463,7 +2463,7 @@ def test_card_cell_render(mock_send, context, app):
|
|||
cell.save()
|
||||
assert cell.get_additional_label() == '<b>Foo bar {{ card.fields.fielda }}</b>'
|
||||
result = cell.render(context)
|
||||
assert '<h2><b>Foo bar a</b></h2>' in result
|
||||
assert '<h2><b>Foo bar <i>a</i></b></h2>' in result
|
||||
|
||||
context.pop('title')
|
||||
cell.custom_title = '{{ foobar }}'
|
||||
|
@ -2627,7 +2627,7 @@ def test_card_cell_render_custom_schema_card_field(mock_send, context):
|
|||
context['synchronous'] = True # to get fresh content
|
||||
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('h3').text() == 'a'
|
||||
assert PyQuery(result).find('h3').text() == '<i>a</i>'
|
||||
|
||||
cell.custom_schema['cells'][0] = {
|
||||
'varname': 'fielda',
|
||||
|
@ -2636,7 +2636,7 @@ def test_card_cell_render_custom_schema_card_field(mock_send, context):
|
|||
}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('h4').text() == 'a'
|
||||
assert PyQuery(result).find('h4').text() == '<i>a</i>'
|
||||
|
||||
cell.custom_schema['cells'][0] = {'varname': 'fielda', 'field_content': 'label', 'display_mode': 'title'}
|
||||
cell.save()
|
||||
|
@ -2660,7 +2660,7 @@ def test_card_cell_render_custom_schema_card_field(mock_send, context):
|
|||
cell.custom_schema['cells'][0] = {'varname': 'fielda', 'field_content': 'value', 'display_mode': 'text'}
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('.value').text() == 'a'
|
||||
assert PyQuery(result).find('.value').text() == '<i>a</i>'
|
||||
|
||||
cell.custom_schema['cells'][0] = {
|
||||
'varname': 'fielda',
|
||||
|
@ -2670,7 +2670,7 @@ def test_card_cell_render_custom_schema_card_field(mock_send, context):
|
|||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('.label').text() == 'Field A'
|
||||
assert PyQuery(result).find('.value').text() == 'a'
|
||||
assert PyQuery(result).find('.value').text() == '<i>a</i>'
|
||||
|
||||
cell.custom_schema['cells'][0] = {
|
||||
'varname': 'fieldb',
|
||||
|
@ -2890,7 +2890,7 @@ def test_card_cell_render_custom_schema_custom_entry(mock_send, context, app):
|
|||
cell.custom_schema['cells'][0]['display_mode'] = 'subtitle'
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('h4').text() == 'a - Foo Bar (42)'
|
||||
assert PyQuery(result).find('h4').text() == '<i>a</i> - Foo Bar (42)'
|
||||
|
||||
# test display_mode & filters in template
|
||||
cell.custom_schema = {
|
||||
|
@ -2978,14 +2978,14 @@ def test_card_cell_render_custom_schema_link_entry(mock_send, context, app):
|
|||
context['synchronous'] = True # to get fresh content
|
||||
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('.value a').text() == 'a - Foo Bar'
|
||||
assert PyQuery(result).find('.value a').text() == '<i>a</i> - Foo Bar'
|
||||
assert PyQuery(result).find('.value a').attr['href'] == '/foo/bar/42/'
|
||||
assert PyQuery(result).find('.value a').attr['class'] is None
|
||||
|
||||
cell.custom_schema['cells'][0]['display_mode'] = 'button'
|
||||
cell.save()
|
||||
result = cell.render(context)
|
||||
assert PyQuery(result).find('.value a').text() == 'a - Foo Bar'
|
||||
assert PyQuery(result).find('.value a').text() == '<i>a</i> - Foo Bar'
|
||||
assert PyQuery(result).find('.value a').attr['href'] == '/foo/bar/42/'
|
||||
assert PyQuery(result).find('.value a').attr['class'] == 'pk-button'
|
||||
|
||||
|
@ -3004,7 +3004,7 @@ def test_card_cell_render_custom_schema_link_entry(mock_send, context, app):
|
|||
)
|
||||
cell_resp = app.get(cell_url + '?ctx=' + extra_ctx[0])
|
||||
assert (
|
||||
'<div class="value"><a href="http://testserver/foo/bar/42/" class="pk-button"><b>a</b> - Foo Bar</a></div>'
|
||||
'<div class="value"><a href="http://testserver/foo/bar/42/" class="pk-button"><b><i>a</i></b> - Foo Bar</a></div>'
|
||||
in cell_resp
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue