Skip to content

Commit

Permalink
Merge branch '3.x' into 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Feb 13, 2025
2 parents 4c468cc + 1228b75 commit 02a7b49
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/forms/docs/02-fields/12-repeater.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,3 +742,23 @@ livewire(EditPost::class, ['record' => $post])

$undoRepeaterFake();
```

### Testing repeater actions

In order to test that repeater actions are working as expected, you can utilize the `callFormComponentAction()` method to call your repeater actions and then [perform additional assertions](../testing#actions).

To interact with an action on a particular repeater item, you need to pass in the `item` argument with the key of that repeater item. If your repeater is reading from a relationship, you should prefix the ID (key) of the related record with `record-` to form the key of the repeater item:

```php
use App\Models\Quote;
use Filament\Forms\Components\Repeater;
use function Pest\Livewire\livewire;

$quote = Quote::first();

livewire(EditPost::class, ['record' => $post])
->callFormComponentAction('quotes', 'sendQuote', arguments: [
'item' => "record-{$quote->getKey()}",
])
->assertNotified('Quote sent!');
```

0 comments on commit 02a7b49

Please sign in to comment.