Skip to content

Commit

Permalink
Test for StudentTasksRelationManager
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 de77989 commit 95d3c5f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 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\StudentFilesRelationManager;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\StudentTasksRelationManager;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\StudentAlertsRelationManager;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\StudentEventsRelationManager;
use AdvisingApp\StudentDataModel\Filament\Resources\StudentResource\RelationManagers\StudentEngagementRelationManager;
Expand Down Expand Up @@ -311,6 +312,45 @@
->assertSeeLivewire($relationManager);
});

it('renders the StudentTasksRelationManager 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');

actingAs($user);

$relationManager = StudentTasksRelationManager::class;

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

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

livewire(ViewStudent::class, [
'record' => $student->getKey(),
'activeRelationManager' => array_search(
$relationManager,
(new ViewStudent())
->tap(fn (ViewStudent $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 95d3c5f

Please sign in to comment.