Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .claude/commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,96 @@ The command will:
- For operators, you can specify entire catalogs (`full: true`) or individual packages
- Use digests instead of tags for additional images when you need reproducible mirrors

### `/test-pr`

Interactive PR testing assistant that analyzes GitHub Pull Request changes and helps plan a comprehensive testing strategy.

#### What it does

This command fetches a PR's diff using `git` (no `gh` CLI required), analyzes the changes, and walks you through an interactive testing workflow. It identifies testable functions, integration points, and user workflows affected by the PR, then provides targeted guidance for the test types you select.

#### Usage

```
/test-pr <PR_URL_or_NUMBER>
```

The PR can be specified as:
- Full URL: `https://github.com/owner/repo/pull/123`
- Short format: `owner/repo#123`
- Just the number: `123` (if in the current repo)

#### How it works

1. **Fetches the PR diff** using `git fetch origin pull/<number>/head` and analyzes files modified, scope of changes, code patterns, and existing test coverage.

2. **Asks which test types you need** (multi-select):
- Unit Tests
- Integration Tests
- E2E Tests
- Regression Tests
- Manual Tests
- Ad-hoc / Exploratory Tests

3. **Provides detailed guidance per test type**, including:
- **Unit Tests** - Lists testable functions with file paths and line numbers, offers test templates, run commands, and coverage checks
- **Integration Tests** - Identifies integration points between components, suggests scenarios, and provides run commands
- **E2E Tests** - Maps affected user workflows (e.g., M2D, D2M, M2M for oc-mirror), provides prerequisite setup and execution steps
- **Regression Tests** - Lists affected code paths and existing test suites to run
- **Manual Tests** - Generates step-by-step test procedures with expected results
- **Ad-hoc/Exploratory Tests** - Suggests focus areas, boundary conditions, and error scenarios to try

4. **Loops interactively** - After covering one function or scenario, asks what to do next: test another function, move to another test type, or finish.

#### Example

```
User: /test-pr https://github.com/openshift/oc-mirror/pull/1234

Claude: I'll analyze PR #1234 for testing requirements.
[Fetches PR diff, analyzes changes]

This PR modifies the mirror workflow and adds a new validation function.
Which types of tests do you need?
[Presents multi-select options]

User: Unit and E2E tests

Claude: For unit tests, I found these functions that need testing:
1. ValidateImageSetConfig() in pkg/config/validate.go:45
2. ProcessManifest() in pkg/mirror/manifest.go:123
3. CalculateDigest() in pkg/image/digest.go:78

Which function should we test first?

User: ValidateImageSetConfig

Claude: [Provides test template, run commands, coverage steps]

What would you like to do next?
- Test another function (ProcessManifest, CalculateDigest)
- Move to E2E tests
- Done

User: Move to E2E tests

Claude: For E2E tests, these workflows need testing:
1. M2D workflow
2. D2M workflow
3. M2M workflow

Which workflow should we test first?

[Process continues...]
```

#### Tips

- The command uses only `git` to fetch PR data, so no `gh` CLI authentication is needed
- It prioritizes tests based on risk and complexity of the changes
- If the PR already includes test files, it reviews them and suggests improvements
- Test templates follow existing project conventions and patterns

## Adding New Commands

To add a new slash command:
Expand Down
Loading