adrema/tests/Feature/Form/FormtemplateIndexActionTest...

101 lines
4.0 KiB
PHP
Raw Normal View History

2023-12-22 20:40:24 +01:00
<?php
namespace Tests\Feature\Form;
2023-12-26 00:44:49 +01:00
use App\Form\Models\Formtemplate;
2023-12-31 14:29:50 +01:00
use App\Group;
2023-12-22 20:40:24 +01:00
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class FormtemplateIndexActionTest extends TestCase
{
use DatabaseTransactions;
public function testItDisplaysIndexPage(): void
{
2024-01-10 21:43:22 +01:00
$formtemplate = Formtemplate::factory()->sections([FormtemplateSectionRequest::new()->name('sname')])->create();
2023-12-26 00:44:49 +01:00
2023-12-31 14:29:50 +01:00
$group = Group::factory()->has(Group::factory()->state(['inner_name' => 'child']), 'children')->create(['inner_name' => 'root']);
$this->login()->loginNami(12345, 'pasword', $group)->withoutExceptionHandling();
2023-12-22 20:40:24 +01:00
$this->get(route('formtemplate.index'))
2023-12-26 00:44:49 +01:00
->assertInertiaPath('data.data.0.links', [
'update' => route('formtemplate.update', ['formtemplate' => $formtemplate]),
2024-02-19 03:01:18 +01:00
'destroy' => route('formtemplate.destroy', ['formtemplate' => $formtemplate]),
2023-12-26 00:44:49 +01:00
])
2024-01-01 16:53:32 +01:00
->assertInertiaPath('data.data.0.config.sections.0.name', 'sname')
2023-12-31 14:29:50 +01:00
->assertInertiaPath('data.meta.groups', [
['id' => $group->id, 'name' => 'root'],
['id' => $group->children->first()->id, 'name' => '-- child'],
])
->assertInertiaPath('data.meta.base_url', url(''))
->assertInertiaPath('data.meta.fields.3', [
2023-12-26 00:44:49 +01:00
'id' => 'DropdownField',
'name' => 'Dropdown',
'default' => [
'name' => '',
'type' => 'DropdownField',
2023-12-26 20:06:57 +01:00
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
2024-03-13 15:48:08 +01:00
'value' => null,
2024-02-16 14:18:16 +01:00
'nami_type' => null,
2024-02-19 02:32:46 +01:00
'for_members' => true,
2024-03-13 13:48:35 +01:00
'special_type' => null,
2024-04-10 00:00:20 +02:00
'hint' => '',
2024-06-07 01:02:07 +02:00
'intro' => '',
2023-12-26 00:44:49 +01:00
'options' => [],
2024-04-12 15:23:18 +02:00
'required' => true,
2024-04-17 10:19:56 +02:00
'allowcustom' => false,
2023-12-26 00:44:49 +01:00
]
])
2024-04-15 16:20:29 +02:00
->assertInertiaPath('data.meta.fields.9', [
2023-12-22 20:40:24 +01:00
'id' => 'TextField',
'name' => 'Text',
2023-12-25 19:35:00 +01:00
'default' => [
'name' => '',
'type' => 'TextField',
2023-12-26 20:06:57 +01:00
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
2024-04-19 11:38:53 +02:00
'value' => null,
2024-02-16 14:18:16 +01:00
'nami_type' => null,
2024-02-19 02:32:46 +01:00
'for_members' => true,
2024-03-13 13:48:35 +01:00
'special_type' => null,
2024-04-10 00:00:20 +02:00
'hint' => '',
2024-06-07 01:02:07 +02:00
'intro' => '',
2024-04-12 15:23:18 +02:00
'required' => true,
2023-12-25 19:35:00 +01:00
]
2023-12-22 20:40:24 +01:00
])
2024-04-15 16:20:29 +02:00
->assertInertiaPath('data.meta.fields.10', [
2023-12-26 00:44:49 +01:00
'id' => 'TextareaField',
'name' => 'Textarea',
'default' => [
'name' => '',
'type' => 'TextareaField',
2023-12-26 20:06:57 +01:00
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
2024-03-13 15:48:08 +01:00
'value' => '',
2024-02-16 14:18:16 +01:00
'nami_type' => null,
2024-02-19 02:32:46 +01:00
'for_members' => true,
2024-03-13 13:48:35 +01:00
'special_type' => null,
2024-04-10 00:00:20 +02:00
'hint' => '',
2024-06-07 01:02:07 +02:00
'intro' => '',
2023-12-26 00:44:49 +01:00
'rows' => 5,
2024-04-12 15:23:18 +02:00
'required' => true,
2023-12-26 00:44:49 +01:00
]
])
2023-12-22 20:40:24 +01:00
->assertInertiaPath('data.meta.default', [
'name' => '',
'config' => [
'sections' => [],
]
])
->assertInertiaPath('data.meta.links.store', route('formtemplate.store'))
2024-01-01 18:29:33 +01:00
->assertInertiaPath('data.meta.links.form_index', route('form.index'))
2024-03-15 00:39:17 +01:00
->assertInertiaPath('data.meta.namiTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
->assertInertiaPath('data.meta.specialTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
2023-12-22 20:40:24 +01:00
->assertInertiaPath('data.meta.section_default', [
2023-12-25 19:35:00 +01:00
'name' => '',
'intro' => '',
2023-12-22 20:40:24 +01:00
'fields' => [],
]);
}
}