CodingBoi
CodingBoi
FFilament
Created by CodingBoi on 2/19/2025 in #❓┊help
[Test] itemLabel function from Repeater
I want to test that a custom itemLabel generator closure is working as expected, thus I'm creating a test for it.
class LineItemPieceIdGeneratorTest extends TestCase
{
public function testLineItemPieceIdGenerator()
{

// Create a new ComponentContainer instance.
$container = ComponentContainer::make();

// Assign a schema of components to the container.
$container->schema([
Repeater::make('line_items')
->schema([
Repeater::make('pieces')
->itemLabel(fn (ComponentContainer $container, $state) => LineItemPieceIdGenerator::make()->handle($container, $state))
->schema([
TextInput::make('line_items.piece_id')
])

])
]);
class LineItemPieceIdGeneratorTest extends TestCase
{
public function testLineItemPieceIdGenerator()
{

// Create a new ComponentContainer instance.
$container = ComponentContainer::make();

// Assign a schema of components to the container.
$container->schema([
Repeater::make('line_items')
->schema([
Repeater::make('pieces')
->itemLabel(fn (ComponentContainer $container, $state) => LineItemPieceIdGenerator::make()->handle($container, $state))
->schema([
TextInput::make('line_items.piece_id')
])

])
]);
in this case, the Container itself is rendered as "empty", and the "make" function wants a Livewire instance. This is the first time I am trying to test something in Filament.
1 replies