Test editOptionForm

Hey everyone. I want to test my form that it is filled with the given data. But when I run the test I always get this error Filament\Forms\Components\Select::getEditOptionActionFormData(): Return value must be of type array, null returned How can I fix this? Dont see anything in de docs about editOptionForm testing. When I remove the editOptionForm from the form, the test is passed. This is my test in pest
it('can fill in the edit page with retrieved data', function () {
// Arrange
$recipe = Recipe::factory()
->has(RecipeIngredient::factory(2), 'ingredients')
->has(RecipeStep::factory(2), 'steps')
->create();

// Act & Assert
livewire(RecipeResource\Pages\EditRecipe::class, [
'record' => $recipe->getRouteKey(),
])
->assertFormSet([
'title' => [
'nl' => $recipe->title,
'en' => $recipe->title,
'fr' => $recipe->title,
],
'recipe_ingredients' => [
'record-1' => [
'quantity' => $recipe->ingredients[0]->quantity,
'ingredient_id' => $recipe->ingredients[0]->ingredient_id,
],
'record-2' => [
'quantity' => $recipe->ingredients[1]->quantity,
'ingredient_id' => $recipe->ingredients[1]->ingredient_id,
],
],
'recipes_steps' => [
'record-1' => [
'step_number' => $recipe->steps[0]->step_number,
'description' => [
'en' => $recipe->steps[0]->description,
'nl' => $recipe->steps[0]->description,
'fr' => $recipe->steps[0]->description,
],
],
],
]);
});
it('can fill in the edit page with retrieved data', function () {
// Arrange
$recipe = Recipe::factory()
->has(RecipeIngredient::factory(2), 'ingredients')
->has(RecipeStep::factory(2), 'steps')
->create();

// Act & Assert
livewire(RecipeResource\Pages\EditRecipe::class, [
'record' => $recipe->getRouteKey(),
])
->assertFormSet([
'title' => [
'nl' => $recipe->title,
'en' => $recipe->title,
'fr' => $recipe->title,
],
'recipe_ingredients' => [
'record-1' => [
'quantity' => $recipe->ingredients[0]->quantity,
'ingredient_id' => $recipe->ingredients[0]->ingredient_id,
],
'record-2' => [
'quantity' => $recipe->ingredients[1]->quantity,
'ingredient_id' => $recipe->ingredients[1]->ingredient_id,
],
],
'recipes_steps' => [
'record-1' => [
'step_number' => $recipe->steps[0]->step_number,
'description' => [
'en' => $recipe->steps[0]->description,
'nl' => $recipe->steps[0]->description,
'fr' => $recipe->steps[0]->description,
],
],
],
]);
});
3 Replies
sfrigzs
sfrigzs5mo ago
@GizaRex Same challenge here, did you find a solution?
awcodes
awcodes5mo ago
Shouldn’t it just be ‘record’ => $recipe
GizaRex
GizaRexOP5mo ago
No still no solution for this. When I use 'record' => $recipe then I get an ModelNotFoundException
Want results from more Discord servers?
Add your server