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,
],
],
],
]);
});