Fix tests after mentions change

pull/580/head
Andrew Godwin 2023-05-13 11:19:23 -06:00
rodzic f5a3971ef8
commit f4bbe78bd5
3 zmienionych plików z 21 dodań i 20 usunięć

Wyświetl plik

@ -101,7 +101,7 @@ def test_linkify_mentions_remote(
post.mentions.add(remote_identity)
assert (
post.safe_content_remote()
== '<p>Hello <a href="https://remote.test/@test/" class="mention">@test</a></p>'
== '<p>Hello <span class="h-card"><a href="https://remote.test/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span></p>'
)
# Test a full username (local)
post = Post.objects.create(
@ -112,7 +112,7 @@ def test_linkify_mentions_remote(
post.mentions.add(identity)
assert (
post.safe_content_remote()
== '<p><a href="https://example.com/@test/" class="mention">@test</a>, welcome!</p>'
== '<p><span class="h-card"><a href="https://example.com/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span>, welcome!</p>'
)
# Test that they don't get touched without a mention
post = Post.objects.create(
@ -131,7 +131,7 @@ def test_linkify_mentions_remote(
post.mentions.add(remote_identity)
assert (
post.safe_content_remote()
== '<p>Hey <a href="https://remote.test/@test/" class="mention">@TeSt</a></p>'
== '<p>Hey <span class="h-card"><a href="https://remote.test/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>TeSt</span></a></span></p>'
)
# Test trailing dot (remote)
@ -143,7 +143,7 @@ def test_linkify_mentions_remote(
post.mentions.add(remote_identity)
assert (
post.safe_content_remote()
== '<p>Hey <a href="https://remote.test/@test/" class="mention">@test</a>.</p>'
== '<p>Hey <span class="h-card"><a href="https://remote.test/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span>.</p>'
)
# Test that collapsing only applies to the first unique, short username
@ -154,15 +154,15 @@ def test_linkify_mentions_remote(
)
post.mentions.set([remote_identity, remote_identity2])
assert post.safe_content_remote() == (
'<p>Hey <a href="https://remote.test/@test/" class="mention">@TeSt</a> '
'and <a href="https://remote2.test/@test/" class="mention">@test@remote2.test</a></p>'
'<p>Hey <span class="h-card"><a href="https://remote.test/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>TeSt</span></a></span> '
'and <span class="h-card"><a href="https://remote2.test/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test@remote2.test</span></a></span></p>'
)
post.content = "<p>Hey @TeSt, @Test@remote.test and @test</p>"
assert post.safe_content_remote() == (
'<p>Hey <a href="https://remote2.test/@test/" class="mention">@TeSt</a>, '
'<a href="https://remote.test/@test/" class="mention">@Test@remote.test</a> '
'and <a href="https://remote2.test/@test/" class="mention">@test</a></p>'
'<p>Hey <span class="h-card"><a href="https://remote2.test/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>TeSt</span></a></span>, '
'<span class="h-card"><a href="https://remote.test/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>Test@remote.test</span></a></span> '
'and <span class="h-card"><a href="https://remote2.test/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span></p>'
)
@ -180,7 +180,7 @@ def test_linkify_mentions_local(config_system, identity, identity2, remote_ident
post.mentions.add(remote_identity)
assert (
post.safe_content_local()
== '<p>Hello <a href="/@test@remote.test/" class="mention">@test</a></p>'
== '<p>Hello <span class="h-card"><a href="/@test@remote.test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span></p>'
)
# Test a full username (local)
post = Post.objects.create(
@ -191,9 +191,9 @@ def test_linkify_mentions_local(config_system, identity, identity2, remote_ident
post.mentions.add(identity)
post.mentions.add(identity2)
assert post.safe_content_local() == (
'<p><a href="/@test@example.com/" class="mention">@test</a>, welcome!'
' <a href="/@test@example2.com/" class="mention">@test@example2.com</a>'
' <a href="/@test@example.com/" class="mention">@test</a></p>'
'<p><span class="h-card"><a href="/@test@example.com/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span>, welcome!'
' <span class="h-card"><a href="/@test@example2.com/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test@example2.com</span></a></span>'
' <span class="h-card"><a href="/@test@example.com/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span></p>'
)
# Test a full username (remote) with no <p>
post = Post.objects.create(
@ -204,7 +204,7 @@ def test_linkify_mentions_local(config_system, identity, identity2, remote_ident
post.mentions.add(remote_identity)
assert (
post.safe_content_local()
== '<a href="/@test@remote.test/" class="mention">@test</a> hello!'
== '<span class="h-card"><a href="/@test@remote.test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span> hello!'
)
# Test that they don't get touched without a mention
post = Post.objects.create(
@ -217,7 +217,6 @@ def test_linkify_mentions_local(config_system, identity, identity2, remote_ident
@pytest.mark.django_db
def test_post_transitions(identity, stator):
# Create post
post = Post.objects.create(
content="<p>Hello!</p>",

Wyświetl plik

@ -71,7 +71,7 @@ def test_mention_format(api_client, identity, remote_identity):
).json()
assert (
response["content"]
== '<p>Hello, <a href="https://example.com/@test/" class="mention">@test</a>!</p>'
== '<p>Hello, <span class="h-card"><a href="https://example.com/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span>!</p>'
)
assert response["visibility"] == "unlisted"
@ -88,7 +88,7 @@ def test_mention_format(api_client, identity, remote_identity):
).json()
assert (
response["text"]
== '<p>Hey <a href="https://example.com/@test/" class="mention">@test</a></p>'
== '<p>Hey <span class="h-card"><a href="https://example.com/@test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span></p>'
)

Wyświetl plik

@ -80,7 +80,8 @@ def test_parser(identity):
find_emojis=True,
)
assert (
parser.html == '<p><a href="/@test@example.com/" class="mention">@test</a></p>'
parser.html
== '<p><span class="h-card"><a href="/@test@example.com/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span></p>'
)
assert parser.plain_text == "@test@example.com"
assert parser.mentions == {"test@example.com"}
@ -93,7 +94,8 @@ def test_parser(identity):
find_emojis=True,
)
assert (
parser.html == '<p><a href="/@test@example.com/" class="mention">@TeSt</a></p>'
parser.html
== '<p><span class="h-card"><a href="/@test@example.com/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>TeSt</span></a></span></p>'
)
assert parser.plain_text == "@TeSt@ExamPle.com"
assert parser.mentions == {"test@example.com"}
@ -135,6 +137,6 @@ def test_parser_same_name_mentions(remote_identity, remote_identity2):
)
assert (
parser.html
== '<a href="/@test@remote.test/" class="mention">@test</a> <a href="/@test@remote2.test/" class="mention">@test</a>'
== '<span class="h-card"><a href="/@test@remote.test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span> <span class="h-card"><a href="/@test@remote2.test/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span>'
)
assert parser.plain_text == "@test @test"