Skip to content

Conversation

@youngchingjui
Copy link
Owner

@youngchingjui youngchingjui commented Jan 3, 2026

Motivation

  • Validate that recent changes to persisting workflow runs still produce the expected graph model (repositories, issues, actors, commits, and relationships).
  • Provide integration coverage that exercises StorageAdapter.workflow.run.create to increase confidence in DB writes.
  • Give maintainers a repeatable test scaffold for local Neo4j verification of workflow run persistence.

Description

  • Add __tests__/shared/adapters/neo4j/StorageAdapter.workflowRun.create.neo4j.test.ts with two integration tests that create workflow runs and assert repository/issue/actor/commit nodes and relationships.
  • Add cleanupWorkflowRunTestData helper to __tests__/shared/adapters/neo4j/testUtils.ts to remove test-created WorkflowRun, Repository, Issue, User, GithubUser, and Commit nodes after tests.
  • Tests use StorageAdapter to exercise the creation code paths for both user and webhook actor types and for optional commit payloads.
  • Include small test helpers such as buildCommitSha and numeric conversion logic to normalize Neo4j integer values in assertions.

Testing

  • These are Neo4j integration tests intended to be run locally with a running Neo4j instance using pnpm test:neo4j and .env.local containing NEO4J_URI, NEO4J_USER, and NEO4J_PASSWORD.
  • The test suite includes a verifyConnection check that will fail if the database is not reachable, preventing false positives.
  • No automated tests were executed in this rollout environment (tests require a local Neo4j instance); run the tests locally to validate behavior.
  • After running, the added cleanup helper can be used to remove created nodes so the test database remains clean.

Codex Task

Summary by CodeRabbit

  • Tests
    • Added a new integration test suite validating workflow run creation, related entities (repository, issue, actor, commits/webhooks) and lifecycle scenarios.
    • Added test utilities to perform targeted cleanup of workflow-run-related test data, improving test isolation and teardown.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel vercel bot temporarily deployed to Preview – issue-to-pr-realtime January 3, 2026 12:26 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-storybook January 3, 2026 12:26 Inactive
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

Walkthrough

Adds an integration test suite for WorkflowRun creation against the Neo4j StorageAdapter and a test utility to clean up WorkflowRun-related test data (repositories, issues, users, github users, commits, and runs).

Changes

Cohort / File(s) Summary
Neo4j StorageAdapter Tests
__tests__/shared/adapters/neo4j/StorageAdapter.workflowRun.create.neo4j.test.ts
New integration tests validating WorkflowRun creation and relationships: repository, issue, actor (user and webhook/github sender), commit linkage, setup/teardown using a running Neo4j instance.
Test Utilities
__tests__/shared/adapters/neo4j/testUtils.ts
Added cleanupWorkflowRunTestData exported helper that conditionally deletes WorkflowRun, Issue, Repository, User, GithubUser, and Commit nodes by provided identifiers via separate Cypher DETACH DELETE operations.

Possibly related issues

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between daf61bd and dec2669.

📒 Files selected for processing (1)
  • __tests__/shared/adapters/neo4j/testUtils.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/shared/adapters/neo4j/testUtils.ts

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel vercel bot temporarily deployed to Preview – issue-to-pr-realtime January 3, 2026 15:46 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-storybook January 3, 2026 15:46 Inactive
@youngchingjui youngchingjui marked this pull request as ready for review January 3, 2026 15:49
Copy link
Owner Author

@youngchingjui youngchingjui left a comment

Choose a reason for hiding this comment

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

@coderabbitai is this safe? what are some concerns that I should think about?

Copy link
Owner Author

@youngchingjui youngchingjui left a comment

Choose a reason for hiding this comment

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

@coderabbitai review

@youngchingjui
Copy link
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
__tests__/shared/adapters/neo4j/StorageAdapter.workflowRun.create.neo4j.test.ts (1)

39-48: Consider deferring dataSource creation to beforeAll.

createTestDataSource() at module scope throws during test file loading if env vars are missing, which can interfere with test discovery. Moving it to beforeAll would allow the test runner to list tests even when the database is unavailable.

🔎 Proposed refactor
 describe("StorageAdapter - WorkflowRun creation", () => {
   let adapter: StorageAdapter
-  const dataSource = createTestDataSource()
+  let dataSource: ReturnType<typeof createTestDataSource>

   const runIds: string[] = []
   const repoIds: string[] = []
   const issues: { repoFullName: string; number: number }[] = []
   const userIds: string[] = []
   const githubUserIds: string[] = []
   const commitShas: string[] = []

   beforeAll(async () => {
+    dataSource = createTestDataSource()
     await verifyConnection(dataSource)
     adapter = new StorageAdapter(dataSource)
   })
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5058c6a and daf61bd.

📒 Files selected for processing (2)
  • __tests__/shared/adapters/neo4j/StorageAdapter.workflowRun.create.neo4j.test.ts
  • __tests__/shared/adapters/neo4j/testUtils.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx,mts,mjs}

📄 CodeRabbit inference engine (.cursor/rules/code-structure.mdc)

Avoid barrel files: do not create files whose sole purpose is to re-export symbols from multiple modules; prefer importing from original module paths to maintain clear dependency graphs and better tree-shaking

Files:

  • __tests__/shared/adapters/neo4j/testUtils.ts
  • __tests__/shared/adapters/neo4j/StorageAdapter.workflowRun.create.neo4j.test.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: shared/src/ports/events/publisher.ts:16-19
Timestamp: 2025-09-22T09:24:26.840Z
Learning: youngchingjui prefers to manage PR scope tightly and defer technical debt improvements to future PRs rather than expanding the current PR's scope, even for related consistency issues.
📚 Learning: 2026-01-02T09:21:36.652Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1450
File: shared/src/adapters/neo4j/types.ts:12-17
Timestamp: 2026-01-02T09:21:36.652Z
Learning: In the Neo4j data model at shared/src/adapters/neo4j/types.ts, the WorkflowRun node intentionally does not include a `state` field. The workflow run state is derived from the chain of events rather than being stored directly on the WorkflowRun node, following an event sourcing pattern where state is computed by replaying events.

Applied to files:

  • __tests__/shared/adapters/neo4j/testUtils.ts
  • __tests__/shared/adapters/neo4j/StorageAdapter.workflowRun.create.neo4j.test.ts
📚 Learning: 2025-09-22T09:34:43.580Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/neo4j/convert.ts:69-74
Timestamp: 2025-09-22T09:34:43.580Z
Learning: The file lib/neo4j/convert.ts is being moved away from/deprecated, so fixes in this file may not be worth implementing since it will be replaced.

Applied to files:

  • __tests__/shared/adapters/neo4j/testUtils.ts
📚 Learning: 2025-09-22T09:28:41.886Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1282
File: lib/adapters/PersistingEventBusAdapter.ts:55-58
Timestamp: 2025-09-22T09:28:41.886Z
Learning: The project is migrating away from neo4j/services/event adapters, so issues in files like lib/adapters/PersistingEventBusAdapter.ts that use these adapters may be temporary and lower priority.

Applied to files:

  • __tests__/shared/adapters/neo4j/testUtils.ts
📚 Learning: 2026-01-02T09:20:53.213Z
Learnt from: youngchingjui
Repo: youngchingjui/issue-to-pr PR: 1450
File: shared/src/adapters/neo4j/types.ts:272-283
Timestamp: 2026-01-02T09:20:53.213Z
Learning: The plan schema and llmResponseWithPlanSchema in shared/src/adapters/neo4j/types.ts are being migrated away/deprecated, so schema inconsistencies related to plan support do not need to be fixed.

Applied to files:

  • __tests__/shared/adapters/neo4j/testUtils.ts
🧬 Code graph analysis (1)
__tests__/shared/adapters/neo4j/testUtils.ts (1)
shared/src/adapters/neo4j/dataSource.ts (1)
  • Neo4jDataSource (10-13)
🔇 Additional comments (4)
__tests__/shared/adapters/neo4j/testUtils.ts (1)

78-166: LGTM - Clean and comprehensive test data cleanup utility.

The function correctly:

  • Uses parameterized Cypher queries to avoid injection
  • Handles session cleanup in a finally block
  • Skips empty arrays to avoid unnecessary queries
  • Uses DETACH DELETE to remove nodes with their relationships

Note: Individual queries are not wrapped in a transaction, so partial cleanup may occur if an error is thrown mid-execution. This is acceptable for test cleanup purposes where atomicity isn't critical.

__tests__/shared/adapters/neo4j/StorageAdapter.workflowRun.create.neo4j.test.ts (3)

29-37: LGTM - Helper functions are well-designed.

The toNumber helper correctly handles Neo4j integer types which can exceed JavaScript's safe integer range. The buildCommitSha helper generates valid 40-character hex strings suitable for test commit SHAs.


67-134: LGTM - Comprehensive test for user actor workflow run creation.

The test properly:

  • Generates unique identifiers to avoid test collisions
  • Registers test data for cleanup before the operation (ensuring cleanup even if creation fails)
  • Verifies all expected relationships and node properties
  • Handles Neo4j integer types correctly with toNumber()

136-224: LGTM - Thorough test for webhook actor with commit data.

The test validates the more complex flow with:

  • Webhook actor type correctly persisting as GithubUser node
  • Commit node creation with expected properties
  • BASED_ON_COMMIT relationship from WorkflowRun
  • IN_REPOSITORY relationship from Commit to Repository

Good coverage of the optional commit payload path.

Base automatically changed from feature/workflows-repo-user-attribution-nodes to main January 9, 2026 02:26
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-realtime January 13, 2026 07:39 Inactive
@vercel vercel bot temporarily deployed to Preview – issue-to-pr-storybook January 13, 2026 07:39 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants