mock.module("fs/promises") on Linux Bun poisons the entire mock
tracking system — not just fs mocks, but ALL mock/spy assertions
(octokit mocks, spyOn(global, "fetch"), etc.) stop recording calls.
Replace with dependency injection: downloadCommentImages() now accepts
an optional fsDeps parameter. Tests pass mock mkdir/writeFile directly.
Production callers omit it and get real fs. No mock.module anywhere.
Fixes 18 test failures blocking CI on Forgejo Linux runners.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
112 lines
6.2 KiB
Markdown
112 lines
6.2 KiB
Markdown
# PRD #6: E2E Test All Untested Forgejo Trigger Scenarios
|
|
|
|
**Issue**: [#6](https://git.wxs.ro/actions/claude-code-action/issues/6)
|
|
**Priority**: High
|
|
**Created**: 2026-02-25
|
|
|
|
---
|
|
|
|
## Problem
|
|
|
|
The Forgejo platform support (PRD #1) was validated for the two most common scenarios (agent mode via `workflow_dispatch` and tag mode via `issue_comment`). However, 5 trigger scenarios remain untested in a live environment:
|
|
|
|
1. PR review comment triggers (`pull_request_review_comment`)
|
|
2. PR review triggers (`pull_request_review`)
|
|
3. Label triggers (`issues` with `labeled` action)
|
|
4. Assignee triggers (`issues` with `assigned` action)
|
|
5. Branch creation + code changes from tag mode (the initial test only asked a question, no code was generated)
|
|
|
|
These untested paths could have silent failures — the code may look correct but break on Forgejo's subtly different webhook payloads, API responses, or event structures.
|
|
|
|
## Solution
|
|
|
|
Systematically exercise each untested scenario on the live Forgejo instance (git.wxs.ro), document results, fix any issues discovered, and update the E2E status table in `docs/forgejo.md`.
|
|
|
|
## Milestones
|
|
|
|
- [x] **M1: Ensure workflow covers all trigger types**
|
|
|
|
- Review `.forgejo/workflows/claude.yml` to confirm all 5 trigger types are listed
|
|
- Add any missing triggers to the workflow file
|
|
- Ensure the workflow has the correct permissions for each trigger type
|
|
- **Validation**: Workflow YAML includes all required `on:` triggers
|
|
|
|
- [x] **M1.5: Fix image-downloader test failures blocking CI**
|
|
|
|
- **Problem**: All 18 `downloadCommentImages` tests failed on Forgejo CI (Linux Bun 1.2.21) while passing locally on macOS. This blocked all PRs.
|
|
- **Root cause**: `mock.module("fs/promises")` on Linux Bun poisons the entire mock tracking system — not just fs mocks, but ALL mock/spy assertions in the file (octokit parameter mocks, `spyOn(global, "fetch")`, etc.) stopped recording calls. The only passing test used a **negative** assertion (`not.toHaveBeenCalledWith`) which trivially passes when tracking is broken.
|
|
- **History of failed attempts**:
|
|
1. Upstream uses `spyOn(fs, "mkdir")` — works on GitHub CI (Bun 1.2.12/ubuntu) but fails on Forgejo Linux (different `fs/promises` object references between test and source modules)
|
|
2. `96ec04e` tried `_fsForTest` mutable export — abandoned
|
|
3. `cff360d` tried dependency injection — replaced
|
|
4. `dab92ef` tried `mock.module("fs/promises")` — works on macOS, poisons mock tracking on Linux
|
|
- **Fix**: Dependency injection via optional `fsDeps` parameter on `downloadCommentImages()`. Tests pass mock `mkdir`/`writeFile` directly — no module-level mocking at all. Production callers omit the parameter and get real `fs`. Zero `mock.module` usage in the test file.
|
|
- **Validation**: 797/797 tests pass locally, typecheck clean. Awaiting CI confirmation.
|
|
|
|
- [ ] **M2: Test PR review comment trigger**
|
|
|
|
- Create a test PR on the repo
|
|
- Post a review comment with `@claude` mention
|
|
- Verify: platform detection, context fetching (PR diff, review comment body), tracking comment, Claude response
|
|
- Document any issues and fix them
|
|
- **Validation**: Claude responds correctly to `@claude` in a PR review comment
|
|
|
|
- [ ] **M3: Test PR review trigger**
|
|
|
|
- Create a test PR on the repo
|
|
- Submit a review with `@claude` mention in the review body
|
|
- Verify: platform detection, context fetching, tracking comment, Claude response
|
|
- Document any issues and fix them
|
|
- **Validation**: Claude responds correctly to `@claude` in a PR review
|
|
|
|
- [ ] **M4: Test label trigger**
|
|
|
|
- Create a label (e.g., `claude`) that triggers the action when applied to an issue
|
|
- Apply the label to a test issue
|
|
- Verify: trigger detection, context fetching (issue body/title), Claude response
|
|
- Document any issues and fix them
|
|
- **Validation**: Claude responds when the configured label is applied to an issue
|
|
|
|
- [ ] **M5: Test assignee trigger**
|
|
|
|
- Assign a user to an issue to trigger the action
|
|
- Verify: trigger detection, context fetching, Claude response
|
|
- Document any issues and fix them
|
|
- **Validation**: Claude responds when assigned to an issue
|
|
|
|
- [ ] **M6: Test tag mode with code changes (branch creation)**
|
|
|
|
- Create an issue requesting a code change (e.g., "add a comment to file X")
|
|
- Trigger Claude via `@claude` mention
|
|
- Verify: Claude creates a branch, pushes commits, links the branch in tracking comment
|
|
- Verify the Forgejo-specific PR compare URL format is correct
|
|
- **Validation**: Claude successfully creates a branch with code changes on Forgejo
|
|
|
|
- [ ] **M7: Update documentation with E2E results**
|
|
- Update `docs/forgejo.md` E2E status table with results for all 5 scenarios
|
|
- Move tested items from "Not Yet E2E Tested" to the validated table
|
|
- Document any Forgejo-specific quirks or limitations discovered
|
|
- Add troubleshooting entries for any issues encountered
|
|
- **Validation**: `docs/forgejo.md` accurately reflects the current E2E validation status
|
|
|
|
## Dependencies
|
|
|
|
- PRD #5 (Dedicated Forgejo User) is recommended but not strictly required — tests can run with the current token setup
|
|
- A test repository on git.wxs.ro with the action workflow configured
|
|
|
|
## Risks
|
|
|
|
| Risk | Mitigation |
|
|
| -------------------------------------------------------- | ----------------------------------------------------------- |
|
|
| Forgejo webhook payloads differ from expected | Log raw payloads, compare with GitHub format, adapt parsing |
|
|
| Trigger type not supported by Forgejo Actions | Document as known limitation, skip gracefully |
|
|
| Action creates unwanted branches/comments during testing | Use a dedicated test repo or clean up after each test |
|
|
| Bun mock.module breaks mock tracking on Linux | Use dependency injection for fs mocks, never mock.module |
|
|
|
|
## Success Criteria
|
|
|
|
- All 5 previously untested scenarios have been exercised on a live Forgejo instance
|
|
- Any bugs discovered are fixed and tested
|
|
- `docs/forgejo.md` E2E status table is fully up-to-date
|
|
- "Not Yet E2E Tested" section is empty (all items moved to validated or documented as unsupported)
|