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

77 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Tests\Feature\Mahasiswa;
use Tests\Concerns\FakesLegacyDatabase;
use Tests\Concerns\InspectsHtml;
use Tests\TestCase;
/** Dashboard mahasiswa dengan akun DB lama: identitas dan nilai asli, tanpa bagian prototipe. */
class LegacyDashboardTest extends TestCase
{
use FakesLegacyDatabase;
use InspectsHtml;
protected function setUp(): void
{
parent::setUp();
$this->useLegacyDatabase();
$this->post(route('login.store'), ['username' => 'D1041191001', 'password' => 'rahasia-mhs'])
->assertRedirect(route('mahasiswa.dashboard'));
}
/** @return list<string> */
private function statValues(): array
{
$nodes = $this->dom($this->get(route('mahasiswa.dashboard')))->query('//*[contains(@class, "stat__value")]');
return array_map(fn ($node): string => trim($node->textContent), iterator_to_array($nodes));
}
public function test_welcome_shows_identity_from_legacy_database(): void
{
$response = $this->get(route('mahasiswa.dashboard'))->assertOk();
$headings = $this->dom($response)->query('//h1');
$this->assertSame(1, $headings->length);
$this->assertSame('Selamat Datang, Rina Lestari!', trim($headings->item(0)->textContent));
$response->assertSee('D1041191001')
->assertSee('Teknik Informatika')
->assertSee('Fakultas Teknik')
->assertSee('2019');
}
public function test_stats_and_latest_grades_come_from_real_grades(): void
{
$this->seedLegacyGrades();
// IPK, SKS lulus, semester terakhir (pendek 2019/2020 Genap), IPS terakhir.
$this->assertSame(['3,07', '8', 'Pendek 2019/2020 Genap', '2,00'], $this->statValues());
$this->get(route('mahasiswa.dashboard'))
->assertSee('Dari 11 SKS ditempuh')
->assertSee('Nilai semester terakhir')
->assertSee('Etika Profesi');
}
public function test_prototype_sections_are_hidden(): void
{
$this->seedLegacyGrades();
$this->get(route('mahasiswa.dashboard'))->assertOk()
->assertDontSee('Status KRS')
->assertDontSee('Kuliah hari ini')
->assertDontSee('Tagihan')
->assertDontSee('Pengumuman terbaru')
->assertDontSee('Nilai Mahasiswa Lain');
}
public function test_student_without_grades_sees_empty_values(): void
{
$this->assertSame(['–', '0', '–', '–'], $this->statValues());
$this->get(route('mahasiswa.dashboard'))->assertSee('Belum ada nilai');
}
}