8.1 KiB
8.1 KiB
Acceptance Tests
Purpose
Comprehensive test catalog derived from the current codebase. Each test is runnable in Simulation and described for Real Box hardware. Behaviors not implemented are explicitly marked.
Prerequisites
- Repo root
- Python 3
- Box API running for Simulation:
python3 box/main.py run - GUI optional:
cd gui && npm run dev
Step-by-step
Use the tests below in order or individually.
Test A: Box Start & box_id
- Goal
- Verify box_id is created once and persists.
- Preconditions
- Simulation:
box/data/box.jsonmay be missing. - Real Box: storage is empty or fresh install.
- Procedure – Simulation / Emulation
- Start Box:
python3 box/main.py run
- Check box_id in API:
curl http://127.0.0.1:8000/status
- Inspect file:
cat box/data/box.json
- Procedure – Real Box (Hardware)
- Power on device.
- Open status UI (if available) or API endpoint.
- Expected Result
/statuscontainsbox_idwith formatklangkiste-<10 chars a-z0-9>.box/data/box.jsoncontainsbox_idand is stable across restarts.
- Deviations / Troubleshooting
box_idmissing: check write permissions forbox/data/.box_idchanges: indicates manual deletion ofbox/data/box.json.
Test B: WLAN Ersteinrichtung (Setup WebGUI)
- Goal
- Configure WiFi profile via setup UI and reach WIFI_ONLINE.
- Preconditions
- No WiFi profiles stored.
- Procedure – Simulation / Emulation
- Reset WiFi profiles:
curl -X POST http://127.0.0.1:8000/command \
-H "Content-Type: application/json" \
-d '{"command":"wifi_reset"}'
- Open Setup UI:
http://127.0.0.1:9000/setup
- Choose SSID and enter password, click "Verbinden".
- Check status:
curl http://127.0.0.1:8000/status
- Procedure – Real Box (Hardware)
- Power on device.
- Connect to device AP SSID (not implemented in code).
- Open setup page and submit WiFi credentials.
- Expected Result
wifi_state = WIFI_ONLINEconnected_ssidmatches selected SSIDwifi_profiles_countincrements
- Deviations / Troubleshooting
- Setup UI unreachable: port 9000 occupied or Box not running.
- Not testable with current code: AP SSID and real WiFi connect.
Test C: Persistenz & Neustart
- Goal
- Ensure resume state and WiFi profiles persist across restarts.
- Preconditions
- At least one WiFi profile stored.
- Playback started once.
- Procedure – Simulation / Emulation
- Add WiFi profile (if needed):
curl -X POST http://127.0.0.1:8000/command \
-H "Content-Type: application/json" \
-d '{"command":"wifi_add_profile","payload":{"ssid":"HomeWiFi","password":"secret","priority":10}}'
- Start playback:
curl -X POST http://127.0.0.1:8000/command \
-H "Content-Type: application/json" \
-d '{"command":"nfc_on","payload":{"uid":"UID_1"}}'
- Stop playback:
curl -X POST http://127.0.0.1:8000/command \
-H "Content-Type: application/json" \
-d '{"command":"nfc_off","payload":{"uid":"UID_1"}}'
- Restart Box process.
- Check status:
curl http://127.0.0.1:8000/status
- Procedure – Real Box (Hardware)
- Start playback via NFC.
- Power cycle device.
- Verify WiFi profile and resume state persist.
- Expected Result
box/data/state.jsoncontainsresume.box/data/secrets.encexists and contains profiles (encrypted).- After restart,
wifi_stateis not UNCONFIGURED.
- Deviations / Troubleshooting
- Resume missing: check
box/data/state.json. - WiFi profiles missing: check
box/data/secrets.enccreation.
Test D: HTTP API Status & Commands
- Goal
- Verify /status and /command are functional.
- Preconditions
- Box running.
- Procedure – Simulation / Emulation
- Status:
curl http://127.0.0.1:8000/status
- Command:
curl -X POST http://127.0.0.1:8000/command \
-H "Content-Type: application/json" \
-d '{"command":"play_pause"}'
- Procedure – Real Box (Hardware)
- Same as above once API is reachable in real network.
- Expected Result
- HTTP 200 responses.
/statusfields updated after commands.
- Deviations / Troubleshooting
- CORS errors: ensure API is running.
- 400 errors: check payload requirements.
Test E: GUI Steuerung
- Goal
- Verify GUI can control playback and display status.
- Preconditions
- Box running on 127.0.0.1:8000.
- GUI running on 127.0.0.1:5174.
- Procedure – Simulation / Emulation
- Open GUI:
http://127.0.0.1:5174
- Click Play / Pause, Next, Prev, Vol +, Vol -.
- Click NFC UID_1 ON/OFF.
- Watch status refresh (polling every 1s).
- Procedure – Real Box (Hardware)
- Use GUI from another device pointing to Box IP.
- Expected Result
/statuschanges after each button.- GUI shows updated status and last_error if present.
- Deviations / Troubleshooting
- GUI shows "Failed to fetch": verify VITE_BOX_API_URL.
Test F: Playback & NFC
- Goal
- Verify NFC starts playback from tags.
- Preconditions
- Tags exist in
box/data/box.json. - Media exists under
box/data/media.
- Procedure – Simulation / Emulation
- Start playback:
curl -X POST http://127.0.0.1:8000/command \
-H "Content-Type: application/json" \
-d '{"command":"nfc_on","payload":{"uid":"UID_1"}}'
- Observe
/status:
curl http://127.0.0.1:8000/status
- Procedure – Real Box (Hardware)
- Place NFC tag mapped to UID_1.
- Expected Result
playback_state.state = PLAYINGactive_uid = UID_1
- Deviations / Troubleshooting
- No playback: check tags in
box/data/box.jsonand files inbox/data/media.
Test G: Resume-Logik
- Goal
- Resume picks up last file index and position per UID.
- Preconditions
- Playback started at least once for UID_1.
- Procedure – Simulation / Emulation
- Start playback, wait ~5s.
- Stop with
nfc_off. - Start again with
nfc_on.
- Procedure – Real Box (Hardware)
- Place NFC tag, remove, place again.
- Expected Result
- Resume uses stored
file_indexandposition. box/data/state.jsoncontains resume for UID_1.
- Deviations / Troubleshooting
- Resume resets to 0: check
state.jsonand path changes.
Test H: Ordner- & Rekursionslogik
- Goal
- Verify recursive ordering (DFS, folders first, lexicographic).
- Preconditions
- Nested media structure in
box/data/media.
- Procedure – Simulation / Emulation
- Create nested structure in
box/data/media/book_6/CD1/.... - Point a tag to
media/book_6inbox/data/box.json. - Start playback with
nfc_on.
- Procedure – Real Box (Hardware)
- Copy nested folders to the device media path.
- Start playback via NFC.
- Expected Result
- Files play in DFS order: subfolders sorted, then files.
- Deviations / Troubleshooting
- Ordering unexpected: check folder names and lexicographic sort.
Test I: Offline Scenarios
- Goal
- Verify WiFi and Spotify states in offline/online flows.
- Preconditions
- Box running.
- Procedure – Simulation / Emulation
- WiFi reset:
curl -X POST http://127.0.0.1:8000/command \
-H "Content-Type: application/json" \
-d '{"command":"wifi_reset"}'
- Spotify clear:
curl -X POST http://127.0.0.1:8000/command \
-H "Content-Type: application/json" \
-d '{"command":"spotify_clear"}'
- Procedure – Real Box (Hardware)
- Not testable with current code: real network loss and Spotify connectivity.
- Expected Result
wifi_state = WIFI_UNCONFIGUREDspotify_status = NOT_CONFIGURED
- Deviations / Troubleshooting
- Status unchanged: ensure you read
/statusafter command.
Test J: Fehlerfälle
- Goal
- Verify error sound and error reporting.
- Preconditions
- Box running.
- Procedure – Simulation / Emulation
- Trigger error:
curl -X POST http://127.0.0.1:8000/command \
-H "Content-Type: application/json" \
-d '{"command":"trigger_error","payload":{"type":"uid_unmapped"}}'
- Check
/statusforlast_error.
- Procedure – Real Box (Hardware)
- Not testable with current code: actual error sound output.
- Expected Result
playback_state.last_errorequals error type.- Box returns to
IDLEafter error.
- Deviations / Troubleshooting
- No error shown: verify
/statusand that errors are not cleared automatically.