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-01 16:53:32 +01:00
|
|
|
$formtemplate = Formtemplate::factory()->sections([FormtemplateSectionRequest::new()->name('sname')->create()])->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-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],
|
|
|
|
'default' => null,
|
2023-12-26 00:44:49 +01:00
|
|
|
'required' => false,
|
|
|
|
'options' => [],
|
|
|
|
]
|
|
|
|
])
|
2023-12-31 14:29:50 +01:00
|
|
|
->assertInertiaPath('data.meta.fields.6', [
|
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],
|
2023-12-25 19:35:00 +01:00
|
|
|
'default' => '',
|
|
|
|
'required' => false,
|
|
|
|
]
|
2023-12-22 20:40:24 +01:00
|
|
|
])
|
2023-12-31 14:29:50 +01:00
|
|
|
->assertInertiaPath('data.meta.fields.7', [
|
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],
|
2023-12-26 00:44:49 +01:00
|
|
|
'default' => '',
|
|
|
|
'required' => false,
|
|
|
|
'rows' => 5,
|
|
|
|
]
|
|
|
|
])
|
2023-12-22 20:40:24 +01:00
|
|
|
->assertInertiaPath('data.meta.default', [
|
|
|
|
'name' => '',
|
|
|
|
'config' => [
|
|
|
|
'sections' => [],
|
|
|
|
]
|
|
|
|
])
|
|
|
|
->assertInertiaPath('data.meta.links.store', route('formtemplate.store'))
|
|
|
|
->assertInertiaPath('data.meta.section_default', [
|
2023-12-25 19:35:00 +01:00
|
|
|
'name' => '',
|
|
|
|
'intro' => '',
|
2023-12-22 20:40:24 +01:00
|
|
|
'fields' => [],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|