121 lines
5.6 KiB
PHP
121 lines
5.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Operator;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Testing\TestResponse;
|
|
use Tests\Concerns\FakesLegacyDatabase;
|
|
use Tests\Concerns\InspectsHtml;
|
|
use Tests\TestCase;
|
|
|
|
/** Dashboard operator dari DB lama; data dari seedLegacyOverview(). */
|
|
class LegacyDashboardTest extends TestCase
|
|
{
|
|
use FakesLegacyDatabase;
|
|
use InspectsHtml;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
$this->useLegacyDatabase();
|
|
$this->post(route('login.store'), ['username' => '198001012005011001', 'password' => 'rahasia-staf'])
|
|
->assertRedirect(route('operator.dashboard'));
|
|
}
|
|
|
|
/** @return list<string> sel baris tabel berjudul $row di dalam tabel berlabel $table */
|
|
private function row(TestResponse $response, string $table, string $row): array
|
|
{
|
|
$cells = $this->dom($response)->query("//*[@aria-label='{$table}']//tr[th[normalize-space()='{$row}']]/td");
|
|
|
|
return array_map(fn ($cell): string => $this->textOf($cell), iterator_to_array($cells));
|
|
}
|
|
|
|
/** @return list<string> */
|
|
private function optionLabels(TestResponse $response, string $name): array
|
|
{
|
|
$nodes = $this->dom($response)->query("//select[@name='{$name}']/option");
|
|
|
|
return array_map(fn ($node): string => $this->textOf($node), iterator_to_array($nodes));
|
|
}
|
|
|
|
public function test_dashboard_summarises_the_operators_programs(): void
|
|
{
|
|
$this->seedLegacyOverview();
|
|
|
|
$response = $this->get(route('operator.dashboard'))->assertOk()
|
|
->assertSee('Selamat Datang, Dr. Budi Santoso, S.T., M.T.!')
|
|
->assertSee('Ringkasan berikut diambil dari data akademik 2 program studi yang Anda kelola.')
|
|
->assertSee('Naik 1 dari 2019/2020 Genap')
|
|
->assertSee('3,00')
|
|
->assertSee('Dari 2 mahasiswa yang IPS-nya sudah dihitung')
|
|
->assertSee('Angkatan 2020')
|
|
->assertSee('Pada semester ini')
|
|
->assertSee('1 mahasiswa memiliki KRS yang belum disetujui')
|
|
->assertSee('2 mahasiswa aktif belum memiliki status semester')
|
|
->assertSee('1 kelas berpeserta belum memiliki jadwal')
|
|
->assertSee('1 kelas belum menerbitkan nilai')
|
|
->assertSee('Pengisian dibuka')
|
|
->assertSee('3 dari 3')
|
|
->assertSee('1 mahasiswa masih menunggu persetujuan dosen pembimbing akademik.')
|
|
->assertDontSee('data contoh')
|
|
->assertDontSee('Belum ada berita');
|
|
|
|
// Hanya semester reguler sampai periode aktif.
|
|
$this->assertSame(['2020/2021 Ganjil', '2019/2020 Genap'], $this->optionLabels($response, 'periode'));
|
|
$this->assertSame(['Semua program studi', 'Teknik Informatika', 'Teknik Sipil'], $this->optionLabels($response, 'prodi'));
|
|
|
|
// Aktif, cuti, non aktif, lulus, keluar, belum berstatus, total.
|
|
$this->assertSame(['1', '1', '0', '1', '0', '1', '4'], $this->row($response, 'AKM per angkatan', '2019'));
|
|
$this->assertSame(['2', '0', '0', '0', '0', '1', '3'], $this->row($response, 'AKM per angkatan', '2020'));
|
|
$this->assertSame([], $this->row($response, 'AKM per angkatan', '2021'));
|
|
// Aktif, cuti, non aktif, lulus, belum berstatus, mahasiswa baru.
|
|
$this->assertSame(['2', '1', '0', '1', '1', '1'], $this->row($response, 'AKM per program studi', 'Teknik Informatika'));
|
|
$this->assertSame(['1', '0', '0', '0', '1', '2'], $this->row($response, 'AKM per program studi', 'Teknik Sipil'));
|
|
}
|
|
|
|
public function test_program_filter_narrows_the_summary(): void
|
|
{
|
|
$this->seedLegacyOverview();
|
|
|
|
$response = $this->get(route('operator.dashboard', ['prodi' => 22]))->assertOk()
|
|
->assertSee('Ringkasan berikut diambil dari data akademik program studi Teknik Sipil.')
|
|
->assertSee('Naik 1 dari 2019/2020 Genap')
|
|
->assertSee('1 mahasiswa aktif belum memiliki status semester')
|
|
->assertSee('Masa pengisian KRS belum diatur untuk 2020/2021 Ganjil.')
|
|
->assertDontSee('KRS yang belum disetujui')
|
|
->assertDontSee('Pengisian dibuka');
|
|
|
|
$this->assertSame([], $this->row($response, 'AKM per program studi', 'Teknik Informatika'));
|
|
$this->assertSame('22', $this->attr($this->dom($response)->query("//select[@name='prodi']/option[@selected]"), 'value'));
|
|
}
|
|
|
|
public function test_earlier_period_and_invalid_filters(): void
|
|
{
|
|
$this->seedLegacyOverview();
|
|
|
|
$this->get(route('operator.dashboard', ['periode' => 365]))->assertOk()
|
|
->assertSee('Statistik mahasiswa 2019/2020 Genap')
|
|
->assertSee('Berstatus aktif semester ini')
|
|
->assertSee('Belum ada kelulusan tercatat')
|
|
->assertSee('IPS semester ini belum dihitung');
|
|
|
|
// Periode di luar daftar (belum berjalan) dan prodi milik akun lain diabaikan.
|
|
$response = $this->get(route('operator.dashboard', ['periode' => 371, 'prodi' => 99]))->assertOk()
|
|
->assertSee('Statistik mahasiswa 2020/2021 Ganjil')
|
|
->assertSee('2 program studi yang Anda kelola');
|
|
$this->assertSame('368', $this->attr($this->dom($response)->query("//select[@name='periode']/option[@selected]"), 'value'));
|
|
}
|
|
|
|
public function test_account_without_programs_sees_empty_state(): void
|
|
{
|
|
$this->seedLegacyOverview();
|
|
DB::connection('untan')->table('t_unituser')->whereNotNull('idprogdi')->delete();
|
|
|
|
$this->get(route('operator.dashboard'))->assertOk()
|
|
->assertSee('Selamat Datang, Dr. Budi Santoso, S.T., M.T.!')
|
|
->assertSee('Akun belum terhubung ke program studi')
|
|
->assertDontSee('Mahasiswa aktif');
|
|
}
|
|
}
|