File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ class="comment-box">
24
24
@else
25
25
{{ trans (' common.deleted_user' ) } }
26
26
@endif
27
- <span title =" {{ $comment -> created_at } }" >  ; {{ trans (' entities.comment_created' , [' createDiff' => $comment -> created ]) } } </span >
27
+ <span title =" {{ $comment -> created_at } }" >  ; {{ trans (' entities.comment_created' , [' createDiff' => $comment -> created_at -> diffForHumans () ]) } } </span >
28
28
@if ($comment -> isUpdated () )
29
29
<span class =" mx-xs" >&bull ; </span >
30
30
<span title =" {{ trans (' entities.comment_updated' , [' updateDiff' => $comment -> updated_at , ' username' => $comment -> updatedBy -> name ?? trans (' common.deleted_user' )]) } }" >
Original file line number Diff line number Diff line change @@ -214,4 +214,21 @@ public function test_comment_editor_js_loaded_with_create_or_edit_permissions()
214
214
$ resp ->assertSee ('window.editor_translations ' , false );
215
215
$ resp ->assertSee ('component="entity-selector" ' , false );
216
216
}
217
+
218
+ public function test_comment_displays_relative_times ()
219
+ {
220
+ $ page = $ this ->entities ->page ();
221
+ $ comment = Comment::factory ()->create (['entity_id ' => $ page ->id , 'entity_type ' => $ page ->getMorphClass ()]);
222
+ $ comment ->created_at = now ()->subWeek ();
223
+ $ comment ->updated_at = now ()->subDay ();
224
+ $ comment ->save ();
225
+
226
+ $ pageResp = $ this ->asAdmin ()->get ($ page ->getUrl ());
227
+ $ html = $ this ->withHtml ($ pageResp );
228
+
229
+ // Create date shows relative time as text to user
230
+ $ html ->assertElementContains ('.comment-box ' , 'commented 1 week ago ' );
231
+ // Updated indicator has full time as title
232
+ $ html ->assertElementContains ('.comment-box span[title^="Updated ' . $ comment ->updated_at ->format ('Y-m-d ' ) . '"] ' , 'Updated ' );
233
+ }
217
234
}
You can’t perform that action at this time.
0 commit comments