Skip to content

Commit d0633fd

Browse files
authored
chore: add Copilot UI test skill (#1039)
Adapt vscode-java-pack#1682 to Project Manager for Java: - Add repository-level Copilot instructions routing UI/E2E requests to AutoTest YAML plans under test/e2e-plans/ - Add scoped test/e2e-plans/**/*.yaml authoring rules for AutoTest plans - Add a uitest skill that guides writing, validating, building, packaging, running, and debugging AutoTest UI tests
1 parent 79ea884 commit d0633fd

3 files changed

Lines changed: 136 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copilot instructions for vscode-java-dependency
2+
3+
## UI and E2E tests
4+
5+
- When asked to add, update, run, or debug UI/E2E coverage, prefer the AutoTest YAML workflow under `test/e2e-plans/`.
6+
- Use the `uitest` skill for UI test work. It should create or update `test/e2e-plans/*.yaml`, validate the plan, build the OSGi bundle and package the extension when needed, run AutoTest, and inspect `test-results/`.
7+
- Do not create legacy VS Code extension tests (`test/maven-suite`, `test/gui`) for UI coverage unless the user explicitly asks for that format.
8+
- Prefer deterministic AutoTest verifiers (`verifyTreeItem`, `verifyFile`, `verifyEditorTab`, `verifyClipboard`) over screenshot-only checks.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
applyTo: "test/e2e-plans/**/*.yaml"
3+
description: "Authoring rules for vscode-java-dependency (Project Manager for Java) AutoTest UI/E2E YAML test plans"
4+
---
5+
6+
# AutoTest UI/E2E test plan instructions
7+
8+
Test plans under `test/e2e-plans/` are executable YAML files consumed by `@vscjava/vscode-autotest`. They should describe stable user scenarios for the Java Projects explorer, not raw implementation details.
9+
10+
## Setup rules
11+
12+
- Use `setup.extension: "vscjava.vscode-java-pack"` plus `setup.vscodeVersion: "stable"` for most scenarios. Installing the Extension Pack for Java pulls in every Java extension the Java Projects view relies on, so there is no need to install `redhat.java` separately.
13+
- Install the extension under test from a local VSIX at runtime with `--vsix vscode-java-dependency.vsix` — do not rely on a marketplace copy of `vscjava.vscode-java-dependency`.
14+
- Use existing in-repo fixtures as the workspace: `../maven` (a `maven-archetype-quickstart` project: `my-app` / `com.mycompany.app` / `App.java`) or `../invisible` (an unmanaged-folder project for referenced-library scenarios). Paths are relative to the test plan file. Do not add large binary fixtures.
15+
- Referenced-library / classpath commands (`java.project.addLibraries`, `java.project.removeLibrary`, `java.project.addLibraryFolders`, `java.project.refreshLibraries`) only apply to invisible projects — use `../invisible`, not `../maven`, for those.
16+
- Disable noisy startup surfaces with settings when relevant, for example `workbench.startupEditor: "none"` and `java.configuration.checkProjectSettingsExclusions: false`.
17+
18+
## Action rules
19+
20+
- Prefer stable command IDs via `executeVSCodeCommand` (for example `javaProjectExplorer.focus`, `java.view.package.revealInProjectExplorer`, `workbench.actions.treeView.javaProjectExplorer.collapseAll`) before UI locators. Command IDs are locale-independent.
21+
- Drive the tree with `expandTreeItem <name>` and title-bar buttons with `clickViewTitleAction "Java Projects" "<action>"`. The action resolver only matches the exact `expandTreeItem <name>` form; free-form phrasing silently falls back to the command palette and no-ops.
22+
- Free up sidebar space before asserting tree rows: `executeVSCodeCommand workbench.action.closeAuxiliaryBar`, `collapseSidebarSection OUTLINE`, `collapseSidebarSection TIMELINE`, and `collapseWorkspaceRoot`.
23+
- Use `insertLineInFile` for Java edits that the language server must analyze. Use `typeInEditor` only for text that does not require language-server analysis.
24+
- Use `waitForLanguageServer` before interacting with the tree; prefer verifier polling over long static waits. Short static waits are acceptable only for UI rendering settle time.
25+
- Native file/folder pickers are suppressed in the smoke-test driver; drive VS Code's internal quick-pick with `fillQuickInput` instead of relying on `mockOpenDialog`.
26+
- Quote action arguments that contain spaces:
27+
28+
```yaml
29+
action: 'clickViewTitleAction "Java Projects" "Unlink with Editor"'
30+
```
31+
32+
## Verification rules
33+
34+
- Add deterministic verification to every meaningful step. The natural-language `verify` field is context for humans and failure analysis; it is not pass/fail authority by itself, and it is auto-passed when a plan runs with `--no-llm`.
35+
- Use `verifyTreeItem` (with `name:`, optional `exact: true`, and `visible: false` for absence) as the authoritative check for Java Projects tree state.
36+
- Use `verifyFile` after operations that create, modify, or delete files on disk (new type, export jar, permanent delete). VS Code can open duplicate editor tabs with stale buffers, so prefer file-content checks over editor checks after such operations.
37+
- Use `verifyEditorTab` to assert which file an action opened, and `verifyClipboard` for copy-path commands.
38+
- On state-check steps whose only assertion is a deterministic verifier, omit the `verify:` field to avoid false LLM failures.
39+
- Use screenshots only as diagnostics produced by AutoTest; do not make screenshots the only evidence of pass/fail.
40+
41+
## Local validation commands
42+
43+
```powershell
44+
npx -y @vscjava/vscode-autotest validate test\e2e-plans\<name>.yaml
45+
npm install # first time only; on later iterations run just the commands below
46+
npm run build-server
47+
npx @vscode/vsce package -o vscode-java-dependency.vsix
48+
npx -y @vscjava/vscode-autotest run test\e2e-plans\<name>.yaml --vsix vscode-java-dependency.vsix --no-llm
49+
```

.github/skills/uitest/SKILL.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
name: uitest
3+
description: Write, update, run, or debug vscode-java-dependency (Project Manager for Java) UI/E2E tests using AutoTest YAML plans. Use when the user asks for a UI test, E2E test, VS Code UI validation, Java Projects tree/view test, referenced-library 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-dependency` (Project Manager for Java).
9+
10+
The repository uses `@vscjava/vscode-autotest`: YAML plans in `test/e2e-plans/*.yaml` launch VS Code, install the Extension Pack for Java (`vscjava.vscode-java-pack`) plus a local VSIX of this extension, execute user-facing actions against the Java Projects view, 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` (JDK 21 is required to build the `jdtls.ext` OSGi bundle).
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+
- Workspace fixtures are in-repo — no external clones are needed. Plans reference `../maven` (`test/maven`, a `maven-archetype-quickstart` project) or `../invisible` (`test/invisible`, an unmanaged-folder project).
17+
18+
## Workflow
19+
20+
1. Identify the scenario and search `test/e2e-plans/*.yaml` for an existing plan that already covers the area (project explorer, view modes, classpath, export jar, new types, file operations, delete, copy paths, refresh, build lifecycle, autorefresh).
21+
2. Update the existing plan when possible. Create a new `test/e2e-plans/java-dep-<scenario>.yaml` only when no existing plan fits.
22+
3. Use stable AutoTest actions and deterministic verifiers. Do not add raw Playwright tests or screenshot-only checks.
23+
4. Validate the plan:
24+
25+
```powershell
26+
npx -y @vscjava/vscode-autotest validate test\e2e-plans\<name>.yaml
27+
```
28+
29+
5. If validating the current branch, build the OSGi bundle and package the extension:
30+
31+
```powershell
32+
npm install # first time only; on later iterations run just the two commands below
33+
npm run build-server
34+
npx @vscode/vsce package -o vscode-java-dependency.vsix
35+
```
36+
37+
6. Run the plan against the packaged VSIX:
38+
39+
```powershell
40+
npx -y @vscjava/vscode-autotest run test\e2e-plans\<name>.yaml --vsix vscode-java-dependency.vsix --output test-results\<name>
41+
```
42+
43+
Add `--no-llm` to skip natural-language `verify:` fields and rely only on deterministic verifiers for a fast local loop. Run the whole suite with `npm run test-e2e` (`autotest run-all test/e2e-plans --no-llm`).
44+
45+
7. Inspect `test-results/<name>/results.json` and `test-results/<name>/screenshots/`.
46+
8. Iterate based on the failure cause:
47+
- **Incorrect plan**: fix the YAML and rerun step 6. No rebuild is needed.
48+
- **Product code fix**: after editing extension source (`src/**`) or the OSGi bundle (`jdtls.ext/**`), re-run step 5 (rebuild + repackage the VSIX) before rerunning step 6. Never rerun against a stale VSIX.
49+
- **Product bug (report only)**: report the observed behavior and cite the failing step, screenshot, and result reason.
50+
51+
## Authoring rules
52+
53+
- For most plans, use:
54+
55+
```yaml
56+
setup:
57+
extension: "vscjava.vscode-java-pack"
58+
vscodeVersion: "stable"
59+
workspace: "../maven"
60+
settings:
61+
java.configuration.checkProjectSettingsExclusions: false
62+
workbench.startupEditor: "none"
63+
```
64+
65+
- Use `--vsix vscode-java-dependency.vsix` to test current-branch changes; do not rely on a marketplace copy of `vscjava.vscode-java-dependency`.
66+
- Use `../invisible` (not `../maven`) for referenced-library / classpath commands, which only apply to unmanaged-folder projects.
67+
- Prefer `executeVSCodeCommand <commandId>` for command-driven UI (e.g. `javaProjectExplorer.focus`, `java.view.package.revealInProjectExplorer`, `workbench.actions.treeView.javaProjectExplorer.collapseAll`).
68+
- Drive the tree with `expandTreeItem <name>` and title-bar buttons with `clickViewTitleAction "Java Projects" "<action>"`.
69+
- Prefer `verifyTreeItem` for tree state, `verifyFile` for generated/modified/deleted files, `verifyEditorTab` for opened tabs, and `verifyClipboard` for copy-path commands.
70+
- Use `waitForLanguageServer` before tree interactions, and `insertLineInFile` for Java source edits that JDT LS must observe.
71+
- Free sidebar space (`closeAuxiliaryBar`, `collapseSidebarSection OUTLINE`/`TIMELINE`, `collapseWorkspaceRoot`) before asserting tree rows.
72+
- Keep step IDs unique, descriptive, and kebab-case. Omit `verify:` on steps whose only assertion is a deterministic verifier.
73+
- Avoid hard-coded coordinates and brittle DOM structure assumptions.
74+
75+
## CI
76+
77+
The repository workflow `.github/workflows/e2eUI.yml` runs on push and pull requests to `main`. It lints, discovers `test/e2e-plans/*.yaml` into a matrix, builds a branch VSIX per OS, runs every plan on Windows and Linux as independent matrix cells, and uploads `test-results/` artifacts plus an aggregate summary.
78+
79+
Each plan surfaces as its own PR check, so a new `test/e2e-plans/*.yaml` is picked up automatically without editing the workflow.

0 commit comments

Comments
 (0)