|
| 1 | +--- |
| 2 | +name: uitest |
| 3 | +description: Write, update, run, or debug vscode-java-pack UI/E2E tests using AutoTest YAML plans. Use when the user asks for a UI test, E2E test, VS Code UI validation, webview test, Java extension pack workflow test, or autotest plan. |
| 4 | +--- |
| 5 | + |
| 6 | +# UI/E2E tests with AutoTest |
| 7 | + |
| 8 | +Use this skill to add or update UI/E2E coverage for `vscode-java-pack`. |
| 9 | + |
| 10 | +The repository uses `@vscjava/vscode-autotest`: YAML plans in `test-plans/*.yaml` launch VS Code, install Java extensions or local VSIX files, execute user-facing actions, capture screenshots, and write `test-results/<plan>/results.json`. |
| 11 | + |
| 12 | +## Prerequisites (local) |
| 13 | + |
| 14 | +- Node.js >= 18 and JDK 21+ installed and on `PATH`. |
| 15 | +- Close any running VS Code instance before running a plan locally; a running instance can block AutoTest from launching its own VS Code. |
| 16 | +- When a plan references external sample projects, clone them as siblings of this repo first (CI does this automatically): |
| 17 | + |
| 18 | +```powershell |
| 19 | +git clone --depth 1 https://github.com/redhat-developer/vscode-java.git ../vscode-java |
| 20 | +git clone --depth 1 https://github.com/eclipse-jdtls/eclipse.jdt.ls.git ../eclipse.jdt.ls |
| 21 | +``` |
| 22 | + |
| 23 | +## Workflow |
| 24 | + |
| 25 | +1. Identify the scenario and search `test-plans/*.yaml` for an existing plan that already covers the area. |
| 26 | +2. Update the existing plan when possible. Create a new `test-plans/<scenario>.yaml` only when no existing plan fits. |
| 27 | +3. Use stable AutoTest actions and deterministic verifiers. Do not add raw Playwright tests or screenshot-only checks. |
| 28 | +4. Validate the plan: |
| 29 | + |
| 30 | +```powershell |
| 31 | +npx -y @vscjava/vscode-autotest validate test-plans\<name>.yaml |
| 32 | +``` |
| 33 | + |
| 34 | +5. If validating the current branch, build and package the extension: |
| 35 | + |
| 36 | +```powershell |
| 37 | +npm ci # first time only; on later iterations run just the two commands below |
| 38 | +npm run build |
| 39 | +npx @vscode/vsce@latest package -o vscode-java-pack-pr.vsix |
| 40 | +``` |
| 41 | + |
| 42 | +6. Run the plan against the packaged VSIX: |
| 43 | + |
| 44 | +```powershell |
| 45 | +npx -y @vscjava/vscode-autotest run test-plans\<name>.yaml --vsix vscode-java-pack-pr.vsix --no-llm |
| 46 | +``` |
| 47 | + |
| 48 | +7. Inspect `test-results/<name>/results.json` and `test-results/<name>/screenshots/`. |
| 49 | +8. Iterate based on the failure cause: |
| 50 | + - **Incorrect plan**: fix the YAML and rerun step 6. No rebuild is needed. |
| 51 | + - **Product code fix**: after editing extension source, re-run step 5 (build + repackage the VSIX) before rerunning step 6. Never rerun against a stale VSIX. |
| 52 | + - **Product bug (report only)**: report the observed behavior and cite the failing step, screenshot, and result reason. |
| 53 | + |
| 54 | +## Authoring rules |
| 55 | + |
| 56 | +- For most plans, use: |
| 57 | + |
| 58 | +```yaml |
| 59 | +setup: |
| 60 | + extension: "redhat.java" |
| 61 | + extensions: |
| 62 | + - "vscjava.vscode-java-pack" |
| 63 | + vscodeVersion: "stable" |
| 64 | +``` |
| 65 | +
|
| 66 | +- Use `--vsix vscode-java-pack-pr.vsix` to test current-branch changes. |
| 67 | +- Prefer `executeVSCodeCommand` or `run command` for command-driven UI. |
| 68 | +- Prefer `verifyWebview` for webview content, `verifyTreeItem` for tree views, `verifyFile` for generated or modified files, `verifyProblems` for diagnostics, and `verifyCompletion` for IntelliSense. |
| 69 | +- Use `insertLineInFile` for Java source edits that JDT LS must observe. |
| 70 | +- Use `verifyFile` instead of `verifyEditor` after code actions, organize imports, or rename. |
| 71 | +- Keep step IDs unique, descriptive, and kebab-case. |
| 72 | +- Avoid hard-coded coordinates and brittle DOM structure assumptions. |
| 73 | + |
| 74 | +## CI |
| 75 | + |
| 76 | +The repository workflow `.github/workflows/e2e-autotest.yml` builds a branch VSIX, discovers `test-plans/*.yaml`, runs plans on Windows/Linux/macOS, and uploads `test-results/` artifacts. |
| 77 | + |
| 78 | +Use workflow dispatch when the user asks to validate in CI or across platforms. The `test_plan` input can target a single plan; leave it empty to run all plans. |
| 79 | + |
0 commit comments