Render
To ensure a table component renders, use theassertSuccessful() Livewire helper:
assertCanSeeTableRecords(), assertCanNotSeeTableRecords() and assertCountTableRecords():
Note that if your table uses pagination,assertCanSeeTableRecords()will only check for records on the first page. To switch page, callset('page', 2).
Note that if your table usesdeferLoading(), you should callloadTable()beforeassertCanSeeTableRecords().
Columns
To ensure that a certain column is rendered, pass the column name toassertCanRenderTableColumn():
assertCanNotRenderTableColumn():
Sorting
To sort table records, you can callsortTable(), passing the name of the column to sort by. You can use 'desc' in the second parameter of sortTable() to reverse the sorting direction.
Once the table is sorted, you can ensure that the table records are rendered in order using assertCanSeeTableRecords() with the inOrder parameter:
Searching
To search the table, call thesearchTable() method with your search query.
You can then use assertCanSeeTableRecords() to check your filtered table records, and use assertCanNotSeeTableRecords() to assert that some records are no longer in the table:
searchTableColumns():
State
To assert that a certain column has a state or does not have a state for a record you can useassertTableColumnStateSet() and assertTableColumnStateNotSet():
assertTableColumnFormattedStateSet() and assertTableColumnFormattedStateNotSet():
Existence
To ensure that a column exists, you can use theassertTableColumnExists() method:
Authorization
To ensure that a particular user cannot see a column, you can use theassertTableColumnVisible() and assertTableColumnHidden() methods:
Descriptions
To ensure a column has the correct description above or below you can use theassertTableColumnHasDescription() and assertTableColumnDoesNotHaveDescription() methods:
Extra Attributes
To ensure that a column has the correct extra attributes you can use theassertTableColumnHasExtraAttributes() and assertTableColumnDoesNotHaveExtraAttributes() methods:
Select Columns
If you have a select column, you can ensure it has the correct options withassertSelectColumnHasOptions() and assertSelectColumnDoesNotHaveOptions():
Filters
To filter the table records, you can use thefilterTable() method, along with assertCanSeeTableRecords() and assertCanNotSeeTableRecords():
SelectFilter or TernaryFilter, pass the value as a second argument:
Resetting filters
To reset all filters to their original state, callresetTableFilters():
Removing Filters
To remove a single filter you can useremoveTableFilter():
removeTableFilters():
Actions
Calling actions
You can call an action by passing its name or class tocallTableAction():
DeleteAction on your table. If you have a custom Action::make('reorder'), you may use callTableAction('reorder').
For column actions, you may do the same, using callTableColumnAction():
callTableBulkAction():
data parameter:
Execution
To check if an action or bulk action has been halted, you can useassertTableActionHalted() / assertTableBulkActionHalted():
Errors
assertHasNoTableActionErrors() 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 assertHasTableActionErrors(), similar to assertHasErrors() in Livewire:
assertHasTableBulkActionErrors() and assertHasNoTableBulkActionErrors().
Pre-filled data
To check if an action or bulk action is pre-filled with data, you can use theassertTableActionDataSet() or assertTableBulkActionDataSet() method:
Action state
To ensure that an action or bulk action exists or doesn’t in a table, you can use theassertTableActionExists() / assertTableActionDoesNotExist() or assertTableBulkActionExists() / assertTableBulkActionDoesNotExist() method:
assertTableActionEnabled() / assertTableActionDisabled() or assertTableBulkActionEnabled() / assertTableBulkActionDisabled() methods:
assertTableActionVisible() / assertTableActionHidden() or assertTableBulkActionVisible() / assertTableBulkActionHidden() methods:
Button Style
To ensure an action or bulk action has the correct label, you can useassertTableActionHasLabel() / assertTableBulkActionHasLabel() and assertTableActionDoesNotHaveLabel() / assertTableBulkActionDoesNotHaveLabel():
assertTableActionHasIcon() / assertTableBulkActionHasIcon() or assertTableActionDoesNotHaveIcon() / assertTableBulkActionDoesNotHaveIcon():
assertTableActionHasColor() / assertTableBulkActionHasColor() or assertTableActionDoesNotHaveColor() / assertTableBulkActionDoesNotHaveColor():
URL
To ensure an action or bulk action has the correct URL traits, you can useassertTableActionHasUrl(), assertTableActionDoesNotHaveUrl(), assertTableActionShouldOpenUrlInNewTab(), and assertTableActionShouldNotOpenUrlInNewTab():