tests: add markup to string field value to check it's escaped properly (#61391)
gitea-wip/combo/pipeline/head There was a failure building this commit Details
gitea/combo/pipeline/head Build queued... Details

This commit is contained in:
Frédéric Péters 2022-03-14 20:50:52 +01:00 committed by Lauréline Guérin
parent ce69ea73d2
commit abae3b1a70
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
1 changed files with 11 additions and 11 deletions

View File

@ -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() == '&lt;b&gt;Foo bar {{ card.fields.fielda }}&lt;/b&gt;'
result = cell.render(context)
assert '<h2>&lt;b&gt;Foo bar a&lt;/b&gt;</h2>' in result
assert '<h2>&lt;b&gt;Foo bar &lt;i&gt;a&lt;/i&gt;&lt;/b&gt;</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">&lt;b&gt;a&lt;/b&gt; - Foo Bar</a></div>'
'<div class="value"><a href="http://testserver/foo/bar/42/" class="pk-button">&lt;b&gt;&lt;i&gt;a&lt;/i&gt;&lt;/b&gt; - Foo Bar</a></div>'
in cell_resp
)