<?php

namespace Tests\Unit;

use App\Filament\Blog\Resources\PostResource;
use Filament\Forms\Components\Textarea;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
use Filament\Schemas\Schema;
use Livewire\Component;
use Tests\TestCase;

class BlogPostExcerptFieldTest extends TestCase
{
    public function test_excerpt_fields_allow_long_text(): void
    {
        $livewire = new class extends Component implements HasSchemas
        {
            use InteractsWithSchemas;

            public function render(): string
            {
                return '';
            }
        };

        $schema = PostResource::form(Schema::make($livewire));

        $excerptDe = $schema->getComponentByStatePath('excerpt.de');
        $excerptEn = $schema->getComponentByStatePath('excerpt.en');

        $this->assertInstanceOf(Textarea::class, $excerptDe);
        $this->assertInstanceOf(Textarea::class, $excerptEn);
        $this->assertSame(65535, $excerptDe->getMaxLength());
        $this->assertSame(65535, $excerptEn->getMaxLength());
    }
}
