first commit
This commit is contained in:
64
tests/Feature/ReminderTest.php
Normal file
64
tests/Feature/ReminderTest.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\DataCentre;
|
||||
use App\Models\ReportingCycle;
|
||||
use App\Models\Submission;
|
||||
use App\Services\SubmissionWorkflowService;
|
||||
use Database\Seeders\ChecklistTemplateSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ReminderTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->seedRolesAndPermissions();
|
||||
$this->seed(ChecklistTemplateSeeder::class);
|
||||
}
|
||||
|
||||
public function test_reminder_list_removes_consultant_after_submission(): void
|
||||
{
|
||||
$jpp = $this->makeUserWithRole('Pegawai JPP');
|
||||
[$cUser, $consultant] = $this->makeConsultantUser();
|
||||
$cycle = ReportingCycle::factory()->create();
|
||||
$dc = DataCentre::factory()->create(['current_consultant_id' => $consultant->id]);
|
||||
|
||||
// Pada mulanya pusat data muncul dalam senarai peringatan.
|
||||
$response = $this->actingAs($jpp)->get(route('reminders.index', ['cycle' => $cycle->id]));
|
||||
$response->assertOk();
|
||||
$response->assertSee($dc->nama_pusat_data);
|
||||
|
||||
// Perunding hantar serahan.
|
||||
$submission = Submission::create([
|
||||
'data_centre_id' => $dc->id,
|
||||
'reporting_cycle_id' => $cycle->id,
|
||||
'consultant_id' => $consultant->id,
|
||||
'status' => 'baru',
|
||||
'submitted_at' => now(),
|
||||
]);
|
||||
|
||||
// Selepas hantar, pusat data dikeluarkan daripada senarai peringatan.
|
||||
$response = $this->actingAs($jpp)->get(route('reminders.index', ['cycle' => $cycle->id]));
|
||||
$response->assertOk();
|
||||
$response->assertDontSee($dc->nama_pusat_data);
|
||||
}
|
||||
|
||||
public function test_draft_submission_still_appears_in_reminder_list(): void
|
||||
{
|
||||
$jpp = $this->makeUserWithRole('Pegawai JPP');
|
||||
[$cUser, $consultant] = $this->makeConsultantUser();
|
||||
$cycle = ReportingCycle::factory()->create();
|
||||
$dc = DataCentre::factory()->create(['current_consultant_id' => $consultant->id]);
|
||||
|
||||
// Hanya draf (belum hantar) — masih dalam senarai peringatan.
|
||||
app(SubmissionWorkflowService::class)->findOrCreateDraft($dc, $cycle);
|
||||
|
||||
$response = $this->actingAs($jpp)->get(route('reminders.index', ['cycle' => $cycle->id]));
|
||||
$response->assertSee($dc->nama_pusat_data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user