forked from jointakahe/takahe
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5a3971
commit f4bbe78
Showing
3 changed files
with
21 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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">@[email protected]</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>[email protected]</span></a></span></p>' | ||
) | ||
|
||
post.content = "<p>Hey @TeSt, @[email protected] 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">@[email protected]</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>[email protected]</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="/@[email protected]/" class="mention">@test</a></p>' | ||
== '<p>Hello <span class="h-card"><a href="/@[email protected]/" 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="/@[email protected]/" class="mention">@test</a>, welcome!' | ||
' <a href="/@[email protected]/" class="mention">@[email protected]</a>' | ||
' <a href="/@[email protected]/" class="mention">@test</a></p>' | ||
'<p><span class="h-card"><a href="/@[email protected]/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span>, welcome!' | ||
' <span class="h-card"><a href="/@[email protected]/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>[email protected]</span></a></span>' | ||
' <span class="h-card"><a href="/@[email protected]/" 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="/@[email protected]/" class="mention">@test</a> hello!' | ||
== '<span class="h-card"><a href="/@[email protected]/" 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>", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,8 @@ def test_parser(identity): | |
find_emojis=True, | ||
) | ||
assert ( | ||
parser.html == '<p><a href="/@[email protected]/" class="mention">@test</a></p>' | ||
parser.html | ||
== '<p><span class="h-card"><a href="/@[email protected]/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span></p>' | ||
) | ||
assert parser.plain_text == "@[email protected]" | ||
assert parser.mentions == {"[email protected]"} | ||
|
@@ -93,7 +94,8 @@ def test_parser(identity): | |
find_emojis=True, | ||
) | ||
assert ( | ||
parser.html == '<p><a href="/@[email protected]/" class="mention">@TeSt</a></p>' | ||
parser.html | ||
== '<p><span class="h-card"><a href="/@[email protected]/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>TeSt</span></a></span></p>' | ||
) | ||
assert parser.plain_text == "@[email protected]" | ||
assert parser.mentions == {"[email protected]"} | ||
|
@@ -135,6 +137,6 @@ def test_parser_same_name_mentions(remote_identity, remote_identity2): | |
) | ||
assert ( | ||
parser.html | ||
== '<a href="/@[email protected]/" class="mention">@test</a> <a href="/@[email protected]/" class="mention">@test</a>' | ||
== '<span class="h-card"><a href="/@[email protected]/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span> <span class="h-card"><a href="/@[email protected]/" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>test</span></a></span>' | ||
) | ||
assert parser.plain_text == "@test @test" |