Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chester-sykes committed Jan 11, 2025
1 parent 6f67770 commit 032221c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/tables/docs/12-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,38 @@ it('can automatically generate a slug from the title without any spaces', functi
});
});
```
### Form field existence

To ensure that a form field exists on a mounted table action form, you can use the `assertTableActionFormFieldExists()` method:

```php
use function Pest\Livewire\livewire;

it('has a slug field', function () {
$post = Post::factory()->create();

livewire(PostsTable::class)
->mountTableAction(EditAction::class, $post)
->assertTableActionFormFieldExists('slug');
});
```

You may pass a function as an additional argument in order to assert that a form field passes a given "truth test". This is useful for asserting that a form field has a specific configuration:

```php
use Filament\Forms\Components\TextInput;
use function Pest\Livewire\livewire;

it('has a slug field', function () {
$post = Post::factory()->create();

livewire(PostsTable::class)
->mountTableAction(EditAction::class, $post)
->assertTableActionFormFieldExists('slug', function (TextInput $slug): bool {
return $slug->isRequired();
});
});
```

### Action state

Expand Down

0 comments on commit 032221c

Please sign in to comment.