create(); $post = Post::factory()->create(); $this->actingAs($user); $html = '

Hello bold and italic world

'; Livewire::test(Comments::class, ['model' => $post]) ->set('newComment', $html) ->call('addComment'); $comment = Comment::first(); expect($comment->body)->toContain('bold'); expect($comment->body)->toContain('italic'); }); it('pre-fills editBody with existing comment HTML when starting edit', function () { $user = User::factory()->create(); $post = Post::factory()->create(); $originalHtml = '

Hello world

'; $comment = Comment::factory()->create([ 'commentable_id' => $post->id, 'commentable_type' => $post->getMorphClass(), 'commenter_id' => $user->getKey(), 'commenter_type' => $user->getMorphClass(), 'body' => $originalHtml, ]); $this->actingAs($user); Livewire::test(CommentItem::class, ['comment' => $comment]) ->call('startEdit') ->assertSet('editBody', $originalHtml); }); it('saves edited HTML content through edit form', function () { $user = User::factory()->create(); $post = Post::factory()->create(); $comment = Comment::factory()->create([ 'commentable_id' => $post->id, 'commentable_type' => $post->getMorphClass(), 'commenter_id' => $user->getKey(), 'commenter_type' => $user->getMorphClass(), 'body' => '

Original

', ]); $this->actingAs($user); $updatedHtml = '

Updated with bold and a link

'; Livewire::test(CommentItem::class, ['comment' => $comment]) ->call('startEdit') ->set('editBody', $updatedHtml) ->call('saveEdit'); $comment->refresh(); expect($comment->body)->toContain('bold'); expect($comment->body)->toContain('a link'); }); it('creates reply with rich HTML content', function () { $user = User::factory()->create(); $post = Post::factory()->create(); $comment = Comment::factory()->create([ 'commentable_id' => $post->id, 'commentable_type' => $post->getMorphClass(), 'commenter_id' => $user->getKey(), 'commenter_type' => $user->getMorphClass(), ]); $this->actingAs($user); $replyHtml = '

Reply with emphasis and inline code

'; Livewire::test(CommentItem::class, ['comment' => $comment]) ->call('startReply') ->set('replyBody', $replyHtml) ->call('addReply'); $reply = Comment::where('parent_id', $comment->id)->first(); expect($reply)->not->toBeNull(); expect($reply->body)->toContain('emphasis'); expect($reply->body)->toContain('inline code'); }); it('renders comment body with fi-prose class', function () { $user = User::factory()->create(); $post = Post::factory()->create(); $comment = Comment::factory()->create([ 'commentable_id' => $post->id, 'commentable_type' => $post->getMorphClass(), 'commenter_id' => $user->getKey(), 'commenter_type' => $user->getMorphClass(), 'body' => '

Styled comment

', ]); $this->actingAs($user); Livewire::test(CommentItem::class, ['comment' => $comment]) ->assertSeeHtml('fi-prose'); }); it('returns editor toolbar configuration as nested array', function () { $toolbar = CommentsConfig::getEditorToolbar(); expect($toolbar)->toBeArray(); expect($toolbar)->not->toBeEmpty(); expect($toolbar[0])->toBeArray(); expect($toolbar[0])->toContain('bold'); expect($toolbar[0])->toContain('italic'); }); it('uses custom toolbar config when overridden', function () { config(['comments.editor.toolbar' => [ ['bold', 'italic'], ]]); $toolbar = CommentsConfig::getEditorToolbar(); expect($toolbar)->toHaveCount(1); expect($toolbar[0])->toBe(['bold', 'italic']); });