|
| 1 | +--- |
| 2 | +name: cypress-run |
| 3 | +description: Display Cypress test commands - choose execution mode (headless recommended) |
| 4 | +parameters: |
| 5 | + - name: execution-mode |
| 6 | + description: Choose execution mode - headless (recommended), headed, or interactive |
| 7 | + required: true |
| 8 | + type: string |
| 9 | +--- |
| 10 | + |
| 11 | +# Cypress Test Commands |
| 12 | + |
| 13 | +**Prerequisites**: |
| 14 | +1. Run `/cypress-setup` first to configure your environment. |
| 15 | +2. Ensure the "Cypress Tests" terminal window is open (created by `/cypress-setup`) |
| 16 | + |
| 17 | +**Note**: All commands are executed in the "Cypress Tests" terminal window using the helper scripts. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Execution Modes |
| 22 | + |
| 23 | +1. **Headless** (Recommended) - Fast, automated testing without visible browser |
| 24 | +2. **Headed** - Watch tests execute in visible browser for debugging |
| 25 | +3. **Interactive** - Visual UI to pick and run tests manually |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## How to Run Commands in Cypress Tests Terminal |
| 30 | + |
| 31 | +All npm commands should be executed in the "Cypress Tests" terminal using the helper scripts: |
| 32 | + |
| 33 | +**macOS:** |
| 34 | +```bash |
| 35 | +./.claude/commands/cypress/scripts/open-cypress-terminal-macos.sh --run "npm run <command>" |
| 36 | +``` |
| 37 | + |
| 38 | +**Linux:** |
| 39 | +```bash |
| 40 | +./.claude/commands/cypress/scripts/open-cypress-terminal-linux.sh --run "npm run <command>" |
| 41 | +``` |
| 42 | + |
| 43 | +**Instructions**: Based on the `execution-mode` parameter provided by the user: |
| 44 | +- If `execution-mode` is "interactive": Display ONLY the "Interactive Mode" section below |
| 45 | +- If `execution-mode` is "headless": display ONLY the "Headless Mode" section with interactive options to be chosen |
| 46 | +- If `execution-mode` is "headed": display ONLY the "Headed Mode" section with interactive options to be chosen |
| 47 | + |
| 48 | +**IMPORTANT**: Always execute the selected command using the appropriate script: |
| 49 | +- macOS: `./.claude/commands/cypress/scripts/open-cypress-terminal-macos.sh --run "<command>"` |
| 50 | +- Linux: `./.claude/commands/cypress/scripts/open-cypress-terminal-linux.sh --run "<command>"` |
| 51 | + |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +# Interactive Mode |
| 56 | + |
| 57 | +**Cypress Interactive Test Runner** - Pick and run tests visually with Cypress UI. |
| 58 | + |
| 59 | +## What is Interactive Mode? |
| 60 | + |
| 61 | +Interactive mode opens the Cypress Test Runner UI where you can: |
| 62 | +- Browse and select tests visually |
| 63 | +- Watch tests run in real-time with time-travel debugging |
| 64 | +- Inspect DOM snapshots at each step |
| 65 | +- See detailed command logs |
| 66 | +- Rerun tests with a single click |
| 67 | +- Perfect for test development and debugging |
| 68 | + |
| 69 | +## Command |
| 70 | + |
| 71 | +**Open Cypress Interactive UI (run in Cypress Tests terminal):** |
| 72 | + |
| 73 | +macOS: |
| 74 | +```bash |
| 75 | +./.claude/commands/cypress/scripts/open-cypress-terminal-macos.sh --run "npm run cypress:open" |
| 76 | +``` |
| 77 | + |
| 78 | +Linux: |
| 79 | +```bash |
| 80 | +./.claude/commands/cypress/scripts/open-cypress-terminal-linux.sh --run "npm run cypress:open" |
| 81 | +``` |
| 82 | + |
| 83 | +This opens a visual interface where you can: |
| 84 | +1. Choose a browser (Chrome, Firefox, Edge, Electron) |
| 85 | +2. Browse your test files |
| 86 | +3. Click any test to run it |
| 87 | +4. Watch it execute step-by-step |
| 88 | +5. Debug failures interactively |
| 89 | + |
| 90 | +## Benefits |
| 91 | + |
| 92 | +- **Visual Testing**: See exactly what's happening |
| 93 | +- **Fast Iteration**: Make changes and rerun instantly |
| 94 | +- **Easy Debugging**: Inspect any step of your test |
| 95 | +- **Browser DevTools**: Full access to browser debugging tools |
| 96 | +- **Selector Playground**: Helps you write better selectors |
| 97 | + |
| 98 | +## When to Use |
| 99 | + |
| 100 | +- Developing new tests |
| 101 | +- Debugging test failures |
| 102 | +- Learning how tests work |
| 103 | +- Demonstrating tests to others |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +# Headless Mode Commands |
| 108 | + |
| 109 | +All commands below run tests in headless mode (no visible browser). |
| 110 | + |
| 111 | +## Dynamic Command Discovery |
| 112 | + |
| 113 | +**IMPORTANT**: Before showing test commands, you MUST dynamically read: |
| 114 | + |
| 115 | +### 1. Available NPM Scripts |
| 116 | +Read `web/package.json` and extract all scripts matching `test-cypress-*` and `cypress:*` patterns. |
| 117 | +Present them as available test suite commands. |
| 118 | + |
| 119 | +### 2. Available Test Spec Files |
| 120 | +Scan `web/cypress/e2e/` directory recursively and list all `.cy.ts` files. |
| 121 | +Present them as available spec file targets for `--spec` option. |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## Quick Reference - Base Commands |
| 126 | + |
| 127 | +**Run with npm script (if defined in package.json):** |
| 128 | +```bash |
| 129 | +npm run <script-name> |
| 130 | +``` |
| 131 | + |
| 132 | +**Run all tests headless:** |
| 133 | +```bash |
| 134 | +npm run cypress:run |
| 135 | +``` |
| 136 | + |
| 137 | +**Run specific spec file:** |
| 138 | +```bash |
| 139 | +npm run cypress:run -- --spec "cypress/e2e/<path-to-file>.cy.ts" |
| 140 | +``` |
| 141 | + |
| 142 | +**Run with custom tags:** |
| 143 | +```bash |
| 144 | +npm run cypress:run -- --env grepTags="<YOUR_TAGS_HERE>" |
| 145 | +``` |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +## NPM Scripts from package.json |
| 150 | + |
| 151 | +**Instructions**: Read `web/package.json` and list ALL scripts that start with: |
| 152 | +- `test-cypress-*` (predefined test suites) |
| 153 | +- `cypress:*` (base cypress commands) |
| 154 | + |
| 155 | +For each script found, display: |
| 156 | +```bash |
| 157 | +npm run <script-name> |
| 158 | +``` |
| 159 | + |
| 160 | +Add a brief description based on the grepTags or other flags in the script definition. |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +## Spec Files from cypress/e2e |
| 165 | + |
| 166 | +**Instructions**: Scan `web/cypress/e2e/` recursively and organize by folder: |
| 167 | + |
| 168 | +For each `.cy.ts` file found, show the command: |
| 169 | +```bash |
| 170 | +npm run cypress:run -- --spec "cypress/e2e/<relative-path>" |
| 171 | +``` |
| 172 | + |
| 173 | +Group files by their parent folder (monitoring, coo, perses, virtualization, incidents, etc.) |
| 174 | + |
| 175 | +--- |
| 176 | + |
| 177 | +## Custom Tag Combinations - Headless |
| 178 | + |
| 179 | +**Base command for custom tags:** |
| 180 | +```bash |
| 181 | +npm run cypress:run -- --env grepTags="YOUR_TAGS_HERE" |
| 182 | +``` |
| 183 | + |
| 184 | +**Tag Operators:** |
| 185 | +- `+` = AND (e.g., `@alerts+@smoke` = alerts AND smoke) |
| 186 | +- `--` = NOT (e.g., `@monitoring --@flaky` = monitoring but NOT flaky) |
| 187 | +- `,` = OR (e.g., `@alerts,@metrics` = alerts OR metrics) |
| 188 | + |
| 189 | +**Common tag patterns:** |
| 190 | + |
| 191 | +| Goal | Command | |
| 192 | +|------|---------| |
| 193 | +| Smoke tests only | `npm run cypress:run -- --env grepTags="@smoke"` | |
| 194 | +| Exclude flaky | `npm run cypress:run -- --env grepTags="<tag> --@flaky"` | |
| 195 | +| Exclude demo | `npm run cypress:run -- --env grepTags="<tag> --@demo"` | |
| 196 | +| Fast smoke | `npm run cypress:run -- --env grepTags="@smoke --@slow --@flaky"` | |
| 197 | + |
| 198 | +--- |
| 199 | + |
| 200 | +## Running Multiple Spec Files |
| 201 | + |
| 202 | +**Comma-separate spec paths:** |
| 203 | +```bash |
| 204 | +npm run cypress:run -- --spec "cypress/e2e/<file1>.cy.ts,cypress/e2e/<file2>.cy.ts" |
| 205 | +``` |
| 206 | + |
| 207 | +--- |
| 208 | + |
| 209 | +## Advanced Headless Options |
| 210 | + |
| 211 | +**Run with specific browser:** |
| 212 | +```bash |
| 213 | +npm run cypress:run -- --browser firefox |
| 214 | +npm run cypress:run -- --browser edge |
| 215 | +npm run cypress:run -- --browser chrome |
| 216 | +``` |
| 217 | + |
| 218 | +**Disable video recording:** |
| 219 | +```bash |
| 220 | +npm run cypress:run -- --config video=false |
| 221 | +``` |
| 222 | + |
| 223 | +**Disable screenshots:** |
| 224 | +```bash |
| 225 | +npm run cypress:run -- --config screenshotOnRunFailure=false |
| 226 | +``` |
| 227 | + |
| 228 | +--- |
| 229 | + |
| 230 | +# Headed Mode Commands |
| 231 | + |
| 232 | +All commands below open a visible browser window. |
| 233 | + |
| 234 | +## Quick Start - Headed |
| 235 | + |
| 236 | +**Interactive Mode (Cypress UI, pick tests manually):** |
| 237 | +```bash |
| 238 | +npm run cypress:open |
| 239 | +``` |
| 240 | + |
| 241 | +**Base headed mode command:** |
| 242 | +```bash |
| 243 | +npm run cypress:run -- --headed |
| 244 | +``` |
| 245 | + |
| 246 | +--- |
| 247 | + |
| 248 | +## Dynamic Command Discovery |
| 249 | + |
| 250 | +**IMPORTANT**: Before showing test commands, you MUST dynamically read: |
| 251 | + |
| 252 | +### 1. Available Test Spec Files |
| 253 | +Scan `web/cypress/e2e/` directory recursively and list all `.cy.ts` files. |
| 254 | +Present them as available spec file targets with `--headed` flag. |
| 255 | + |
| 256 | +### 2. Available Tags |
| 257 | +Extract grepTags patterns from `web/package.json` scripts to show common tag combinations. |
| 258 | + |
| 259 | +--- |
| 260 | + |
| 261 | +## Running Test Suites - Headed |
| 262 | + |
| 263 | +To run any tag-based suite in headed mode, add `--headed` flag: |
| 264 | +```bash |
| 265 | +npm run cypress:run -- --headed --env grepTags="<TAG_COMBINATION>" |
| 266 | +``` |
| 267 | + |
| 268 | +**Examples based on common tags:** |
| 269 | +```bash |
| 270 | +# Monitoring tests (headed) |
| 271 | +npm run cypress:run -- --headed --env grepTags="@monitoring --@flaky" |
| 272 | + |
| 273 | +# Smoke tests (headed) |
| 274 | +npm run cypress:run -- --headed --env grepTags="@smoke --@flaky" |
| 275 | + |
| 276 | +# COO tests (headed) |
| 277 | +npm run cypress:run -- --headed --env grepTags="@coo --@flaky" |
| 278 | +``` |
| 279 | + |
| 280 | +--- |
| 281 | + |
| 282 | +## Running Specific Files - Headed |
| 283 | + |
| 284 | +**Template:** |
| 285 | +```bash |
| 286 | +npm run cypress:run -- --headed --spec "cypress/e2e/<path-to-file>.cy.ts" |
| 287 | +``` |
| 288 | + |
| 289 | +**Instructions**: Scan `web/cypress/e2e/` and for each `.cy.ts` file, the headed command is: |
| 290 | +```bash |
| 291 | +npm run cypress:run -- --headed --spec "cypress/e2e/<relative-path>" |
| 292 | +``` |
| 293 | + |
| 294 | +--- |
| 295 | + |
| 296 | +## Advanced Headed Options |
| 297 | + |
| 298 | +**Headed with specific browser:** |
| 299 | +```bash |
| 300 | +npm run cypress:run -- --headed --browser chrome |
| 301 | +npm run cypress:run -- --headed --browser firefox |
| 302 | +npm run cypress:run -- --headed --browser edge |
| 303 | +``` |
| 304 | + |
| 305 | +**Headed without video:** |
| 306 | +```bash |
| 307 | +npm run cypress:run -- --headed --config video=false |
| 308 | +``` |
| 309 | + |
| 310 | +--- |
| 311 | + |
| 312 | +## Available Tags Reference |
| 313 | + |
| 314 | +Use these tags with `--env grepTags`: |
| 315 | + |
| 316 | +**Feature Tags:** |
| 317 | +- `@monitoring` - Core monitoring plugin tests |
| 318 | +- `@monitoring-dev` - Developer user tests |
| 319 | +- `@alerts` - Alert-related tests |
| 320 | +- `@metrics` - Metrics explorer tests |
| 321 | +- `@dashboards` - Legacy dashboard tests |
| 322 | +- `@perses` - Perses dashboard tests |
| 323 | +- `@coo` - Observability Operator tests |
| 324 | +- `@acm` - Advanced Cluster Management tests |
| 325 | +- `@virtualization` - OpenShift Virtualization tests |
| 326 | +- `@incidents` - Incidents feature tests |
| 327 | + |
| 328 | +**Modifier Tags:** |
| 329 | +- `@smoke` - Quick smoke tests |
| 330 | +- `@slow` - Longer running tests |
| 331 | +- `@flaky` - Known flaky tests |
| 332 | +- `@demo` - Demo/showcase tests |
| 333 | + |
| 334 | +**Tag Operators:** |
| 335 | +- `+` = AND (e.g., `@alerts+@smoke` = alerts AND smoke) |
| 336 | +- `--` = NOT (e.g., `@monitoring --@flaky` = monitoring but NOT flaky) |
| 337 | +- `,` = OR (e.g., `@alerts,@metrics` = alerts OR metrics) |
| 338 | + |
| 339 | +--- |
| 340 | + |
| 341 | +## Related Commands |
| 342 | + |
| 343 | +- **`/cypress-setup`** - Configure testing environment and open Cypress Tests terminal |
| 344 | + |
| 345 | +--- |
| 346 | + |
| 347 | +## Running Commands via Scripts |
| 348 | + |
| 349 | +All cypress commands should be executed in the "Cypress Tests" terminal using: |
| 350 | + |
| 351 | +**macOS:** |
| 352 | +```bash |
| 353 | +./.claude/commands/cypress/scripts/open-cypress-terminal-macos.sh --run "<your-command>" |
| 354 | +``` |
| 355 | + |
| 356 | +**Linux:** |
| 357 | +```bash |
| 358 | +./.claude/commands/cypress/scripts/open-cypress-terminal-linux.sh --run "<your-command>" |
| 359 | +``` |
| 360 | + |
| 361 | +**Examples:** |
| 362 | +```bash |
| 363 | +# Run smoke tests (macOS) |
| 364 | +./.claude/commands/cypress/scripts/open-cypress-terminal-macos.sh --run "npm run test-cypress-smoke" |
| 365 | + |
| 366 | +# Run specific spec file (macOS) |
| 367 | +./.claude/commands/cypress/scripts/open-cypress-terminal-macos.sh --run "npm run cypress:run -- --spec 'cypress/e2e/monitoring/00.bvt_admin.cy.ts'" |
| 368 | + |
| 369 | +# Run with custom tags (macOS) |
| 370 | +./.claude/commands/cypress/scripts/open-cypress-terminal-macos.sh --run "npm run cypress:run -- --env grepTags='@monitoring --@flaky'" |
| 371 | + |
| 372 | +# Open interactive mode (macOS) |
| 373 | +./.claude/commands/cypress/scripts/open-cypress-terminal-macos.sh --run "npm run cypress:open" |
| 374 | +``` |
| 375 | + |
| 376 | +--- |
| 377 | + |
| 378 | +## Documentation |
| 379 | + |
| 380 | +- `web/cypress/README.md` - Setup and execution guide |
| 381 | +- `web/cypress/E2E_TEST_SCENARIOS.md` - Complete test catalog |
| 382 | +- `web/cypress/CYPRESS_TESTING_GUIDE.md` - Testing best practices |
0 commit comments