Feat: Smoke test untuk menu dashboard dan dashboard demografi#1056
Open
pandigresik wants to merge 42 commits into
Open
Feat: Smoke test untuk menu dashboard dan dashboard demografi#1056pandigresik wants to merge 42 commits into
pandigresik wants to merge 42 commits into
Conversation
- 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
…upgrade/laravel-13
…upgrade/laravel-13
…upgrade/laravel-13
|
🔄 AI PR Review sedang antri di server...
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Smoke Test dengan Pest Browser (Playwright) untuk Dashboard dan Demografi
Deskripsi
Menambahkan smoke test otomatis menggunakan Pest v4 + pest-plugin-browser (Playwright) untuk memastikan fungsionalitas inti halaman Dashboard dan Dashboard Demografi berjalan dengan benar. Test menggunakan MSW (Mock Service Worker) untuk mengintersep request API eksternal dan mengembalikan data fixture, sehingga test berjalan cepat, deterministik, dan tidak bergantung pada koneksi jaringan.
Perubahan yang dilakukan:
MswSetup.php) yang mengintersep fetch/XHR requests dan mengembalikan data dari JSON fixturesSmokeLoginTest.php)SmokeDashboardTest.php)SmokeDashboardDemografiTest.php)SessionState.php(session management & quick login),FixtureReader.php(JSON fixture reader),ScreenshotHelper.php(optional screenshot capture)data-testiddi Blade templates untuk selector yang stabil dan resilientapply-patch.shuntuk menginjek MSW init script kepest-plugin-browser'sInitScript.phpvia composer hookdocs/smoke-test-browser.md) tentang arsitektur, setup, dan best practicesAlasan perubahan:
assertScriptdengan DOM queries langsung alih-alih Playwright's built-in select interactionsDampak perubahan:
✅ Smoke Test Coverage: Dashboard, Dashboard Demografi, dan Login page tercoverage oleh automated browser tests
✅ CI/CD Integration: Test bisa dijalankan di CI/CD pipeline untuk mendeteksi regressions
✅ Deterministic Testing: MSW mock memastikan test selalu menggunakan data yang konsisten
✅ data-testid Convention: Establishes testing contract antara developer dan tester melalui explicit test selectors
✅ Documentation: Panduan lengkap untuk developer lain menambahkan test baru atau route mock baru
Masalah Terkait (Related Issue)
Detail Perubahan File
Testing Infrastructure (New Files)
tests/Pest.phptests/Browser/MswSetup.phptests/Browser/SessionState.php/_pest/login/{id}, apply/clear filtertests/Browser/FixtureReader.phptests/Browser/ScreenshotHelper.phpSCREENSHOT_ON_SUCCESSenv vartests/Browser/apply-patch.shvendor/pestphp/pest-plugin-browser/src/Playwright/InitScript.phpuntuk inject MSW init scriptpublic/mockServiceWorker.jsnpx msw init)Smoke Tests (New Files)
tests/Browser/SmokeLoginTest.phptests/Browser/SmokeDashboardTest.phptests/Browser/SmokeDashboardDemografiTest.phpJSON Fixtures (New Files — 19 files)
Data mock untuk semua API endpoints yang di-intercept oleh MSW:
kabupaten.json/api/v1/statistik-web/get-list-kabupatenkecamatan-50.01.json,kecamatan-50.02.json,kecamatan-5271.json,kecamatan-5272.json/api/v1/statistik-web/get-list-kecamatan/{id}desa-50.01.01.json,desa-50.01.02.json,desa-5271010.json,desa-5271020.json/api/v1/statistik-web/get-list-desa/{id}data-website.json/api/v1/data-websitependuduk.json/api/v1/wilayah/pendudukcoordinates.json/api/v1/statistik-web/get-list-coordinatedasbor.json/api/v1/dasborstatistik-penduduk-*.json(9 files)/api/v1/statistik/penduduk?filter[id]={key}View Changes (data-testid additions)
Penambahan
data-testidattributes untuk testing contract:resources/views/components/wilayah_filter.blade.phpfilter-kabupaten,filter-kecamatan,filter-desa,bt-filter,bt-clear-filterresources/views/dasbor/category_item.blade.phpsummary-card-{key},summary-value-{key},summary-label-{key},summary-link-{key}resources/views/dasbor/summary.blade.phpsummary-blockresources/views/dasbor/peta.blade.phppetaresources/views/dasbor/tabel_penduduk.blade.phptabel-penduduk-blockresources/views/dasbor/data-desa.blade.phpsummary-pendudukresources/views/demografi/chart_item.blade.phpchart-item-{key},chart-title-{key},chart-content-{key}Configuration & Dependency Changes
composer.jsonpestphp/pest:^4.0,pestphp/pest-plugin-browser:^4.0; upgrade PHP ke^8.4, Laravel ke^13.0; tambah composer hookapply-patch.shpackage.jsonmsw:^2.14.6,playwright:^1.60.0; tambah configmsw.workerDirectory.gitignoretests/Browser/Screenshots/,tests/Browser/.session_state.json,public/mockServiceWorker.jsroutes/web.php/_pest/login/{userId}untuk testing; perbaikan route names yang duplikatDocumentation (New File)
docs/smoke-test-browser.mdArsitektur Testing
Request Flow during Tests:
Teknis Detail
MSW Route Matching
MSW menggunakan dua jenis route matching:
Exact Routes — URL statis tanpa parameter:
Regex Routes — URL dengan parameter dinamik:
Select2 Dropdown Testing
Karena dropdown menggunakan Select2 (hidden
<select>+ custom UI), testing menggunakan JavaScript DOM queries langsung:Chart Rendering Detection
Test mendeteksi chart rendering melalui phase-based polling:
Vendor Patching
apply-patch.shdiperlukan karenapest-plugin-browsertidak menyediakan hook untuk menambahkan init script custom. Script ini:InitScript.phporiginal keInitScript.php.bakInitScript.phpuntuk memanggilMswSetup::getInitScriptJs()post-install-cmd,post-update-cmd)Dependencies yang ditambahkan
PHP (Composer)
pestphp/pest:^4.0— Pest PHP testing frameworkpestphp/pest-plugin-browser:^4.0— Browser testing via Playwrightreact/http:^0.4.0— HTTP server untuk Pest browserJavaScript (npm)
msw:^2.14.6— Mock Service Worker untuk intercept API callsplaywright:^1.60.0— Browser automationUpgrades
^8.1->^8.4^10.48->^13.0^10.1->^12.0Langkah untuk Mereproduksi (Steps to Reproduce)
Setup:
feat/smoketestcomposer install(akan otomatis menjalankanapply-patch.sh)npm install && npx msw init public/ --save.env.testingdari.envdan setAPP_ENV=testingMenjalankan Smoke Tests:
Hasil yang diharapkan:
tests/Browser/Screenshots/)Daftar Periksa (Checklist)
Testing
Automated Testing — Smoke Tests
SmokeLoginTest.phpSmokeDashboardTest.phpSmokeDashboardDemografiTest.phpChecklist Fungsionalitas (sesuai Issue #1055)
Menu Dashboard
Menu Dashboard Demografi
Breaking Changes
Tidak ada breaking changes untuk functionality aplikasi. Perubahan yang bersifat breaking:
Migration Guide
composer updateuntuk mendapatkan dependencies barunpx msw init public/ --saveuntuk generate MSW service workerbash tests/Browser/apply-patch.sh(otomatis via composer hook)References
Catatan tambahan:
renders chart content from fixture datadiSmokeDashboardDemografiTest.phpmemerlukan pendekatan khusus karena chart loading memiliki 3 phase: initial canvas (HTML) → "Sedang memuat data..." (AJAX beforeSend) → canvas baru (AJAX success). Polling menunggu transisi phase 1→2→3 untuk memastikan AJAX telah selesai sebelum assertion dijalankan.document.querySelectorAll) karena Playwright's built-in select methods tidak kompatibel dengan Select2's hidden<select>pattern.apply-patch.sh) karenapest-plugin-browserbelum menyediakan hook untuk custom init scripts. Long-term solution: contribute PR ke pest-plugin-browser untuk menambahkanpest()->browser()->initScript()API.Screenshots / Video
php artisan test --testsuite=Browser