Fix tests after mentions change
This commit is contained in:
parent
f5a3971ef8
commit
f4bbe78bd5
|
@ -101,7 +101,7 @@ def test_linkify_mentions_remote(
|
||||||
post.mentions.add(remote_identity)
|
post.mentions.add(remote_identity)
|
||||||
assert (
|
assert (
|
||||||
post.safe_content_remote()
|
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)
|
# Test a full username (local)
|
||||||
post = Post.objects.create(
|
post = Post.objects.create(
|
||||||
|
@ -112,7 +112,7 @@ def test_linkify_mentions_remote(
|
||||||
post.mentions.add(identity)
|
post.mentions.add(identity)
|
||||||
assert (
|
assert (
|
||||||
post.safe_content_remote()
|
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
|
# Test that they don't get touched without a mention
|
||||||
post = Post.objects.create(
|
post = Post.objects.create(
|
||||||
|
@ -131,7 +131,7 @@ def test_linkify_mentions_remote(
|
||||||
post.mentions.add(remote_identity)
|
post.mentions.add(remote_identity)
|
||||||
assert (
|
assert (
|
||||||
post.safe_content_remote()
|
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)
|
# Test trailing dot (remote)
|
||||||
|
@ -143,7 +143,7 @@ def test_linkify_mentions_remote(
|
||||||
post.mentions.add(remote_identity)
|
post.mentions.add(remote_identity)
|
||||||
assert (
|
assert (
|
||||||
post.safe_content_remote()
|
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
|
# 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])
|
post.mentions.set([remote_identity, remote_identity2])
|
||||||
assert post.safe_content_remote() == (
|
assert post.safe_content_remote() == (
|
||||||
'<p>Hey <a href="https://remote.test/@test/" class="mention">@TeSt</a> '
|
'<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 <a href="https://remote2.test/@test/" class="mention">@test@remote2.test</a></p>'
|
'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>"
|
post.content = "<p>Hey @TeSt, @Test@remote.test and @test</p>"
|
||||||
assert post.safe_content_remote() == (
|
assert post.safe_content_remote() == (
|
||||||
'<p>Hey <a href="https://remote2.test/@test/" class="mention">@TeSt</a>, '
|
'<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>, '
|
||||||
'<a href="https://remote.test/@test/" class="mention">@Test@remote.test</a> '
|
'<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 <a href="https://remote2.test/@test/" class="mention">@test</a></p>'
|
'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)
|
post.mentions.add(remote_identity)
|
||||||
assert (
|
assert (
|
||||||
post.safe_content_local()
|
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)
|
# Test a full username (local)
|
||||||
post = Post.objects.create(
|
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(identity)
|
||||||
post.mentions.add(identity2)
|
post.mentions.add(identity2)
|
||||||
assert post.safe_content_local() == (
|
assert post.safe_content_local() == (
|
||||||
'<p><a href="/@test@example.com/" class="mention">@test</a>, welcome!'
|
'<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!'
|
||||||
' <a href="/@test@example2.com/" class="mention">@test@example2.com</a>'
|
' <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>'
|
||||||
' <a href="/@test@example.com/" class="mention">@test</a></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>'
|
||||||
)
|
)
|
||||||
# Test a full username (remote) with no <p>
|
# Test a full username (remote) with no <p>
|
||||||
post = Post.objects.create(
|
post = Post.objects.create(
|
||||||
|
@ -204,7 +204,7 @@ def test_linkify_mentions_local(config_system, identity, identity2, remote_ident
|
||||||
post.mentions.add(remote_identity)
|
post.mentions.add(remote_identity)
|
||||||
assert (
|
assert (
|
||||||
post.safe_content_local()
|
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
|
# Test that they don't get touched without a mention
|
||||||
post = Post.objects.create(
|
post = Post.objects.create(
|
||||||
|
@ -217,7 +217,6 @@ def test_linkify_mentions_local(config_system, identity, identity2, remote_ident
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_post_transitions(identity, stator):
|
def test_post_transitions(identity, stator):
|
||||||
|
|
||||||
# Create post
|
# Create post
|
||||||
post = Post.objects.create(
|
post = Post.objects.create(
|
||||||
content="<p>Hello!</p>",
|
content="<p>Hello!</p>",
|
||||||
|
|
|
@ -71,7 +71,7 @@ def test_mention_format(api_client, identity, remote_identity):
|
||||||
).json()
|
).json()
|
||||||
assert (
|
assert (
|
||||||
response["content"]
|
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"
|
assert response["visibility"] == "unlisted"
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ def test_mention_format(api_client, identity, remote_identity):
|
||||||
).json()
|
).json()
|
||||||
assert (
|
assert (
|
||||||
response["text"]
|
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>'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,8 @@ def test_parser(identity):
|
||||||
find_emojis=True,
|
find_emojis=True,
|
||||||
)
|
)
|
||||||
assert (
|
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.plain_text == "@test@example.com"
|
||||||
assert parser.mentions == {"test@example.com"}
|
assert parser.mentions == {"test@example.com"}
|
||||||
|
@ -93,7 +94,8 @@ def test_parser(identity):
|
||||||
find_emojis=True,
|
find_emojis=True,
|
||||||
)
|
)
|
||||||
assert (
|
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.plain_text == "@TeSt@ExamPle.com"
|
||||||
assert parser.mentions == {"test@example.com"}
|
assert parser.mentions == {"test@example.com"}
|
||||||
|
@ -135,6 +137,6 @@ def test_parser_same_name_mentions(remote_identity, remote_identity2):
|
||||||
)
|
)
|
||||||
assert (
|
assert (
|
||||||
parser.html
|
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"
|
assert parser.plain_text == "@test @test"
|
||||||
|
|
Loading…
Reference in New Issue