82 lines
3.1 KiB
PHP
82 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Form;
|
|
|
|
use App\Form\Models\Formtemplate;
|
|
use App\Group;
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
use Tests\TestCase;
|
|
|
|
class FormtemplateIndexActionTest extends TestCase
|
|
{
|
|
|
|
use DatabaseTransactions;
|
|
|
|
public function testItDisplaysIndexPage(): void
|
|
{
|
|
$formtemplate = Formtemplate::factory()->sections([FormtemplateSectionRequest::new()->name('sname')])->create();
|
|
|
|
$group = Group::factory()->has(Group::factory()->state(['inner_name' => 'child']), 'children')->create(['inner_name' => 'root']);
|
|
$this->login()->loginNami(12345, 'pasword', $group)->withoutExceptionHandling();
|
|
|
|
$this->get(route('formtemplate.index'))
|
|
->assertInertiaPath('data.data.0.links', [
|
|
'update' => route('formtemplate.update', ['formtemplate' => $formtemplate]),
|
|
])
|
|
->assertInertiaPath('data.data.0.config.sections.0.name', 'sname')
|
|
->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', [
|
|
'id' => 'DropdownField',
|
|
'name' => 'Dropdown',
|
|
'default' => [
|
|
'name' => '',
|
|
'type' => 'DropdownField',
|
|
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
|
|
'default' => null,
|
|
'required' => false,
|
|
'options' => [],
|
|
]
|
|
])
|
|
->assertInertiaPath('data.meta.fields.6', [
|
|
'id' => 'TextField',
|
|
'name' => 'Text',
|
|
'default' => [
|
|
'name' => '',
|
|
'type' => 'TextField',
|
|
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
|
|
'default' => '',
|
|
'required' => false,
|
|
]
|
|
])
|
|
->assertInertiaPath('data.meta.fields.7', [
|
|
'id' => 'TextareaField',
|
|
'name' => 'Textarea',
|
|
'default' => [
|
|
'name' => '',
|
|
'type' => 'TextareaField',
|
|
'columns' => ['mobile' => 2, 'tablet' => 4, 'desktop' => 6],
|
|
'default' => '',
|
|
'required' => false,
|
|
'rows' => 5,
|
|
]
|
|
])
|
|
->assertInertiaPath('data.meta.default', [
|
|
'name' => '',
|
|
'config' => [
|
|
'sections' => [],
|
|
]
|
|
])
|
|
->assertInertiaPath('data.meta.links.store', route('formtemplate.store'))
|
|
->assertInertiaPath('data.meta.links.form_index', route('form.index'))
|
|
->assertInertiaPath('data.meta.section_default', [
|
|
'name' => '',
|
|
'intro' => '',
|
|
'fields' => [],
|
|
]);
|
|
}
|
|
}
|