Following this testing docs section, I came to this:
- Add a
key() to the tab that you want to test in order to make it accesible by the test itself:
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Tabs::make('My tabs')
->tabs([
Tab::make('My tab')
->key('my-tab') // give a key to the tab
->schema([
Action::make('myCustomAction')
]),
]),
]);
}
- Now, you can point to that specific tab and check with
checkComponentUsing if there is the action that you expect:
it('has myCustomAction inside My Tab', function () {
$record = Model::factory()->create();
$component = livewire(ViewAsset::class, [
'record' => $record->id,
])
->assertSchemaComponentExists(
key: 'my-tab',
checkComponentUsing: function (Tab $tab): bool {
return (bool) $tab->getChildSchema()->getAction('myCustomAction');
},
);
});