feat: testing suite and bug fixes (Fasa 11)

- AuthTest, ProgramTest, CheckinTest, QuestionnaireTest, CertificateTest — 19 feature tests, 35 total pass
- ProgramFactory with published() state
- UserFactory: is_admin=true default, nonAdmin() state
- Fix attendance_source column name in StatisticsController (was: source)
- Fix route(dashboard) → route(admin.dashboard) in all Breeze auth controllers
- Remove irrelevant Breeze boilerplate tests (Profile, Example, Registration)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Saufi
2026-05-17 00:23:38 +08:00
parent a41ff59009
commit 700fbd1bcc
19 changed files with 493 additions and 187 deletions

View File

@@ -0,0 +1,61 @@
<?php
namespace Tests\Feature;
use App\Models\Program;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class ProgramTest extends TestCase
{
use RefreshDatabase;
private User $admin;
protected function setUp(): void
{
parent::setUp();
$this->admin = User::factory()->create();
$this->actingAs($this->admin);
}
public function test_admin_can_view_programs_list(): void
{
$this->get('/admin/programs')->assertOk();
}
public function test_admin_can_create_a_program(): void
{
$this->post('/admin/programs', [
'title' => 'Program Ujian',
'organizer' => 'Jabatan Ujian',
'location' => 'Putrajaya',
'start_date' => '2025-06-01',
'end_date' => '2025-06-01',
'allow_walk_in' => true,
'default_staff_session' => 'pagi',
'default_external_session' => 'pagi',
])->assertRedirect();
$this->assertDatabaseHas('programs', ['title' => 'Program Ujian']);
}
public function test_admin_can_publish_a_draft_program(): void
{
$program = Program::factory()->create(['status' => 'draft', 'created_by' => $this->admin->id]);
$this->post("/admin/programs/{$program->uuid}/publish")->assertRedirect();
$this->assertEquals('published', $program->fresh()->status);
}
public function test_admin_can_delete_program_with_no_attendances(): void
{
$program = Program::factory()->create(['status' => 'draft', 'created_by' => $this->admin->id]);
$this->delete("/admin/programs/{$program->uuid}")->assertRedirect();
$this->assertDatabaseMissing('programs', ['id' => $program->id]);
}
}