Fix: Update section intro
continuous-integration/drone/push Build is failing Details

This commit is contained in:
philipp lang 2024-06-18 14:54:44 +02:00
parent 3f3ecf0071
commit f03459de58
4 changed files with 23 additions and 1 deletions

View File

@ -18,6 +18,7 @@ trait HasValidation
'name' => 'required|string|max:255',
'config' => 'array',
'config.sections.*.name' => 'required',
'config.sections.*.intro' => 'nullable|string',
'config.sections.*.fields' => 'array',
'config.sections.*.fields.*.name' => 'required|string',
'config.sections.*.fields.*.type' => ['required', 'string', Rule::in(array_column(Field::asMeta(), 'id'))],

View File

@ -15,7 +15,8 @@ class SectionData extends Data
public string $name,
#[WithCast(FieldCollectionCast::class)]
#[WithTransformer(FieldCollectionTransformer::class)]
public FieldCollection $fields
public FieldCollection $fields,
public ?string $intro
) {
}
}

View File

@ -59,6 +59,20 @@ class FormUpdateActionTest extends FormTestCase
$this->assertEquals(['firstname'], $form->fresh()->meta['active_columns']);
}
public function testItUpdatesIntroOfSections(): void
{
$this->login()->loginNami()->withoutExceptionHandling();
$form = Form::factory()
->sections([FormtemplateSectionRequest::new()->intro('aaa')])
->create();
$payload = FormRequest::new()->sections([
FormtemplateSectionRequest::new()->intro('aaa')
])->create();
$this->patchJson(route('form.update', ['form' => $form]), $payload)->assertSessionDoesntHaveErrors()->assertOk();
$this->assertEquals('aaa', $form->fresh()->config->sections[0]->intro);
}
public function testItUpdatesActiveState(): void
{
$this->login()->loginNami()->withoutExceptionHandling();

View File

@ -16,6 +16,7 @@ class FormtemplateSectionRequest extends RequestFactory
{
return [
'name' => $this->faker->words(5, true),
'intro' => '',
'fields' => [],
];
}
@ -28,6 +29,11 @@ class FormtemplateSectionRequest extends RequestFactory
return $this->state(['fields' => $fields]);
}
public function intro(string $intro): self
{
return $this->state(['intro' => $intro]);
}
/**
* @param mixed $args
*/