f855f7e027
- Add /dashboard route (all authenticated roles)
- Add dashboard view with Chart.js 4.4:
- 4 stat cards (ibadah, miskin, jiwa, % terjangkau)
- Donut chart: ibadah per jenis
- Horizontal bar chart: miskin per kondisi rumah
- Gap Analysis: Turf.js coverage computation, doughnut chart,
per-ibadah coverage table sorted by KK count, uncovered family list
- esc() helper applied to all user-data innerHTML
- Add Dashboard nav link to map, data, and admin views
- 5 new tests: unauthenticated redirect + all 4 roles can access
- Mark K-02 and K-03 complete in missing_features.md
- Update README with new page and feature section
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class DashboardTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
foreach (['administrator', 'pengurus_ibadah', 'petugas_pendataan', 'pemangku_kebijakan'] as $role) {
|
|
\Spatie\Permission\Models\Role::create(['name' => $role, 'guard_name' => 'web']);
|
|
}
|
|
}
|
|
|
|
private function createUser(string $role): User
|
|
{
|
|
$user = User::factory()->create();
|
|
$user->assignRole($role);
|
|
return $user;
|
|
}
|
|
|
|
public function test_unauthenticated_cannot_access_dashboard(): void
|
|
{
|
|
$this->get('/dashboard')->assertRedirect('/login');
|
|
}
|
|
|
|
public function test_administrator_can_access_dashboard(): void
|
|
{
|
|
$this->actingAs($this->createUser('administrator'));
|
|
$this->get('/dashboard')->assertOk();
|
|
}
|
|
|
|
public function test_pengurus_ibadah_can_access_dashboard(): void
|
|
{
|
|
$this->actingAs($this->createUser('pengurus_ibadah'));
|
|
$this->get('/dashboard')->assertOk();
|
|
}
|
|
|
|
public function test_petugas_pendataan_can_access_dashboard(): void
|
|
{
|
|
$this->actingAs($this->createUser('petugas_pendataan'));
|
|
$this->get('/dashboard')->assertOk();
|
|
}
|
|
|
|
public function test_pemangku_kebijakan_can_access_dashboard(): void
|
|
{
|
|
$this->actingAs($this->createUser('pemangku_kebijakan'));
|
|
$this->get('/dashboard')->assertOk();
|
|
}
|
|
}
|