Pest Testing Repeater (extra value added in tests)

Hi all,

I'm hoping somebody can help me understand where I'm going wrong.

I've set up a repeater action

return CreateAction::make('create_content')
            ...
            ->form([
                Section::make('Content')
                    ->description('Add your content ')
                    ->schema([
                        Repeater::make('articles')
                            ->label('')
                            ->addActionLabel('Add More Content')
                            ->schema([
                                TextArea::make('body')
                                    ->label('')
                                    ->required(),
                            ]),
                    ]),
            ])->using(function (array $data, string $model): Model {
                // I check my $data['articles'] here
            });


I'm trying to test it as such:

livewire(MyComponent::class)
        ->callTableAction('create_content', data: ['articles' => [
            ['body' => 'huh?'],
            ['body' => 'woah'],
            ['body' => 'cool'],
        ],
        ]);


However, when I run the test in debug, the $data['articles'] variable has 4 entries - 1 null, and then the 3 I've specified in my test.

Normally it wouldn't be a problem, I can just filter out the null value, but when I add in a ->required() to the textfield in the repeater, the test doesn't work (due to the null value, I'm assuming).

Has anybody else experienced this, and can you point me to what I'm doing wrong?

Thanks so much!
Was this page helpful?