Skip to content

Commit 08f7dbf

Browse files
pedjakclaude
andcommitted
Add list-e2e-steps Claude Code command
Add a Claude Code skill that generates a categorized reference of all Godog e2e step definitions. Add doc comments to exported step handler functions documenting their behavior and polling characteristics. Update e2e README with usage instructions. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent e17412a commit 08f7dbf

File tree

3 files changed

+156
-0
lines changed

3 files changed

+156
-0
lines changed

.claude/commands/list-e2e-steps.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
description: List all available Godog e2e step definitions with categories, parameters, and descriptions
3+
---
4+
5+
# List E2E Steps
6+
7+
Generate a categorized reference of all Godog (Cucumber BDD) step definitions available for writing e2e feature files.
8+
9+
## Instructions for Claude AI
10+
11+
When this command is invoked, you MUST:
12+
13+
**CRITICAL:** The final output MUST be a comprehensive categorized reference displayed directly in the conversation. Do NOT just create files - output the full reference as your response.
14+
15+
1. **Get the authoritative list of registered step patterns**
16+
17+
Run:
18+
```bash
19+
go test ./test/e2e/features_test.go -d || true 2>&1
20+
```
21+
The `-d` flag prints all registered step definitions without running tests. Parse each step regex pattern from the output.
22+
23+
2. **Read the step registration and handler implementations**
24+
25+
Read `test/e2e/steps/steps.go` and locate the `RegisterSteps()` function. For each regex pattern from step 1, find its corresponding `sc.Step()` call and the handler function it references.
26+
27+
Then read each handler function's signature to determine:
28+
- What parameters it accepts (string, int, `*godog.DocString`, etc.)
29+
- Whether it expects a DocString (multi-line YAML block in the feature file)
30+
31+
Consult the handler documentation to understand what the step does. If the documentation is missing,
32+
check what the handler actually does (kubectl commands, polling, assertions, etc.)
33+
34+
3. **Output a categorized reference**
35+
36+
Organize all steps into the following categories and format. Use the information gathered from the handler implementations to write accurate descriptions.
37+
38+
### Output Format
39+
40+
Start with a variable substitution reference, then list steps by category.
41+
42+
---
43+
44+
#### Variable Substitution
45+
46+
These variables are automatically replaced in DocString content and some string parameters:
47+
48+
| Variable | Replaced With | Example |
49+
|---|---|-----------------------------------------------|
50+
| `${TEST_NAMESPACE}` | Scenario's test namespace | `olmv1-e2e-abc123` |
51+
| `${NAME}` | Current ClusterExtension name | `ce-123` |
52+
53+
---
54+
55+
#### Categories
56+
57+
Organize steps into these 10 categories. For each step, document:
58+
- **Pattern**: The human-readable Gherkin step text (with capture groups shown as `<arg>`)
59+
- **Parameters**: Each captured parameter with its Go type
60+
- **DocString**: Whether the step expects a `"""` YAML block (and what it should contain)
61+
- **Description**: What the handler function does, based on reading its documentation
62+
63+
**Categories:**
64+
65+
1. **Setup & Prerequisites** - OLM availability, ServiceAccount setup, permissions
66+
2. **Catalog Management** - ClusterCatalog creation, updates, image tagging, deletion
67+
3. **ClusterExtension Lifecycle** - Apply, update, remove ClusterExtension resources
68+
4. **ClusterExtension Status & Conditions** - Condition checks, transition times, reconciliation
69+
5. **ClusterExtensionRevision** - Revision-specific condition checks, archival, annotations, labels, active revisions
70+
7. **Generic Resource Operations** - Get, delete, restore, match arbitrary resources
71+
8. **Test Operator Control** - Marking test-operator deployment ready/not-ready
72+
9. **Metrics** - Fetching and validating Prometheus metrics
73+
10. **CRD Patching** - Setting minimum values on CRD fields
74+
75+
Group steps by category.
76+
77+
For each step entry, use this format:
78+
79+
```
80+
### <N>. <Category Name>
81+
82+
#### `<human-readable pattern>`
83+
- **Parameters:** `<name>` (string), ...
84+
- **DocString:** Yes/No — <what to include if yes>
85+
- **Description:** <what the handler does>
86+
- **Handler:** `<FunctionName>` in steps.go:<line>
87+
- **Polling:** Yes/No - <specify the timeout if yes>
88+
```
89+
90+
---
91+
92+
#### Notes Section
93+
94+
After all categories, include a **Notes** section covering:
95+
96+
- **Case insensitivity**: Most patterns use `(?i)` — step text is case-insensitive
97+
- **Resource format**: Steps accepting a `"resource"` parameter expect `kind/name` format (e.g., `"deployment/my-deploy"`)
98+
- **Scenario context**: The ClusterExtension name is auto-captured when a ClusterExtension is applied — subsequent steps reference it implicitly
99+
- **Duplicate aliases**: Some steps have multiple patterns mapping to the same handler (e.g., `resource "X" is installed` / `resource "X" is available` / `resource "X" exists` all map to `ResourceAvailable`). Note which are aliases.
100+
- **Catalog naming convention**: Catalog steps automatically append `-catalog` to the name parameter (e.g., `"test"` becomes `"test-catalog"`)

test/e2e/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ A list of available, implemented steps can be obtained by running:
335335
go test test/e2e/features_test.go -d
336336
```
337337

338+
When working with [Claude Code](https://claude.com/claude-code), run the `/list-e2e-steps` command to get a categorized
339+
reference of all step definitions including parameters, DocString expectations, polling behavior, and handler locations.
340+
This is useful when writing new feature files or debugging existing scenarios.
341+
338342
## Best Practices
339343

340344
1. **Keep scenarios focused**: Each scenario should test one specific behavior

0 commit comments

Comments
 (0)