Getting started
Ensure that you are authenticated to access the admin panel in yourTestCase:
Resources
Pages
List
Routing & render
To ensure that the List page for thePostResource is able to render successfully, generate a page URL, perform a request to this URL and ensure that it is successful:
Table
Filament includes a selection of helpers for testing tables. A full guide to testing tables can be found in the Table Builder documentation. To use a table testing helper, make assertions on the resource’s List page class, which holds the table:Create
Routing & render
To ensure that the Create page for thePostResource is able to render successfully, generate a page URL, perform a request to this URL and ensure that it is successful:
Creating
You may check that data is correctly saved into the database by callingfillForm() with your form data, and then asserting that the database contains a matching record:
Validation
UseassertHasFormErrors() to ensure that data is properly validated in a form:
Edit
Routing & render
To ensure that the Edit page for thePostResource is able to render successfully, generate a page URL, perform a request to this URL and ensure that it is successful:
Filling existing data
To check that the form is filled with the correct data from the database, you mayassertFormSet() that the data in the form matches that of the record:
Saving
You may check that data is correctly saved into the database by callingfillForm() with your form data, and then asserting that the database contains a matching record:
Validation
UseassertHasFormErrors() to ensure that data is properly validated in a form:
Deleting
You can test theDeleteAction using callPageAction():
DeleteAction using assertPageActionHidden():
View
Routing & render
To ensure that the View page for thePostResource is able to render successfully, generate a page URL, perform a request to this URL and ensure that it is successful:
Filling existing data
To check that the form is filled with the correct data from the database, you mayassertSet() that the data in the form matches that of the record:
Relation managers
Render
To ensure that a relation manager is able to render successfully, mount the Livewire component:Table
Filament includes a selection of helpers for testing tables. A full guide to testing tables can be found in the Table Builder documentation. To use a table testing helper, make assertions on the relation manager class, which holds the table:Page actions
Calling actions
You can call a page action by passing its name or class tocallPageAction():
data parameter:
setPageActionData():
Execution
To check if an action has been halted, you can useassertPageActionHalted():
Errors
assertHasNoPageActionErrors() is used to assert that no validation errors occurred when submitting the action form.
To check if a validation error has occurred with the data, use assertHasPageActionErrors(), similar to assertHasErrors() in Livewire:
Pre-filled data
To check if a page action is pre-filled with data, you can use theassertPageActionDataSet() method:
Action State
To ensure that an action exists or doesn’t in a table, you can use theassertPageActionExists() or assertPageActionDoesNotExist() method:
assertPageActionHidden() or assertPageActionVisible() methods:
assertPageActionEnabled() or assertPageActionDisabled() methods:
assertPageActionsExistInOrder():
Button appearance
To ensure an action has the correct label, you can useassertPageActionHasLabel() and assertPageActionDoesNotHaveLabel():
assertPageActionHasIcon() or assertPageActionDoesNotHaveIcon():
assertPageActionHasColor() or assertPageActionDoesNotHaveColor():
URL
To ensure an action has the correct URL, you can useassertPageActionHasUrl(), assertPageActionDoesNotHaveUrl(), assertPageActionShouldOpenUrlInNewTab(), and assertPageActionShouldNotOpenUrlInNewTab():