Add config to index
This commit is contained in:
parent
7d880c6e29
commit
5cf49489d5
|
@ -30,6 +30,7 @@ class FormResource extends JsonResource
|
||||||
'mail_bottom' => $this->mail_bottom,
|
'mail_bottom' => $this->mail_bottom,
|
||||||
'registration_from' => $this->registration_from?->format('Y-m-d H:i:s'),
|
'registration_from' => $this->registration_from?->format('Y-m-d H:i:s'),
|
||||||
'registration_until' => $this->registration_until?->format('Y-m-d H:i:s'),
|
'registration_until' => $this->registration_until?->format('Y-m-d H:i:s'),
|
||||||
|
'config' => $this->config,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Database\Factories\Form\Models;
|
||||||
|
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
use Tests\Feature\Form\FormtemplateSectionRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @extends Factory<Form>
|
* @extends Factory<Form>
|
||||||
|
@ -48,7 +49,7 @@ class FormFactory extends Factory
|
||||||
*/
|
*/
|
||||||
public function sections(array $sections): self
|
public function sections(array $sections): self
|
||||||
{
|
{
|
||||||
return $this->state(['config.sections' => $sections]);
|
return $this->state(['config' => ['sections' => $sections]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,19 +14,31 @@ class FormIndexActionTest extends TestCase
|
||||||
public function testItDisplaysForms(): void
|
public function testItDisplaysForms(): void
|
||||||
{
|
{
|
||||||
$this->login()->loginNami()->withoutExceptionHandling();
|
$this->login()->loginNami()->withoutExceptionHandling();
|
||||||
Form::factory()->name('lala')->excerpt('fff')->description('desc')->from('2023-05-05')->to('2023-06-07')->mailTop('Guten Tag')->mailBottom('Cheers')->registrationFrom('2023-05-06 04:00:00')->registrationUntil('2023-04-01 05:00:00')->create();
|
$form = Form::factory()
|
||||||
|
->name('lala')
|
||||||
|
->excerpt('fff')
|
||||||
|
->description('desc')
|
||||||
|
->from('2023-05-05')
|
||||||
|
->to('2023-06-07')
|
||||||
|
->mailTop('Guten Tag')
|
||||||
|
->mailBottom('Cheers')
|
||||||
|
->registrationFrom('2023-05-06 04:00:00')
|
||||||
|
->registrationUntil('2023-04-01 05:00:00')
|
||||||
|
->sections([FormtemplateSectionRequest::new()->name('sname')->fields([FormtemplateFieldRequest::new()])->create()])
|
||||||
|
->create();
|
||||||
|
|
||||||
$this->get(route('form.index'))
|
$this->get(route('form.index'))
|
||||||
->assertOk()
|
->assertOk()
|
||||||
|
->assertInertiaPath('data.data.0.config.sections.0.name', 'sname')
|
||||||
->assertInertiaPath('data.data.0.name', 'lala')
|
->assertInertiaPath('data.data.0.name', 'lala')
|
||||||
->assertInertiaPath('data.data.0.from_human', '05.05.2023')
|
|
||||||
->assertInertiaPath('data.data.0.to_human', '07.06.2023')
|
|
||||||
->assertInertiaPath('data.data.0.from', '2023-05-05')
|
|
||||||
->assertInertiaPath('data.data.0.to', '2023-06-07')
|
|
||||||
->assertInertiaPath('data.data.0.excerpt', 'fff')
|
->assertInertiaPath('data.data.0.excerpt', 'fff')
|
||||||
->assertInertiaPath('data.data.0.description', 'desc')
|
->assertInertiaPath('data.data.0.description', 'desc')
|
||||||
->assertInertiaPath('data.data.0.mail_top', 'Guten Tag')
|
->assertInertiaPath('data.data.0.mail_top', 'Guten Tag')
|
||||||
->assertInertiaPath('data.data.0.mail_bottom', 'Cheers')
|
->assertInertiaPath('data.data.0.mail_bottom', 'Cheers')
|
||||||
|
->assertInertiaPath('data.data.0.from_human', '05.05.2023')
|
||||||
|
->assertInertiaPath('data.data.0.to_human', '07.06.2023')
|
||||||
|
->assertInertiaPath('data.data.0.from', '2023-05-05')
|
||||||
|
->assertInertiaPath('data.data.0.to', '2023-06-07')
|
||||||
->assertInertiaPath('data.data.0.registration_from', '2023-05-06 04:00:00')
|
->assertInertiaPath('data.data.0.registration_from', '2023-05-06 04:00:00')
|
||||||
->assertInertiaPath('data.data.0.registration_until', '2023-04-01 05:00:00');
|
->assertInertiaPath('data.data.0.registration_until', '2023-04-01 05:00:00');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue