Dev branch
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Permission;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
|
||||
it('shows a single report page', function (): void {
|
||||
$user = User::factory()->create();
|
||||
$role = Role::create(['name' => 'Reporter', 'slug' => 'reporter']);
|
||||
$perm = Permission::firstOrCreate(['slug' => 'reports-view'], ['name' => 'Reports View']);
|
||||
$role->permissions()->syncWithoutDetaching($perm->id);
|
||||
$role->users()->syncWithoutDetaching($user->id);
|
||||
$this->actingAs($user);
|
||||
|
||||
$response = $this->get(route('reports.show', 'field-jobs-completed'));
|
||||
$response->assertSuccessful();
|
||||
$response->assertInertia(fn ($page) => $page
|
||||
->component('Reports/Show')
|
||||
->where('slug', 'field-jobs-completed')
|
||||
->has('inputs')
|
||||
->has('columns')
|
||||
);
|
||||
});
|
||||
|
||||
it('returns data json for report', function (): void {
|
||||
$user = User::factory()->create();
|
||||
$role = Role::create(['name' => 'Reporter', 'slug' => 'reporter']);
|
||||
$perm = Permission::firstOrCreate(['slug' => 'reports-view'], ['name' => 'Reports View']);
|
||||
$role->permissions()->syncWithoutDetaching($perm->id);
|
||||
$role->users()->syncWithoutDetaching($user->id);
|
||||
$this->actingAs($user);
|
||||
|
||||
$response = $this->get(route('reports.data', 'field-jobs-completed'));
|
||||
$response->assertSuccessful();
|
||||
$json = $response->json();
|
||||
expect($json)->toHaveKeys(['data', 'total', 'current_page', 'last_page']);
|
||||
});
|
||||
Reference in New Issue
Block a user