Skip to content

Commit

Permalink
Merge pull request #13291 from mokhosh/current-panel-docs
Browse files Browse the repository at this point in the history
Add docs for setting the current panel in tests
  • Loading branch information
danharrin authored Jun 18, 2024
2 parents 8ee193c + 65bf604 commit 2dc5950
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/panels/docs/14-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ protected function setUp(): void
}
```

### Testing multiple panels

If you have multiple panels and you would like to test a non-default panel, you will need to tell Filament which panel you are testing. This can be done in the `setUp()` method of the test case, or you can do it at the start of a particular test. Filament usually does this in a middleware when you access the panel through a request, so if you're not making a request in your test like when testing a Livewire component, you need to set the current panel manually:

```php
use Filament\Facades\Filament;

Filament::setCurrentPanel(
Filament::getPanel('app'), // Where `app` is the ID of the panel you want to test
);
```

## Resources

### Pages
Expand Down

0 comments on commit 2dc5950

Please sign in to comment.