oncall-engine/engine/common/tests/test_markup.py
Vadim Stepanov e042949cf1
Fix cuddled list Markdown issue (#2488)
# What this PR does

Fixes an issue when alert group list page fails to load if any alert
group on the page has `- - ` substring in its message.

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-11 09:14:52 +00:00

56 lines
1.5 KiB
Python

from common.utils import clean_markup, convert_md_to_html
def test_clean_code_blocks_name():
original = "Tada! ```Tadada!``` `Tadadada!`"
expected = "Tada! Tadada! Tadadada!"
assert clean_markup(original) == expected
def test_clean_visual_basics():
original = "~Stroke~ *Bold* _Italic_ ~Word ~"
expected = "Stroke Bold Italic ~Word ~"
assert clean_markup(original) == expected
def test_clean_block_quotes():
original = (
"This is unquoted text\n"
"> This is quoted text\n"
"> This is still quoted text\n"
"This is unquoted text again"
)
expected = (
"This is unquoted text\n"
"> This is quoted text\n"
"> This is still quoted text\n"
"This is unquoted text again"
)
assert clean_markup(original) == expected
def test_clean_link():
original = "<http://www.foo.com>"
expected = "http://www.foo.com"
assert clean_markup(original) == expected
def test_clean_mailto():
# email
original = "<mailto:bob@example.com>"
expected = "bob@example.com"
assert clean_markup(original) == expected
def test_convert_md_to_html_basic():
md = "This is a test, **This is bold**, *This is italic*"
expected = "<p>This is a test, <strong>This is bold</strong>, <em>This is italic</em></p>"
assert convert_md_to_html(md) == expected
def test_convert_md_to_html_bad_cuddled_list():
md = "- - "
expected = "<p>- - </p>"
assert convert_md_to_html(md) == expected