Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app-modules/panel-app/src/Pages/ProfilePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Components\Utilities\Set;
use Filament\Schemas\JsContent;
use Filament\Schemas\Schema;
use Filament\Support\Enums\Width;
use He4rt\Gamification\Character\Models\Character;
Expand Down Expand Up @@ -131,6 +132,7 @@ public function form(Schema $schema): Schema
Textarea::make('about')
->label(__('panel-app::profile.fields.about'))
->placeholder(__('panel-app::profile.placeholders.about'))
->hint(JsContent::make('`${Array.from($state ?? "").length}/500`'))
->maxLength(500)
->rows(4)
->live(onBlur: true)
Comment thread
gvieira18 marked this conversation as resolved.
Expand Down
17 changes: 17 additions & 0 deletions app-modules/panel-app/tests/Feature/ProfilePageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use Filament\Facades\Filament;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Schemas\JsContent;
use He4rt\Identity\User\Models\User;
use He4rt\PanelApp\Pages\ProfilePage;
use He4rt\Profile\Enums\EmploymentType;
Expand Down Expand Up @@ -185,6 +187,21 @@
->assertHasFormErrors(['about']);
});

test('profile page shows about character counter in real time', function (): void {
livewire(ProfilePage::class)
->fillForm([
'about' => 'abc'."\u{1F600}".'def',
])
->assertFormFieldExists('about', function (Textarea $field): bool {
expect($field->getHint())->toBeInstanceOf(JsContent::class)
->and($field->getHint()->toHtml())->toContain('Array.from($state')
->toContain('500')
->and($field->getStateBindingModifiers())->toBe(['live', 'blur']);

return true;
});
});

test('profile page validates headline max length', function (): void {
livewire(ProfilePage::class)
->fillForm([
Expand Down