fix: update tests for RichEditor form data paths and service providers
Update all tests to use new form state paths (commentData.body, editData.body, replyData.body) instead of removed public properties. Remove searchUsers() tests (method replaced by MentionProvider). Add BladeUI Icons service providers to TestCase for RichEditor views.
This commit is contained in:
@@ -7,66 +7,6 @@ use Relaticle\Comments\Models\Comment;
|
||||
use Relaticle\Comments\Tests\Models\Post;
|
||||
use Relaticle\Comments\Tests\Models\User;
|
||||
|
||||
it('returns matching users for search query', function () {
|
||||
$alice = User::factory()->create(['name' => 'Alice']);
|
||||
User::factory()->create(['name' => 'Bob']);
|
||||
$post = Post::factory()->create();
|
||||
|
||||
$this->actingAs($alice);
|
||||
|
||||
$component = Livewire::test(Comments::class, ['model' => $post]);
|
||||
$results = $component->instance()->searchUsers('Ali');
|
||||
|
||||
expect($results)->toHaveCount(1);
|
||||
expect($results[0])->toMatchArray([
|
||||
'id' => $alice->id,
|
||||
'name' => 'Alice',
|
||||
]);
|
||||
expect($results[0])->toHaveKey('avatar_url');
|
||||
});
|
||||
|
||||
it('returns empty array for empty query', function () {
|
||||
$user = User::factory()->create();
|
||||
$post = Post::factory()->create();
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
$component = Livewire::test(Comments::class, ['model' => $post]);
|
||||
$results = $component->instance()->searchUsers('');
|
||||
|
||||
expect($results)->toBeEmpty();
|
||||
});
|
||||
|
||||
it('returns empty array for no matches', function () {
|
||||
$user = User::factory()->create(['name' => 'Alice']);
|
||||
$post = Post::factory()->create();
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
$component = Livewire::test(Comments::class, ['model' => $post]);
|
||||
$results = $component->instance()->searchUsers('zzz');
|
||||
|
||||
expect($results)->toBeEmpty();
|
||||
});
|
||||
|
||||
it('limits search results to configured max', function () {
|
||||
$user = User::factory()->create(['name' => 'Admin']);
|
||||
$post = Post::factory()->create();
|
||||
|
||||
for ($i = 1; $i <= 10; $i++) {
|
||||
User::factory()->create(['name' => "Test User {$i}"]);
|
||||
}
|
||||
|
||||
config(['comments.mentions.max_results' => 3]);
|
||||
|
||||
$this->actingAs($user);
|
||||
|
||||
$component = Livewire::test(Comments::class, ['model' => $post]);
|
||||
$results = $component->instance()->searchUsers('Test');
|
||||
|
||||
expect($results)->toHaveCount(3);
|
||||
});
|
||||
|
||||
it('stores mentions when creating comment with @mention', function () {
|
||||
$user = User::factory()->create();
|
||||
$alice = User::factory()->create(['name' => 'Alice']);
|
||||
@@ -75,7 +15,7 @@ it('stores mentions when creating comment with @mention', function () {
|
||||
$this->actingAs($user);
|
||||
|
||||
Livewire::test(Comments::class, ['model' => $post])
|
||||
->set('newComment', '<p>Hey @Alice check this</p>')
|
||||
->set('commentData.body', '<p>Hey @Alice check this</p>')
|
||||
->call('addComment');
|
||||
|
||||
$comment = Comment::first();
|
||||
@@ -101,7 +41,7 @@ it('stores mentions when editing comment with @mention', function () {
|
||||
|
||||
Livewire::test(CommentItem::class, ['comment' => $comment])
|
||||
->call('startEdit')
|
||||
->set('editBody', '<p>Updated @Bob</p>')
|
||||
->set('editData.body', '<p>Updated @Bob</p>')
|
||||
->call('saveEdit');
|
||||
|
||||
$comment->refresh();
|
||||
|
||||
Reference in New Issue
Block a user