|
| 1 | +--- |
| 2 | +name: bug-fix |
| 3 | +description: > |
| 4 | + Reproduce, diagnose, fix, and PR RHDH plugin bugs from Jira tickets using |
| 5 | + Playwright e2e tests with before/after screen recordings. Accepts a Jira key |
| 6 | + (RHDHBUGS-1934), Jira URL (redhat.atlassian.net/browse/...), or a request to |
| 7 | + "fix this bug", "reproduce and fix", "/bug-fix". Chains into raise-pr for the |
| 8 | + full PR lifecycle including post-PR Jira updates (Web Link, comment, transition |
| 9 | + to Review). |
| 10 | +--- |
| 11 | + |
| 12 | +<essential_principles> |
| 13 | + |
| 14 | +<principle name="repro_test_is_temporary"> |
| 15 | +The reproduction test (`_repro-<KEY>.test.ts`) is a diagnostic tool, not a deliverable. It is deleted before staging. It must never appear in the PR. |
| 16 | +</principle> |
| 17 | + |
| 18 | +<principle name="runtime_discovery"> |
| 19 | +Do not hardcode workspace internals. Discover each workspace's e2e infrastructure at runtime by reading its `playwright.config.ts`, `e2e-tests/utils/`, and `plugins/*/src/translations/ref.ts`. The `references/workspace-map.md` maps Jira components to workspace directories, but everything else is discovered dynamically. |
| 20 | +</principle> |
| 21 | + |
| 22 | +<principle name="video_evidence"> |
| 23 | +Every bug fix PR must include before/after visual evidence. Playwright video recording captures the bug in action (before) and the fix working (after). These are converted to GIFs and embedded in the PR description. |
| 24 | +</principle> |
| 25 | + |
| 26 | +</essential_principles> |
| 27 | + |
| 28 | +## Prerequisites |
| 29 | + |
| 30 | +- Working checkout of `rhdh-plugins` (or `community-plugins`) |
| 31 | +- `yarn` available on PATH |
| 32 | +- `ffmpeg` available on PATH (for video conversion; fall back to raw `.webm` if absent) |
| 33 | +- Jira auth configured (`.jira-token` next to `acli` binary, or Jira MCP in Cursor) |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Step 1 — Fetch Jira issue and parse details |
| 38 | + |
| 39 | +Read `references/workspace-map.md` for the Jira component-to-workspace mapping. |
| 40 | + |
| 41 | +1. Parse the Jira reference from the user's input. Follow the parsing rules in `raise-pr/references/jira-input.md`: |
| 42 | + - Bare key: `RHDHBUGS-1934` |
| 43 | + - Browse URL: `https://redhat.atlassian.net/browse/RHDHBUGS-1934` |
| 44 | + - URL without scheme: `redhat.atlassian.net/browse/RHIDP-15252` |
| 45 | +2. Fetch the full issue details using the Jira REST API or MCP (`read_jira_issue`): |
| 46 | + - Summary, description, steps to reproduce |
| 47 | + - Component field (maps to workspace) |
| 48 | + - Status (for post-PR transition) |
| 49 | + - Attachments/screenshots (visual reference for reproduction) |
| 50 | +3. Store: `jira_key`, `jira_url`, `jira_summary`, `jira_description`, `jira_component`, `jira_status` |
| 51 | + |
| 52 | +**If the description has no clear steps to reproduce**: ask the user to provide reproduction steps before proceeding. |
| 53 | + |
| 54 | +--- |
| 55 | + |
| 56 | +## Step 2 — Identify workspace and discover e2e infrastructure |
| 57 | + |
| 58 | +1. Map the Jira **Component** field to a workspace directory using `references/workspace-map.md`. |
| 59 | + - If no component is set or the component is unknown: ask the user which workspace to target. |
| 60 | +2. Navigate to the workspace: `cd workspaces/<workspace-dir>` |
| 61 | +3. **Discover e2e infrastructure dynamically**: |
| 62 | + - Read `playwright.config.ts` for port configuration, locale list, start commands, and `APP_MODE` support. |
| 63 | + - Scan `e2e-tests/utils/` to discover available helper functions (translations, navigation, API mocking, accessibility). |
| 64 | + - Read `plugins/*/src/translations/ref.ts` for translation key structure (used for i18n-safe selectors). |
| 65 | + - Read `plugins/*/src/components/` to build a component-to-source-file map. |
| 66 | +4. Run `yarn install` if `node_modules` is missing or stale. |
| 67 | + |
| 68 | +**If the workspace has no `playwright.config.ts`**: fall back to a screenshot-only approach — skip video recording and use DOM assertions or manual screenshots instead. |
| 69 | + |
| 70 | +Read `references/e2e-patterns.md` for shared Playwright patterns across all rhdh-plugins workspaces. |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## Step 3 — Write reproduction test with video recording |
| 75 | + |
| 76 | +Read `references/e2e-patterns.md` for test patterns and `references/video-recording.md` for video configuration. |
| 77 | + |
| 78 | +1. Create a temporary test file: `e2e-tests/_repro-<JIRA-KEY>.test.ts` |
| 79 | + - The `_` prefix signals this file is temporary and should not be committed. |
| 80 | +2. The test must: |
| 81 | + - Import workspace-specific helpers discovered in Step 2. |
| 82 | + - Use i18n-safe selectors (via translation keys) where available. |
| 83 | + - Configure video recording per-test: |
| 84 | + ```typescript |
| 85 | + test.use({ |
| 86 | + video: { mode: 'on', size: { width: 1280, height: 720 } }, |
| 87 | + }); |
| 88 | + ``` |
| 89 | + - Encode the "steps to reproduce" from the Jira description as Playwright actions. |
| 90 | + - Assert the **expected** behavior (the assertion should fail when the bug is present). |
| 91 | +3. Run the test against the `en` locale in legacy mode: |
| 92 | + ``` |
| 93 | + APP_MODE=legacy npx playwright test e2e-tests/_repro-<KEY>.test.ts --project=en |
| 94 | + ``` |
| 95 | +4. The test should **fail** — confirming the bug is reproduced. |
| 96 | +
|
| 97 | +**If the test passes** (bug not reproduced): re-read the Jira description, adjust the test, and retry. If still not reproducible after 2 attempts, report findings and ask the user for guidance. |
| 98 | +
|
| 99 | +--- |
| 100 | +
|
| 101 | +## Step 4 — Capture "before" recording |
| 102 | +
|
| 103 | +1. After the failed test run (Step 3), locate the video file in `test-results/`. |
| 104 | + - Playwright saves videos at `test-results/<test-title>/video.webm`. |
| 105 | +2. Copy the video to a stable path: |
| 106 | + ``` |
| 107 | + mkdir -p e2e-tests/_repro-artifacts |
| 108 | + cp test-results/*/video.webm e2e-tests/_repro-artifacts/before-fix.webm |
| 109 | + ``` |
| 110 | +3. Store the path for later conversion (Step 7). |
| 111 | +
|
| 112 | +--- |
| 113 | +
|
| 114 | +## Step 5 — Diagnose and fix |
| 115 | +
|
| 116 | +1. **Diagnose**: trace from the failing Playwright selector back to the source: |
| 117 | + - Identify which React component renders the UI element under test. |
| 118 | + - Read the component source code (`plugins/*/src/components/`). |
| 119 | + - Identify the root cause (e.g., MUI prop misconfiguration, missing state update, CSS issue, accessibility gap, i18n key mismatch). |
| 120 | +2. **Apply the fix** in the source code. |
| 121 | +3. **Validate**: |
| 122 | + - `yarn tsc:full` — type check passes. |
| 123 | + - `yarn test --watchAll=false` — unit tests pass. |
| 124 | +
|
| 125 | +**Confidence gates** — ask the user before proceeding if: |
| 126 | +- Multiple possible root causes exist — present options and let the user choose. |
| 127 | +- The fix touches more than 3 files — show the plan and get approval. |
| 128 | +- The fix changes API surface or public types — this may need a minor version bump. |
| 129 | +
|
| 130 | +--- |
| 131 | +
|
| 132 | +## Step 6 — Capture "after" recording |
| 133 | +
|
| 134 | +1. Re-run the reproduction test: |
| 135 | + ``` |
| 136 | + APP_MODE=legacy npx playwright test e2e-tests/_repro-<KEY>.test.ts --project=en |
| 137 | + ``` |
| 138 | +2. The test should **pass** — confirming the fix works. |
| 139 | +3. Copy the video: |
| 140 | + ``` |
| 141 | + cp test-results/*/video.webm e2e-tests/_repro-artifacts/after-fix.webm |
| 142 | + ``` |
| 143 | +4. Optionally run in NFS mode as well to check for mode-specific regressions: |
| 144 | + ``` |
| 145 | + APP_MODE=nfs npx playwright test e2e-tests/_repro-<KEY>.test.ts --project=en |
| 146 | + ``` |
| 147 | +
|
| 148 | +**If the test still fails after the fix**: re-examine the diagnosis and iterate. |
| 149 | +
|
| 150 | +--- |
| 151 | +
|
| 152 | +## Step 7 — Convert videos for PR embedding |
| 153 | +
|
| 154 | +Read `references/video-recording.md` for conversion details. |
| 155 | +
|
| 156 | +1. Check if `ffmpeg` is available on PATH. |
| 157 | +2. **If available**: convert `.webm` to `.gif`: |
| 158 | + ``` |
| 159 | + ffmpeg -i e2e-tests/_repro-artifacts/before-fix.webm -vf "fps=10,scale=800:-1" -loop 0 e2e-tests/_repro-artifacts/before-fix.gif |
| 160 | + ffmpeg -i e2e-tests/_repro-artifacts/after-fix.webm -vf "fps=10,scale=800:-1" -loop 0 e2e-tests/_repro-artifacts/after-fix.gif |
| 161 | + ``` |
| 162 | +3. **If `ffmpeg` is not available**: keep the `.webm` files and note that they will be uploaded as PR comment attachments instead of inline GIFs. |
| 163 | +
|
| 164 | +--- |
| 165 | +
|
| 166 | +## Step 8 — Clean up and create PR |
| 167 | +
|
| 168 | +### 8.1 — Delete temporary files |
| 169 | +
|
| 170 | +Remove the reproduction test and artifacts — these must not appear in the PR: |
| 171 | +
|
| 172 | +``` |
| 173 | +rm e2e-tests/_repro-<KEY>.test.ts |
| 174 | +rm -rf test-results/ |
| 175 | +``` |
| 176 | +
|
| 177 | +Keep `e2e-tests/_repro-artifacts/` temporarily (needed for PR image upload). |
| 178 | +
|
| 179 | +### 8.2 — Stage fix files |
| 180 | +
|
| 181 | +Stage only the code fix (not the repro test or artifacts): |
| 182 | +
|
| 183 | +``` |
| 184 | +git add <fixed-source-files> |
| 185 | +``` |
| 186 | +
|
| 187 | +### 8.3 — Chain into raise-pr |
| 188 | +
|
| 189 | +Invoke `raise-pr --a` with the following caller context: |
| 190 | +
|
| 191 | +| Field | Value | |
| 192 | +|-------|-------| |
| 193 | +| `jira_key` | The resolved Jira key from Step 1 | |
| 194 | +| `jira_url` | `https://redhat.atlassian.net/browse/<jira_key>` | |
| 195 | +| `jira_summary` | Issue summary from Step 1 | |
| 196 | +| `recordings` | `{ before: "e2e-tests/_repro-artifacts/before-fix.gif", after: "e2e-tests/_repro-artifacts/after-fix.gif" }` | |
| 197 | +| `pr_description_extra` | `**Root cause:** <diagnosis from Step 5>` | |
| 198 | +
|
| 199 | +`raise-pr` handles: repo detection, build, changeset, commit (with `Fixes:` trailer), push, PR creation (with `## UI before/after changes`), and post-PR Jira updates (Web Link, comment, transition to Review). |
| 200 | +
|
| 201 | +### 8.4 — Final cleanup |
| 202 | +
|
| 203 | +After the PR is created, delete the artifacts directory: |
| 204 | +
|
| 205 | +``` |
| 206 | +rm -rf e2e-tests/_repro-artifacts/ |
| 207 | +``` |
| 208 | +
|
| 209 | +--- |
| 210 | +
|
| 211 | +## When NOT to Use |
| 212 | +
|
| 213 | +- **Backend-only bugs** — if the bug has no UI component, there is nothing to video-record. Use standard debugging and fix workflows instead. |
| 214 | +- **Bugs requiring live backend data** — if reproduction depends on real API responses that cannot be mocked via the workspace's e2e test infrastructure. |
| 215 | +- **Cross-workspace bugs** — if the fix requires changes across multiple workspaces, handle each workspace separately or use `raise-pr` directly. |
| 216 | +- **Non-RHDH Jira projects** — this skill's workspace mapping is specific to `rhdh-plugins` workspaces and RHDH Jira projects (RHIDP, RHDHBUGS, RHDHPLAN, RHDHSUPP). |
| 217 | +
|
| 218 | +<reference_index> |
| 219 | +
|
| 220 | +## Reference Index |
| 221 | +
|
| 222 | +| Reference | Load when... | |
| 223 | +|-----------|-------------| |
| 224 | +| `references/workspace-map.md` | Always — at the start of every invocation (Step 1-2) | |
| 225 | +| `references/e2e-patterns.md` | When writing the reproduction test (Step 3) | |
| 226 | +| `references/video-recording.md` | When configuring video capture (Step 3) and converting videos (Step 7) | |
| 227 | +| `raise-pr/references/jira-input.md` | When parsing Jira keys/URLs (Step 1) — shared with raise-pr | |
| 228 | +| `raise-pr/references/repo-profiles.md` | Loaded by raise-pr during Step 8.3 chain | |
| 229 | +
|
| 230 | +</reference_index> |
0 commit comments