Skip to content

Commit ad4a0a4

Browse files
Add form data max length validation test case
1 parent f68602b commit ad4a0a4

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

resources/views/resources/pages/create/can-create-record.blade.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,16 @@
55
livewire({{ $getPageClass('create') }}::class)
66
->fillForm([
77
@foreach($getResourceFormFields() as $key => $field)
8-
@if($field instanceof RichEditor)
9-
// TODO: RichEditor expects a very specific array structure for its data and Filament tests do not currently support this.
10-
// '{{ $key }}' => $record->{{ $key }},
11-
@else
12-
'{{ $key }}' => $record->{{ $key }},
13-
@endif
8+
'{{ $key }}' => $record->{{ $key }},
149
@endforeach
1510
])
1611
->call('create')
12+
->assertHasNoFormErrors()
1713
->assertNotified();
1814

1915
$this->assertDatabaseHas({{ $getResourceModel() }}::class, [
2016
@foreach($getResourceFormFields() as $key => $field)
21-
@if($field instanceof RichEditor)
22-
// TODO: RichEditor expects a very specific array structure for its data and Filament tests do not currently support this.
23-
// '{{ $key }}' => $record->{{ $key }},
24-
@else
25-
'{{ $key }}' => $record->{{ $key }},
26-
@endif
17+
'{{ $key }}' => $record->{{ $key }},
2718
@endforeach
2819
]);
2920
});

resources/views/resources/pages/create/can-validate-create-form-data.blade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@
1212
@foreach($getResourceRequiredFormFields() as $key => $field)
1313
'`{{ $key }}` is required' => [['{{ $key }}' => null], ['{{ $key }}' => 'required']],
1414
@endforeach
15+
@foreach($getResourceMaxLengthFormFields() as $key => $field)
16+
'`{{ $key }}` is max {{ $field->getMaxLength() }} characters' => [['{{ $key }}' => Illuminate\Support\Str::random({{ $field->getMaxLength() + 1 }})], ['{{ $key }}' => 'max']],
17+
@endforeach
1518
]);

0 commit comments

Comments
 (0)