Matlamat / Goal
Minta AI menjana ujian Playwright untuk sempadan kuantiti, simpan dan jalankan pada ShopFast, baca kegagalan, kemudian jana ujian API daripada kontrak OpenAPI.
Ask the AI for a Playwright test for the quantity boundary, save and run it against ShopFast, read the failure, then generate API tests from the OpenAPI contract.
Peraturan data: guna data sintetik ShopFast sahaja. Model percuma dihoskan di luar negara. Output AI ialah draf yang mesti disemak manusia.
Langkah demi langkah dengan tangkapan skrin sebenar
Jalankan /gen-ui-test untuk kes sempadan kuantiti 10. AI membaca dokumen dahulu dan mungkin berhenti seketika pada Preparing write. Apabila dialog Permission required muncul, baca pratonton dan pilih Allow once.
Run /gen-ui-test for the quantity 10 boundary case. The AI reads the documents first and may pause at Preparing write. When the Permission required dialog appears, read the preview and choose Allow once.
/gen-ui-test TC-CHK-004 tambah P002 kuantiti 10 ke troli dan semak troli menerima kuantiti 10 (REQ-CHK-01)

Allow once. Ujian dan arahan disimpan dalam outputs/m05-ui-test.md.
Allow once. The test and instructions are saved in outputs/m05-ui-test.md.
Allow once (Enter)

Simpan blok kod sebagai fail spec dan jalankan. Kegagalan di sini ialah penemuan sebenar untuk dihasilkan semula dan dilaporkan dalam Modul 6.
Save the code block as a spec file and run it. A failure here is a real finding to reproduce and report in Module 6.
$md = Get-Content outputs\m05-ui-test.md -Raw [regex]::Match($md, '(?s)```(?:js|javascript)\s*(.*?)```').Groups[1].Value | Set-Content -Encoding utf8 shopfast\tests\ui\m05-senario.spec.js cd shopfast npx playwright test tests/ui/m05-senario.spec.js --reporter=list

Kembali ke opencode, jalankan /gen-api-tests daripada kontrak OpenAPI. AI membaca dokumen dahulu dan mungkin berhenti seketika pada Preparing write. Apabila dialog Permission required muncul, baca pratonton dan pilih Allow once.
Back in opencode, run /gen-api-tests from the OpenAPI contract. The AI reads the documents first and may pause at Preparing write. When the Permission required dialog appears, read the preview and choose Allow once.
/gen-api-tests REQ-CHK-01 REQ-CHK-03

Allow once. Semak ujian API yang dijana sebelum digunakan.
Allow once. Review the generated API tests before using them.
Allow once (Enter)

Semakan manusia / Human check
- Ujian memilih elemen melalui data-testid yang benar-benar wujud
The test selects elements by data-testid that really exist - Ujian yang gagal ialah penemuan: hasilkan semula secara manual sebelum log pepijat
A failing test is a finding: reproduce it by hand before logging a bug - Ujian yang dijana disemak seperti kod sebelum di-commit
Generated tests are reviewed like code before they are committed
Contoh output sebenar
Jawapan AI berbeza setiap larian. Bandingkan struktur dan semak kandungan.
Jika ada masalah / Troubleshooting
| Masalah | Tindakan |
|---|---|
| opencode is not recognised | Close and reopen PowerShell so PATH refreshes. Still failing: powershell -ExecutionPolicy Bypass -File .\setup\install-opencode.ps1 -Portable |
| Scripts are disabled on this system | Set-ExecutionPolicy -Scope CurrentUser RemoteSigned, or run opencode.cmd instead of opencode |
| The model is slow or stops | Wait up to 2 minutes. Press Esc to interrupt, then send the prompt again. Try another free model with /models |
| Permission required dialog | Read the preview. Choose Allow once for files in outputs/. Reject anything outside the lab folder |
| File or command not found | Check the status bar path ends with \lab. Commands and @files are relative to the lab folder |
| Answer uses Indonesian words or dashes | Reply: Ikut AGENTS.md peraturan 1 dan 14, tulis semula dalam Bahasa Melayu Malaysia |
| Network or proxy error | $env:HTTPS_PROXY = "http://proxy:port" and $env:NO_PROXY = "localhost,127.0.0.1" before starting opencode |
| Port 3000 already in use | $env:PORT = 3001 before npm start, and use http://localhost:3001 |