Select getSearchResultsUsing , Test read null

This is my code protected function getFormSchema(): array { //TODO SISTEMARE CODICE DUPLICATO E RIPROVARE I TEST $selectComponent = Forms\Components\Select::make('storeId') ->label('Seleziona Store') ->getSearchResultsUsing(function ($search){ return Store::where('name', 'like', '%' . $search . '%')->limit(10)->pluck('name', 'id')->toArray(); }) ->searchable() ->required() ->extraAttributes(['id' => 'storeIdSelect']); if (Store::first() ?? false) { $selectComponent->default(Store::first()->id); }
return [ $selectComponent // Assumi che il modello Store abbia 'name' e 'id' ]; } and this is my test it('shows the store selection dropdown', function () { livewire(ScanQR::class) ->assertFormFieldExists('storeId') ->fillForm(['storeId' => 1]) ->assertFormSet(['storeId' => 1]); }); the result it's Failed asserting that null matches expected 1. what im doing wrong ? because if i put options() instead of getSearchResultsUsing() it works normally
No description
4 Replies
LeandroFerreira
LeandroFerreira6mo ago
->options(fn () => app()->runningUnitTests() ? Store::pluck('name', 'id') : null)
->options(fn () => app()->runningUnitTests() ? Store::pluck('name', 'id') : null)
what happens?
Darkavatar23
Darkavatar23OP6mo ago
do not find anymore anything
No description
Darkavatar23
Darkavatar23OP6mo ago
But it perform query to search first store
No description
LeandroFerreira
LeandroFerreira6mo ago
I mean, when you run tests
Want results from more Discord servers?
Add your server