Infolist ViewResource Test

Please who can help with test for ViewPage that uses infolist instead of the default disabled form view.
6 Replies
LeandroFerreira
LeandroFerreira11mo ago
What would you like to test?
Hussain4real
Hussain4realOP11mo ago
this is the test:
it('can retrieve data for view page', function () {
$student = Student::factory()->create();
$retrievedData = Livewire::test(StudentResource\Pages\ViewStudent::class, [
'record' => $student->getRouteKey(),
])
->assertViewHas([
'user_id' => $student->user->getKey(),
'guardian_id' => $student->guardian->getKey(),
'grade_id' => $student->grade->getKey(),
'term_id' => $student->term->getKey(),
'ID_number' => $student->ID_number,
'admission_number' => $student->admission_number,
'date_of_birth' => $student->date_of_birth,
'gender' => 'male',
'address' => $student->address,
'place_of_birth' => $student->place_of_birth,
'religion' => $student->religion,
'nationality' => $student->nationality,
'first_language' => $student->first_language,
]);
});
it('can retrieve data for view page', function () {
$student = Student::factory()->create();
$retrievedData = Livewire::test(StudentResource\Pages\ViewStudent::class, [
'record' => $student->getRouteKey(),
])
->assertViewHas([
'user_id' => $student->user->getKey(),
'guardian_id' => $student->guardian->getKey(),
'grade_id' => $student->grade->getKey(),
'term_id' => $student->term->getKey(),
'ID_number' => $student->ID_number,
'admission_number' => $student->admission_number,
'date_of_birth' => $student->date_of_birth,
'gender' => 'male',
'address' => $student->address,
'place_of_birth' => $student->place_of_birth,
'religion' => $student->religion,
'nationality' => $student->nationality,
'first_language' => $student->first_language,
]);
});
it works if i remove the infolist function on my Resource
LeandroFerreira
LeandroFerreira11mo ago
you could use ->assertSee()
Hussain4real
Hussain4realOP11mo ago
then pass in the ViewStudent component?
LeandroFerreira
LeandroFerreira11mo ago
comment the assertViewHas and try it
->assertSee($student->admission_number)
->assertSee($student->admission_number)
Hussain4real
Hussain4realOP11mo ago
this worked Thanks a lot
Want results from more Discord servers?
Add your server