Skip to content

test(git): e2e coverage for the Git integration, plus fixes it found - #636

Merged
pikann merged 3 commits into
masterfrom
feature/add-e2e-tests-for-git-feature
Oct 25, 2026
Merged

pikann merged 3 commits into
masterfrom
feature/add-e2e-tests-for-git-feature

Conversation

@pikann

@pikann pikann commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

End-to-end coverage for the Git integration (permissions, project settings, tasks, agents, setup), plus three backend bugs those tests found and a missing policy resource root. The e2e stack has no Git provider plugin, so specs that need one stub the provider endpoints in the browser with page.route; permissions, projects, tasks and agents are always real.

Bugs found by the new tests (fixed here)

Bug Effect Fix
git_identity was not a known policy resource root A role granting git.identities:manage could not be created (ROLE_POLICY_INVALID, "unknown root") Added the root to the validator (iam/validate.go) + test
DELETE /projects/{id}/git/repositories/{repositoryId} was unreachable Mounting the /{repositoryId} sub-router replaced the Delete registered on the same pattern: every unlink answered a plain router 404, skipping the permission gate Unlink now lives inside the sub-router (router.go)
GET /projects/{id}/tasks/{taskId}/git answered 200 for another project's task Inconsistent with the other task routes (404); no data leaked, the query already filters by project ListTaskGit checks TaskInProject and returns not found
PUT /projects/{id}/git/settings for a project that does not exist answered 500 FK violation surfaced as an internal error Mapped to GIT_NOT_FOUND (404)
A NUL byte (or any odd character) in a webhook endpoint key answered 500 on the public endpoint Postgres rejects \x00 in a text parameter Keys that cannot be ours (not [A-Za-z0-9_-], empty or > 128 chars) are a 404 before the database is touched

New e2e specs (apps/e2e, each with a .feature file)

API / permissions

  • iam/git-permissions: who may read, write, link, approve and merge; workspace identity routes; public webhook.
  • iam/git-ops-gates: one test per operation route (26 routes): open only to the one action it declares (git:read, git:write, git:approve, git:merge, git:*), 403 to everyone else, 401 anonymous; deny wins over a wildcard; id validation.
  • iam/git-role-templates: built-in Editor / Viewer / Admin Git actions, custom roles holding each action, workspace action on its own resource only, Editor works end to end.
  • projects/git-settings-api: defaults, round trip, replace-on-save semantics, every minimum-permission level, validation, default-responder rules, isolation between projects.
  • projects/git-task-links: task Git routes and their permission combinations (tasks:* + git:*), unknown repository, cross-project task.
  • projects/git-agent-api: trigger defaults and explicit choices, unknown kind, identity routes' permissions, no-provider answer (503 GIT_PROVIDER_UNAVAILABLE).
  • security/git-webhook: unknown keys, methods, odd keys, no session needed, /_git not callable from a browser.

UI

  • admin/git-identities, admin/git-setup: admin Git page states, setup dialog payload, remove confirmation, callback page (invalid state, single completion call with raw params, other-origin return URL ignored, next step, access grant).
  • projects/git-settings, projects/git-automation: link form visibility by permission, link errors explained, unlink confirmation, automation saved to the real settings (responder, minimum access, pause), reader view.
  • projects/git-task-detail: PR state and CI badges, branches, link / unlink, rejected link, read-only view.
  • projects/git-agent-tab: shared vs own identity, create / install / remove, trigger groups and switches, reader view.
  • iam/git-role-editor: the four project Git switches and the workspace one store the right actions; stored Git roles reopen in Simple.

Shared helpers are in tests/helpers/git.ts; tests/helpers/e2e-api.ts gains git_identity/* in the workspace resources.

Go unit tests

validate_test.go (resource root), service_test.go (webhook keys, endpoint check, offered identity, cached-credential audit), ops_test.go (foreign task), git_handler_test.go (unknown endpoint refused before the body is read).

Testing

  • docker compose -f deploy/docker-compose.e2e.yml up -d --build --wait, then cd apps/e2e && E2E_WORKERS=2 npx playwright test --project=chromium tests/{iam,projects,admin,security}/git-*.spec.ts: 162 passed.
  • The UI specs also pass on mobile-chrome (the task page hides the author and CI label on narrow screens, so those are asserted as present rather than visible).
  • go test ./internal/service/git/... ./internal/transport/http/... ./internal/platform/authz/... pass.

Notes

  • A 9 MB webhook body through the gateway answered 502 (probably the gateway's limit); not covered.
  • The workspace role editor stores the single-action domain as git.identities:*.

🤖 Generated with Claude Code

…inks

- Implemented e2e tests for Git settings in projects, covering scenarios for linking and managing repositories.
- Created tests for task details to verify linked pull requests and branches, including various states and actions.
- Added tests for the Git task links API to ensure proper permissions and error handling for linking tasks to repositories.
- Introduced security tests for Git webhook intake to validate endpoint behavior and error responses.
- Enhanced IAM validation to include git_identity resources and updated related tests.
- Improved error handling in the Git workflow repository for project settings.
- Updated service logic to ensure tasks from different projects are not accessible.
- Added validation for webhook keys to ensure only plausible keys are accepted.
- Refactored Git handler tests to cover scenarios for unknown webhook endpoints.
@pikann pikann changed the title feat: add end-to-end tests for Git settings, task details, and task l… test(git): e2e coverage for the Git integration, plus fixes it found Oct 25, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — minor suggestions inline.

Reviewed changes

This PR adds the Git end-to-end suite plus several production hardening fixes; the Go tests for the touched packages pass and PR CI is green.

  • Git e2e coverage — 14 feature/spec pairs cover admin identities/setup, IAM gates and role templates/editor, project settings/automation, the agent Git tab/API, task Git detail/links, and webhook intake.
  • IAM resource root — git_identity is accepted by policy validation, so workspace Git-identity roles no longer fail with ROLE_POLICY_INVALID.
  • Settings 404 — a foreign-key violation on project-settings upsert maps to ErrNotFound instead of a 500.
  • Webhook key guard — implausible endpoint keys are rejected before the database lookup in both the check and handle paths.
  • Task project scoping — ListTaskGit returns ErrNotFound for a task in another project.
  • Unlink route fix — the handler moves into the /{repositoryId} subrouter, restoring a route that the later mount was shadowing.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

This run re-reviewed the delta since pullfrog's prior review (e4b7301): six test/feature files tightened in response to the earlier inline findings, with no production code touched.

  • Role-template scenario corrected — the wrong "project resource is refused with 422" claim is replaced by an "accepted but grants nothing" scenario, and the spec now creates the role and asserts 403 on the workspace identity routes.
  • Settings feature line removed — the self-contradictory "a partial update keeps the fields it does not mention" step is gone.
  • Sidebar absence assertion anchored — the admin Git page test now opens a collapsed sidebar and waits for a visible entry the user holds before asserting the Git link is absent.
  • Remove-identity confirm waits for the dialog — the non-waiting isVisible() probe is replaced by a dialog-scoped click on Remove identity.
  • Git task-detail absence and unlink assertions strengthened — the "nothing shown" test waits for the repositories response and the Properties panel first, and both unlink tests assert the resulting empty state.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@pikann
pikann merged commit fad015a into master Oct 25, 2026
7 checks passed
@pikann
pikann deleted the feature/add-e2e-tests-for-git-feature branch October 25, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant