Files
siakad/tests/Feature/Mahasiswa/LegacyKhsTest.php
T

104 lines
3.2 KiB
PHP

<?php
namespace Tests\Feature\Mahasiswa;
use Tests\Concerns\FakesLegacyDatabase;
use Tests\Concerns\InspectsHtml;
use Tests\TestCase;
/** KHS dari nilai asli DB lama (t_kst) untuk mahasiswa yang masuk lewat provider legacy. */
class LegacyKhsTest extends TestCase
{
use FakesLegacyDatabase;
use InspectsHtml;
protected function setUp(): void
{
parent::setUp();
$this->useLegacyDatabase();
}
private function login(): void
{
$this->post(route('login.store'), ['username' => 'D1041191001', 'password' => 'rahasia-mhs'])
->assertRedirect(route('mahasiswa.dashboard'));
}
public function test_latest_semester_is_shown_by_default(): void
{
$this->seedLegacyGrades();
$this->login();
$response = $this->get(route('mahasiswa.khs'))->assertOk()
->assertSee('Etika Profesi')
->assertSee('2019/2020 Genap (pendek)')
->assertSee('3,07');
$active = $this->dom($response)->query('//a[@aria-current="page" and contains(@href, "semester=366")]');
$this->assertSame(1, $active->length);
$this->assertSame('Pendek 2019/2020 Genap', trim($active->item(0)->textContent));
}
public function test_semester_numbers_and_ips_follow_legacy_rules(): void
{
$this->seedLegacyGrades();
$this->login();
$this->get(route('mahasiswa.khs', ['semester' => 362]))->assertOk()
->assertSee('Semester 1')
->assertSee('Semester 2')
->assertSee('Algoritma')
->assertSee('72,50')
->assertSee('IPS 3,60');
// (3 SKS x 3,25 + 2 SKS belum terbit x 0) / 5 SKS
$this->get(route('mahasiswa.khs', ['semester' => 365]))->assertOk()
->assertSee('Jaringan Komputer')
->assertSee('IPS 1,95')
->assertSee('1 nilai belum terbit')
->assertDontSee('Skripsi')
->assertDontSee('Statistika');
}
public function test_unpublished_grade_is_hidden(): void
{
$this->seedLegacyGrades();
$this->login();
$response = $this->get(route('mahasiswa.khs', ['semester' => 365]));
$row = $this->dom($response)->query('//tr[td[contains(., "Kalkulus")]]')->item(0);
$this->assertNotNull($row);
$this->assertStringContainsString('Belum terbit', $row->textContent);
$this->assertStringNotContainsString('91', $row->textContent);
}
public function test_other_students_grades_are_never_shown(): void
{
$this->seedLegacyGrades();
$this->login();
foreach ([null, 362, 365, 366] as $semester) {
$this->get(route('mahasiswa.khs', array_filter(['semester' => $semester])))->assertDontSee('Nilai Mahasiswa Lain');
}
}
public function test_unknown_semester_falls_back_to_latest(): void
{
$this->seedLegacyGrades();
$this->login();
$this->get(route('mahasiswa.khs', ['semester' => 999]))->assertOk()->assertSee('Etika Profesi');
}
public function test_student_without_grades_sees_empty_state(): void
{
$this->login();
$this->get(route('mahasiswa.khs'))->assertOk()
->assertSee('Belum ada nilai')
->assertDontSee('Cetak');
}
}