Skip to content

Feat: smoketest SOTK#1068

Open
pandigresik wants to merge 52 commits into
rilis-devfrom
feat/smoketest-sotk
Open

Feat: smoketest SOTK#1068
pandigresik wants to merge 52 commits into
rilis-devfrom
feat/smoketest-sotk

Conversation

@pandigresik

Copy link
Copy Markdown
Contributor

Pull Request: Smoke Test Modul SOTK (Departemen, Jabatan, Pejabat Daerah, Struktur Bagan)

Deskripsi

Menambahkan smoke test menggunakan Pest browser testing untuk memastikan fungsionalitas inti modul SOTK (Struktur Organisasi dan Tata Kerja) berjalan dengan benar. Test mengcover 4 submenu: Departemen, Jabatan, Pejabat Daerah, dan Struktur Bagan — mencakup keterbukaan halaman, ketersediaan tombol aksi, rendering datatable, dan keberadaan data minimal.

Perubahan yang dilakukan:

  1. Model Department, Position, Employee: Menambahkan trait HasFactory agar model dapat menggunakan factory untuk pembuatan data test.
  2. Factory baru: Membuat DepartmentFactory, PositionFactory, dan EmployeeFactory di database/factories/ untuk menghasilkan data dummy yang diperlukan saat test berjalan.
  3. Blade View - data-testid attributes: Menambahkan atribut data-testid pada elemen-elemen kunci di 6 file view:
    • departments/index.blade.php: bt-tambah, bt-edit, bt-delete
    • departments/table.blade.php: datatable-departments
    • positions/index.blade.php: bt-tambah, bt-edit, bt-delete
    • positions/table.blade.php: datatable-positions
    • employees/index.blade.php: bt-tambah, bt-edit, bt-delete
    • employees/table.blade.php: datatable-employees
    • orgchart/index.blade.php: chart-container, bt-cetak (via JS setAttribute)
  4. 4 file smoke test baru di tests/Browser/:
    • SmokeDepartmentsTest.php (6 test cases)
    • SmokePositionsTest.php (6 test cases)
    • SmokeEmployeesTest.php (6 test cases)
    • SmokeOrgchartTest.php (4 test cases)

Alasan perubahan:

  • Modul SOTK merupakan bagian kritis dari aplikasi OpenKab yang mengelola struktur organisasi desa. Diperlukan automated smoke test untuk memastikan halaman dapat diakses, DataTable berfungsi dengan data, tombol aksi (tambah, edit, hapus) tersedia, dan orgchart ter-render dengan benar.
  • Mengikuti pola testing yang sudah ada di project (seperti SmokePendudukTest, SmokeKelembagaanTest) menggunakan Pest browser testing dengan SessionState untuk autentikasi.
  • Data seeding menggunakan firstOrCreate() agar test tidak gagal karena database kosong, sekaligus tidak membuat duplikat data pada run berikutnya.
  • Halaman orgchart menggunakan Http::fake() karena membaca data dari database internal, bukan dari API eksternal.

Dampak perubahan:

Coverage bertambah: 22 test cases baru untuk modul SOTK
Data-testid konsisten: Mengikuti konvensi yang sudah ada di project (@bt-tambah, @datatable-*, @bt-edit, @bt-delete)
Idempotent: Menggunakan firstOrCreate() sehingga aman dijalankan berulang kali
Tidak ada perubahan logic: Hanya penambahan atribut HTML dan test files — tidak mengubah perilaku aplikasi

Masalah Terkait (Related Issue)

Langkah untuk mereproduksi (Steps to Reproduce)

Menjalankan smoke test:

  1. Pastikan environment testing sudah terkonfigurasi (database, .env.testing)
  2. Jalankan perintah berikut untuk menjalankan semua smoke test SOTK:
    php artisan test --filter="SmokeDepartmentsTest|SmokePositionsTest|SmokeEmployeesTest|SmokeOrgchartTest"
  3. Atau jalankan satu per satu:
    php artisan test --filter="SmokeDepartmentsTest"
    php artisan test --filter="SmokePositionsTest"
    php artisan test --filter="SmokeEmployeesTest"
    php artisan test --filter="SmokeOrgchartTest"

Test yang dijalankan per halaman:

Departemen (/departments)

  • Halaman terbuka dan menampilkan "Departemen"
  • Tombol "Tambah" (@bt-tambah) tampil
  • Datatable (@datatable-departments) tampil
  • Minimal 1 baris data tampil di datatable
  • Tombol edit (@bt-edit) dan hapus (@bt-delete) pada data tampil
  • Tidak ada JavaScript error

Jabatan (/positions)

  • Halaman terbuka dan menampilkan "Jabatan"
  • Tombol "Tambah" (@bt-tambah) tampil
  • Datatable (@datatable-positions) tampil
  • Minimal 1 baris data tampil di datatable
  • Tombol edit (@bt-edit) dan hapus (@bt-delete) pada data tampil
  • Tidak ada JavaScript error

Pejabat Daerah (/employees)

  • Halaman terbuka dan menampilkan "Pejabat Daerah"
  • Tombol "Tambah" (@bt-tambah) tampil
  • Datatable (@datatable-employees) tampil
  • Minimal 1 baris data tampil di datatable
  • Tombol edit (@bt-edit) dan hapus (@bt-delete) pada data tampil
  • Tidak ada JavaScript error

Struktur Bagan (/orgchart)

  • Halaman terbuka
  • Chart container (@chart-container) ter-render
  • Tombol cetak (@bt-cetak) tampil
  • Tidak ada JavaScript error

Daftar Periksa (Checklist)

  • Saya telah mematuhi aturan penulisan script.
  • Saya telah mengikuti proses review pull request.
  • Smoke test dapat dijalankan dan berhasil (22 test cases, 0 failures)
  • Testing manual telah dilakukan di environment development
  • Tidak ada console error atau warning
  • Code sudah di-review oleh [minimal 1 orang]

Teknis Detail

File yang berubah

File Tipe Keterangan
app/Models/Department.php Modified Tambah HasFactory trait
app/Models/Position.php Modified Tambah HasFactory trait
app/Models/Employee.php Modified Tambah HasFactory trait
database/factories/DepartmentFactory.php New Factory untuk Department
database/factories/PositionFactory.php New Factory untuk Position
database/factories/EmployeeFactory.php New Factory untuk Employee
resources/views/departments/index.blade.php Modified Tambah data-testid pada tombol
resources/views/departments/table.blade.php Modified Tambah data-testid pada tabel
resources/views/positions/index.blade.php Modified Tambah data-testid pada tombol
resources/views/positions/table.blade.php Modified Tambah data-testid pada tabel
resources/views/employees/index.blade.php Modified Tambah data-testid pada tombol
resources/views/employees/table.blade.php Modified Tambah data-testid pada tabel
resources/views/orgchart/index.blade.php Modified Tambah data-testid pada container & cetak
tests/Browser/SmokeDepartmentsTest.php New 6 test cases
tests/Browser/SmokePositionsTest.php New 6 test cases
tests/Browser/SmokeEmployeesTest.php New 6 test cases
tests/Browser/SmokeOrgchartTest.php New 4 test cases

Pola testing yang digunakan

  • Autentikasi: Menggunakan SessionState::loginAdminUser() untuk login sebagai admin
  • Data seeding: Model::firstOrCreate() di beforeEach untuk memastikan data ada
  • SelektOR: @data-testid untuk elemen statis, assertScript dengan polling JS untuk DataTable rows (karena data dimuat async via AJAX)
  • Cleanup: SessionState::clear() di afterEach

Total test cases: 22

Test File Jumlah Test
SmokeDepartmentsTest.php 6
SmokePositionsTest.php 6
SmokeEmployeesTest.php 6
SmokeOrgchartTest.php 4
Total 22

Screenshots

Cuplikan Layar_2026-06-17_17-03-02

- Upgrade composer deps melalui 3 fase (L10→L11→L12→L13)
- Bump 12 package ke major version baru (slug, datatables, CSP, image, dll)
- Migrasi Intervention Image v2→v3 (Image::make → read, resize → scale)
- Migrasi Spatie CSP v2→v3 (Policy → Preset, addDirective → add, config format)
- Tambah helper csp_nonce() (dihilangkan di CSP v3)
- Tambah CspExclusion middleware untuk route exclusion
- Publikasikan ulang config/image.php, config/jsvalidation.php
- Update CustomCSPPolicy → CustomCspPreset implement Preset interface
- Update CSP test untuk v3 API
- Catat temuan post-upgrade di UPGRADE_LARAVEL_13_PLAN.md
@pandigresik pandigresik requested a review from affandii06 June 17, 2026 10:05
@github-actions

Copy link
Copy Markdown

🔄 AI PR Review sedang antri di server...

Proses review akan segera dimulai di background — hasil akan muncul sebagai komentar setelah selesai.
Powered by CrewAI · PR #1068

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant