How to test repeater value in filament form?

Please confirmed my test is good or not? Please suggest how to test repeater in filament?
livewire(Create::class)
->fillForm([
'name' => fake()->word(),
'document' => fake()->file('public'),
'bio' => fake()->sentence(),
'experience' => [
['job_title' => fake()->word()],
['company_name' => fake()->word()],
['description' => fake()->sentence()]
]
])
->call('create')
->assertStatus(200);
livewire(Create::class)
->fillForm([
'name' => fake()->word(),
'document' => fake()->file('public'),
'bio' => fake()->sentence(),
'experience' => [
['job_title' => fake()->word()],
['company_name' => fake()->word()],
['description' => fake()->sentence()]
]
])
->call('create')
->assertStatus(200);
10 Replies
Patrick Boivin
Patrick Boivin15mo ago
Instead of assertStatus I guess you could check that the item was really created in the DB?
Shaung Bhone
Shaung BhoneOP15mo ago
Yes when I use ->assertHasNoFormErrors(); that gives me error.
Component has errors:
"data.experience.e921bb43-badf-4371-9901-d25b6113018e.job_title", "data.experience.e921bb43-badf-4371-9901-d25b6113018e.company_name", "data.experience.e921bb43-badf-4371-9901-d25b6113018e.description", "data.experience.0.company_name",
"data.experience.0.description",
"data.experience.1.job_title",
"data.experience.1.description",
"data.experience.2.job_title",
"data.experience.2.company_name",
"data.experience.3.job_title",
"data.experience.3.company_name",
"data.experience.3.description",
"data.experience.4.job_title",
"data.experience.4.company_name",
"data.experience.4.description",
"data.education.80efdce6-f10f-4fd1-86e7-feef840509fa.school", "data.education.1.school",
"data.education.2.school",
"data.education.3.school",
"data.technology_id",
"data.experience_level",
"data.language.a063fe62-90e6-4810-b1d8-163303bd6311.language", "data.language.a063fe62-90e6-4810-b1d8-163303bd6311.proficiency"
Failed asserting that false is true.
Component has errors:
"data.experience.e921bb43-badf-4371-9901-d25b6113018e.job_title", "data.experience.e921bb43-badf-4371-9901-d25b6113018e.company_name", "data.experience.e921bb43-badf-4371-9901-d25b6113018e.description", "data.experience.0.company_name",
"data.experience.0.description",
"data.experience.1.job_title",
"data.experience.1.description",
"data.experience.2.job_title",
"data.experience.2.company_name",
"data.experience.3.job_title",
"data.experience.3.company_name",
"data.experience.3.description",
"data.experience.4.job_title",
"data.experience.4.company_name",
"data.experience.4.description",
"data.education.80efdce6-f10f-4fd1-86e7-feef840509fa.school", "data.education.1.school",
"data.education.2.school",
"data.education.3.school",
"data.technology_id",
"data.experience_level",
"data.language.a063fe62-90e6-4810-b1d8-163303bd6311.language", "data.language.a063fe62-90e6-4810-b1d8-163303bd6311.proficiency"
Failed asserting that false is true.
Patrick Boivin
Patrick Boivin15mo ago
Not sure but I'm thinking the grouping is off in your example above. Should it be something like this?
'experience' => [
[
'job_title' => fake()->word(),
'company_name' => fake()->word(),
'description' => fake()->sentence(),
],
// ...
]
'experience' => [
[
'job_title' => fake()->word(),
'company_name' => fake()->word(),
'description' => fake()->sentence(),
],
// ...
]
Shaung Bhone
Shaung BhoneOP15mo ago
yes I'm trying like this. It's not working. https://github.com/filamentphp/filament/discussions/8459 Still stuck
Patrick Boivin
Patrick Boivin15mo ago
Can you share your complete form and test in a Gist on Github? I'll have a look.
Patrick Boivin
Patrick Boivin15mo ago
Can you share the form code as well?
Patrick Boivin
Patrick Boivin15mo ago
@shaungbhone I think the general approach with the Repeaters in your tests is good. I mean, I'm not 100% sure but my guess is that your tests are failing because of actual validation errors. Maybe some of the dates, etc. Try to remove all validation and re-introduce it field by field. Make sure the test is passing after each step.
Shaung Bhone
Shaung BhoneOP15mo ago
Yes let me try Thank you so much.
Want results from more Discord servers?
Add your server