diff --git a/resources/views/projects/templates.blade.php b/resources/views/projects/templates.blade.php index fbdcbbb..20a639b 100644 --- a/resources/views/projects/templates.blade.php +++ b/resources/views/projects/templates.blade.php @@ -1,12 +1,23 @@ -
- -

- {{ __('Create generic templates that can be used in any phase of the project') }} -

+ +
+ + + +
+

{{ __('Inspection templates') }}

+

{{ $project->name }}

+
+
+
+ +
+
+

+ {{ __('Create generic templates that can be used in any phase of the project') }} +

+ + +
- diff --git a/tests/Feature/TemplateCreationTest.php b/tests/Feature/TemplateCreationTest.php new file mode 100644 index 0000000..8e83890 --- /dev/null +++ b/tests/Feature/TemplateCreationTest.php @@ -0,0 +1,59 @@ +create(); + $user->givePermissionTo('edit projects'); + $project = Project::create([ + 'reference' => 'TPL-2', 'name' => 'Proyecto TPL', 'address' => 'x', + 'lat' => 40.0, 'lng' => -3.0, 'start_date' => now()->toDateString(), + 'end_date_estimated' => now()->addMonth()->toDateString(), + 'status' => 'in_progress', 'created_by' => $user->id, + ]); + return [$user, $project]; + } + + public function test_templates_page_embeds_the_manager_component(): void + { + [$user, $project] = $this->setup_(); + + $this->actingAs($user) + ->get(route('projects.templates', $project)) + ->assertOk() + ->assertSeeLivewire(TemplateManager::class); + } + + public function test_new_template_button_opens_form_and_saves(): void + { + [$user, $project] = $this->setup_(); + + Livewire::actingAs($user) + ->test(TemplateManager::class, ['project' => $project]) + ->assertSet('showForm', false) + ->call('newTemplate') + ->assertSet('showForm', true) + ->set('form.name', 'Recepción de hormigón') + ->call('saveTemplate') + ->assertHasNoErrors(); + + $this->assertDatabaseHas('inspection_templates', [ + 'project_id' => $project->id, + 'name' => 'Recepción de hormigón', + ]); + } +}