From f997d3e0bbd6dd9bbd90c75a1df8903323609512 Mon Sep 17 00:00:00 2001 From: Bajszi Date: Mon, 11 Sep 2023 21:27:15 +0200 Subject: [PATCH 1/3] Trimmed name last resort --- app/Users/Models/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Users/Models/User.php b/app/Users/Models/User.php index 92701ac1312..cbfdbef2dd6 100644 --- a/app/Users/Models/User.php +++ b/app/Users/Models/User.php @@ -345,7 +345,7 @@ public function getShortName(int $chars = 8): string return $splitName[0]; } - return ''; + return mb_substr($this->name, 0, $chars) . '..'; } /** From f4deb13301feb6087cb56f22ef52230905821952 Mon Sep 17 00:00:00 2001 From: Bajszi Date: Tue, 12 Sep 2023 17:03:57 +0200 Subject: [PATCH 2/3] Truncate with three dots --- app/Users/Models/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Users/Models/User.php b/app/Users/Models/User.php index cbfdbef2dd6..3efbeec70a8 100644 --- a/app/Users/Models/User.php +++ b/app/Users/Models/User.php @@ -345,7 +345,7 @@ public function getShortName(int $chars = 8): string return $splitName[0]; } - return mb_substr($this->name, 0, $chars) . '..'; + return mb_substr($this->name, 0, $chars-3) . '…'; } /** From 83028f3fbea8ead701b604d161100923545fcb53 Mon Sep 17 00:00:00 2001 From: Bajszi Date: Tue, 12 Sep 2023 21:00:00 +0200 Subject: [PATCH 3/3] Test comment creator name truncation --- tests/Entity/CommentTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/Entity/CommentTest.php b/tests/Entity/CommentTest.php index 0a71bb6eff4..d2ed3513679 100644 --- a/tests/Entity/CommentTest.php +++ b/tests/Entity/CommentTest.php @@ -152,4 +152,20 @@ public function test_comments_are_visible_in_the_page_editor() $respHtml = $this->withHtml($this->get($page->getUrl('/edit'))); $respHtml->assertElementContains('.comment-box .content', 'My great comment to see in the editor'); } + + public function test_comment_creator_name_truncated() + { + $longNamedUser = $this->users->admin(); + $longNamedUser->name = 'Wolfeschlegelsteinhausenbergerdorff'; + $longNamedUser->save(); + $this->actingAs($longNamedUser); + + $page = $this->entities->page(); + + $comment = Comment::factory()->make(); + $this->postJson("/comment/$page->id", $comment->getAttributes()); + + $pageResp = $this->get($page->getUrl()); + $pageResp->assertSee('Wolfeschlegel…'); + } }