Skip to content

Commit

Permalink
Add test for StudentInteractionsRelationManager
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Ullyott <[email protected]>
  • Loading branch information
Orrison committed Oct 30, 2024
1 parent 5d63467 commit ca2cc2d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions app-modules/student-data-model/tests/Student/ViewStudentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\ProgramsRelationManager;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\EnrollmentsRelationManager;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\StudentEventsRelationManager;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\StudentInteractionsRelationManager;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\StudentFormSubmissionsRelationManager;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\StudentApplicationSubmissionsRelationManager;

Expand Down Expand Up @@ -165,6 +166,49 @@
->assertSeeLivewire($relationManager);
});

it('renders the StudentInteractionsRelationManager based on proper access', function () {
$user = User::factory()->licensed(Student::getLicenseType())->create();

$student = Student::factory()->create();

$user->givePermissionTo('student.view-any');
$user->givePermissionTo('student.*.view');

$user->refresh();

actingAs($user);

$relationManager = StudentInteractionsRelationManager::class;

livewire(ManageStudentInformation::class, [
'record' => $student->getKey(),
'activeRelationManager' => array_search(
$relationManager,
(new ManageStudentInformation())
->tap(fn (ManageStudentInformation $manager) => $manager->mount($student->getKey()))
->getRelationManagers()
),
])
->assertOk()
->assertDontSeeLivewire($relationManager);

$user->givePermissionTo('interaction.view-any');

$user->refresh();

livewire(ManageStudentInformation::class, [
'record' => $student->getKey(),
'activeRelationManager' => array_search(
$relationManager,
(new ManageStudentInformation())
->tap(fn (ManageStudentInformation $manager) => $manager->mount($student->getKey()))
->getRelationManagers()
),
])
->assertOk()
->assertSeeLivewire($relationManager);
});

it('renders the StudentFormSubmissionsRelationManager based on Feature access', function () {
$student = Student::factory()->create();

Expand Down

0 comments on commit ca2cc2d

Please sign in to comment.