From d1d7fd2765abdbe20bb78da9e1dd053d2f1aec7c Mon Sep 17 00:00:00 2001 From: Dan <79267265+dansysanalyst@users.noreply.github.com> Date: Sun, 31 May 2026 01:29:36 +0200 Subject: [PATCH] add browser test exmaple --- docs/testing/index.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/testing/index.md b/docs/testing/index.md index 3b5aa9d..f1b55a6 100644 --- a/docs/testing/index.md +++ b/docs/testing/index.md @@ -2,6 +2,32 @@ Create a test component inside the `tests` folder in your application, for example `tests/Feature/Livewire/UsersTableTest.php` +## Pest Browser Testing + +[Pest Browser Testing](https://pestphp.com/docs/browser-testing) allows you to simulate authentic user interactions within your application—including clicking elements, typing input, and selecting options in real time. + +. +The next example tests the [PowerGrid Demo](https://demo.livewire-powergrid.com/examples/demo-dish) component, ensuring that clicking and typing in the filter field will perform the search query and return the expected records. + + +```php +//tests/Browser/FilterFieldTest.php + +$searchField = '[wire\:model\.live\.debounce\.700ms="search"]'; + +it('can filter by existing record') + ->withVite() //enable Vite for this test + ->visit('/examples/demo-dish') + ->assertSee('Arkansas Possum Pie') + ->fill($searchField, 'Bacalhau') + ->assertDontSee('Arkansas Possum Pie') + ->assertSee('Bacalhau com natas'); +``` + +Here, we guarantee the row "Arkansas Possum Pie" is visible when the page loads. Then, we simulate a click in the filter and typing the word "Bacalhau". As a result, we ensure that "Arkansas Possum Pie" is not visible anymore, while the row "Bacalhau com natas" is visible. + +## Liveware Testing + You should follow the same concept defined in the [livewire documentation](https://livewire.laravel.com/docs/testing), and then you will be able to use other native assertions in PowerGrid: ### Testing Actions Buttons