--- name: test-audio description: 'Test audio system (AudioSource loading, playback state, stop, spatial audio) against the audio example using the iwsdk CLI.' argument-hint: '[--suite loading|playback|stop|all]' --- # Audio System Test Run 6 test suites covering audio loading, playback trigger, stop, system registration, component schema, and stability. **Configuration:** - EXAMPLE_DIR: `$IWSDK_REPO_ROOT/examples/audio` **Tool calls**: every tool call is `npx iwsdk [--input-json ''] [--timeout ]`, run from inside the example workspace (cwd `$EXAMPLE_DIR`). The CLI auto-discovers the IWSDK app root from cwd, so no path tricks are required. Run `npx iwsdk mcp inspect` from the example to discover available tools and their CLI subcommands. - `` is a JSON object string. Omit `--input-json` if no arguments are needed. - Output is JSON on stdout: `{ok, workspaceRoot, operation, result}`. Parse it to check assertions. - Use `--timeout 20000` for operations that may take longer (reload, xr enter, screenshot). **IMPORTANT**: Run each Bash command one at a time. Parse the JSON output and verify assertions before moving to the next command. Do NOT chain multiple CLI commands together. **IMPORTANT**: When the instructions say "wait N seconds", use `sleep N` as a separate Bash command. **IMPORTANT**: Boolean values in `ecs set-component` must be actual JSON booleans (`value: true`), NOT strings (`value: "true"`). Strings silently fail to coerce. --- ## Step 1: Install Dependencies ```bash cd $IWSDK_REPO_ROOT/examples/audio && npm run fresh:install ``` Wait for this to complete before proceeding. --- ## Step 2: Start Dev Server Start the dev server as a background task using the Bash tool's `run_in_background: true` parameter: ```bash cd $IWSDK_REPO_ROOT/examples/audio && npm run dev ``` **IMPORTANT**: This command MUST be run with `run_in_background: true` on the Bash tool — do NOT append `&` to the command itself. Once the background task is launched, poll the output for Vite's ready message (up to 60s). You can also run `npx iwsdk dev status` from the example directory until `state.running` becomes `true`. You do not need to extract or manage the port yourself; subsequent commands resolve the active runtime through the CLI automatically. If the server fails to start within 60 seconds, report FAIL for all suites and skip to Step 5. --- ## Step 3: Verify Connectivity ```bash npx iwsdk ecs systems 2>/dev/null ``` This must return JSON with a list of systems. If it fails: 1. Check the dev server output for errors 2. Try killing and restarting the server (Step 2) 3. If it still fails, report FAIL for all suites and skip to Step 5 --- ## Step 4: Run Test Suites ### Pre-test Setup Run these commands in order: 1. `npx iwsdk browser reload --timeout 20000 2>/dev/null` Then: `sleep 3` 2. `npx iwsdk xr enter --timeout 20000 2>/dev/null` Then: `sleep 2` 3. `npx iwsdk browser logs --input-json '{"count":20,"level":["error"]}' 2>/dev/null` Assert: No error-level logs. Audio autoplay warnings are acceptable. --- ### Suite 1: Audio Loading **Test 1.1: Find Audio Entity** ```bash npx iwsdk ecs find --input-json '{"withComponents":["AudioSource"]}' 2>/dev/null ``` Assert: At least 1 entity. Save the first as `