Skip to content

Commit

Permalink
Merge pull request #15584 from Mrkbingham/repeater-action-test-doc-up…
Browse files Browse the repository at this point in the history
…date

Docs: Add repeater action item testing documentation
  • Loading branch information
danharrin authored Feb 13, 2025
2 parents 11b2dae + 408064c commit 1228b75
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/forms/docs/03-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 1228b75

Please sign in to comment.