hungry-ghost-hive 0.48.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/base-agent.d.ts +11 -11
- package/dist/agents/base-agent.d.ts.map +1 -1
- package/dist/agents/base-agent.js +25 -25
- package/dist/agents/base-agent.js.map +1 -1
- package/dist/agents/base-agent.test.js +2 -1
- package/dist/agents/base-agent.test.js.map +1 -1
- package/dist/agents/intermediate.d.ts +2 -0
- package/dist/agents/intermediate.d.ts.map +1 -1
- package/dist/agents/intermediate.js +25 -18
- package/dist/agents/intermediate.js.map +1 -1
- package/dist/agents/junior.d.ts +2 -0
- package/dist/agents/junior.d.ts.map +1 -1
- package/dist/agents/junior.js +25 -18
- package/dist/agents/junior.js.map +1 -1
- package/dist/agents/qa.d.ts +2 -0
- package/dist/agents/qa.d.ts.map +1 -1
- package/dist/agents/qa.js +47 -38
- package/dist/agents/qa.js.map +1 -1
- package/dist/agents/senior.d.ts +2 -0
- package/dist/agents/senior.d.ts.map +1 -1
- package/dist/agents/senior.js +40 -27
- package/dist/agents/senior.js.map +1 -1
- package/dist/agents/tech-lead.d.ts +2 -0
- package/dist/agents/tech-lead.d.ts.map +1 -1
- package/dist/agents/tech-lead.js +37 -31
- package/dist/agents/tech-lead.js.map +1 -1
- package/dist/cli/commands/add-repo.js +2 -2
- package/dist/cli/commands/add-repo.js.map +1 -1
- package/dist/cli/commands/add-repo.test.js +1 -1
- package/dist/cli/commands/add-repo.test.js.map +1 -1
- package/dist/cli/commands/agents.d.ts.map +1 -1
- package/dist/cli/commands/agents.js +12 -10
- package/dist/cli/commands/agents.js.map +1 -1
- package/dist/cli/commands/agents.test.js +7 -7
- package/dist/cli/commands/agents.test.js.map +1 -1
- package/dist/cli/commands/approach.js +2 -2
- package/dist/cli/commands/approach.js.map +1 -1
- package/dist/cli/commands/approvals.js +7 -7
- package/dist/cli/commands/approvals.js.map +1 -1
- package/dist/cli/commands/approvals.test.js +8 -8
- package/dist/cli/commands/approvals.test.js.map +1 -1
- package/dist/cli/commands/assign.js +4 -4
- package/dist/cli/commands/assign.js.map +1 -1
- package/dist/cli/commands/assign.test.js +18 -16
- package/dist/cli/commands/assign.test.js.map +1 -1
- package/dist/cli/commands/cleanup.d.ts.map +1 -1
- package/dist/cli/commands/cleanup.js +8 -8
- package/dist/cli/commands/cleanup.js.map +1 -1
- package/dist/cli/commands/cleanup.test.js +5 -1
- package/dist/cli/commands/cleanup.test.js.map +1 -1
- package/dist/cli/commands/escalations.js +9 -7
- package/dist/cli/commands/escalations.js.map +1 -1
- package/dist/cli/commands/escalations.test.js +2 -2
- package/dist/cli/commands/escalations.test.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +48 -5
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/init.test.js +4 -0
- package/dist/cli/commands/init.test.js.map +1 -1
- package/dist/cli/commands/manager/agent-monitoring.d.ts +2 -2
- package/dist/cli/commands/manager/agent-monitoring.d.ts.map +1 -1
- package/dist/cli/commands/manager/agent-monitoring.js +1 -1
- package/dist/cli/commands/manager/agent-monitoring.js.map +1 -1
- package/dist/cli/commands/manager/auditor-lifecycle.js +3 -3
- package/dist/cli/commands/manager/auditor-lifecycle.js.map +1 -1
- package/dist/cli/commands/manager/auditor-lifecycle.test.js +21 -14
- package/dist/cli/commands/manager/auditor-lifecycle.test.js.map +1 -1
- package/dist/cli/commands/manager/auto-reject-comment-only-reviews.test.js +28 -23
- package/dist/cli/commands/manager/auto-reject-comment-only-reviews.test.js.map +1 -1
- package/dist/cli/commands/manager/escalation-handler.d.ts +2 -2
- package/dist/cli/commands/manager/escalation-handler.d.ts.map +1 -1
- package/dist/cli/commands/manager/escalation-handler.js +11 -10
- package/dist/cli/commands/manager/escalation-handler.js.map +1 -1
- package/dist/cli/commands/manager/escalation-handler.test.js +8 -8
- package/dist/cli/commands/manager/escalation-handler.test.js.map +1 -1
- package/dist/cli/commands/manager/feature-sign-off.js +7 -7
- package/dist/cli/commands/manager/feature-sign-off.js.map +1 -1
- package/dist/cli/commands/manager/feature-sign-off.test.js +40 -31
- package/dist/cli/commands/manager/feature-sign-off.test.js.map +1 -1
- package/dist/cli/commands/manager/feature-test-result.d.ts.map +1 -1
- package/dist/cli/commands/manager/feature-test-result.js +12 -13
- package/dist/cli/commands/manager/feature-test-result.js.map +1 -1
- package/dist/cli/commands/manager/handoff-recovery.d.ts.map +1 -1
- package/dist/cli/commands/manager/handoff-recovery.js +14 -15
- package/dist/cli/commands/manager/handoff-recovery.js.map +1 -1
- package/dist/cli/commands/manager/index.d.ts.map +1 -1
- package/dist/cli/commands/manager/index.js +26 -26
- package/dist/cli/commands/manager/index.js.map +1 -1
- package/dist/cli/commands/manager/index.test.js +3 -3
- package/dist/cli/commands/manager/index.test.js.map +1 -1
- package/dist/cli/commands/manager/merged-story-cleanup.d.ts +2 -2
- package/dist/cli/commands/manager/merged-story-cleanup.d.ts.map +1 -1
- package/dist/cli/commands/manager/merged-story-cleanup.js +6 -7
- package/dist/cli/commands/manager/merged-story-cleanup.js.map +1 -1
- package/dist/cli/commands/manager/merged-story-cleanup.test.js +27 -18
- package/dist/cli/commands/manager/merged-story-cleanup.test.js.map +1 -1
- package/dist/cli/commands/manager/pr-sync-orchestrator.d.ts.map +1 -1
- package/dist/cli/commands/manager/pr-sync-orchestrator.js +46 -38
- package/dist/cli/commands/manager/pr-sync-orchestrator.js.map +1 -1
- package/dist/cli/commands/manager/qa-review-handler.d.ts.map +1 -1
- package/dist/cli/commands/manager/qa-review-handler.js +25 -22
- package/dist/cli/commands/manager/qa-review-handler.js.map +1 -1
- package/dist/cli/commands/manager/spin-down.d.ts.map +1 -1
- package/dist/cli/commands/manager/spin-down.js +23 -19
- package/dist/cli/commands/manager/spin-down.js.map +1 -1
- package/dist/cli/commands/manager/stale-escalations.d.ts +2 -3
- package/dist/cli/commands/manager/stale-escalations.d.ts.map +1 -1
- package/dist/cli/commands/manager/stale-escalations.js.map +1 -1
- package/dist/cli/commands/manager/stuck-story-helpers.js +8 -8
- package/dist/cli/commands/manager/stuck-story-helpers.js.map +1 -1
- package/dist/cli/commands/manager/stuck-story-processor.d.ts +2 -2
- package/dist/cli/commands/manager/stuck-story-processor.d.ts.map +1 -1
- package/dist/cli/commands/manager/stuck-story-processor.js +23 -22
- package/dist/cli/commands/manager/stuck-story-processor.js.map +1 -1
- package/dist/cli/commands/manager/tech-lead-lifecycle.js +6 -6
- package/dist/cli/commands/manager/tech-lead-lifecycle.js.map +1 -1
- package/dist/cli/commands/manager/types.d.ts +2 -3
- package/dist/cli/commands/manager/types.d.ts.map +1 -1
- package/dist/cli/commands/manager/types.js.map +1 -1
- package/dist/cli/commands/msg.test.js +2 -2
- package/dist/cli/commands/msg.test.js.map +1 -1
- package/dist/cli/commands/my-stories.d.ts.map +1 -1
- package/dist/cli/commands/my-stories.js +17 -18
- package/dist/cli/commands/my-stories.js.map +1 -1
- package/dist/cli/commands/my-stories.test.js +2 -2
- package/dist/cli/commands/my-stories.test.js.map +1 -1
- package/dist/cli/commands/nuke.test.js +1 -1
- package/dist/cli/commands/nuke.test.js.map +1 -1
- package/dist/cli/commands/pr.js +32 -32
- package/dist/cli/commands/pr.js.map +1 -1
- package/dist/cli/commands/pr.test.js +10 -6
- package/dist/cli/commands/pr.test.js.map +1 -1
- package/dist/cli/commands/progress.d.ts.map +1 -1
- package/dist/cli/commands/progress.js +4 -5
- package/dist/cli/commands/progress.js.map +1 -1
- package/dist/cli/commands/progress.test.js +1 -1
- package/dist/cli/commands/progress.test.js.map +1 -1
- package/dist/cli/commands/req-headless.test.d.ts +2 -0
- package/dist/cli/commands/req-headless.test.d.ts.map +1 -0
- package/dist/cli/commands/req-headless.test.js +128 -0
- package/dist/cli/commands/req-headless.test.js.map +1 -0
- package/dist/cli/commands/req-spawn.test.js +5 -1
- package/dist/cli/commands/req-spawn.test.js.map +1 -1
- package/dist/cli/commands/req.d.ts.map +1 -1
- package/dist/cli/commands/req.js +13 -14
- package/dist/cli/commands/req.js.map +1 -1
- package/dist/cli/commands/resume.d.ts.map +1 -1
- package/dist/cli/commands/resume.js +7 -8
- package/dist/cli/commands/resume.js.map +1 -1
- package/dist/cli/commands/resume.test.js +1 -1
- package/dist/cli/commands/resume.test.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +42 -40
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/status.test.js +1 -1
- package/dist/cli/commands/status.test.js.map +1 -1
- package/dist/cli/commands/stories.js +9 -9
- package/dist/cli/commands/stories.js.map +1 -1
- package/dist/cli/commands/stories.test.js +2 -2
- package/dist/cli/commands/stories.test.js.map +1 -1
- package/dist/cli/commands/teams.js +11 -11
- package/dist/cli/commands/teams.js.map +1 -1
- package/dist/cli/commands/teams.test.js +2 -2
- package/dist/cli/commands/teams.test.js.map +1 -1
- package/dist/cli/dashboard/index.d.ts +2 -2
- package/dist/cli/dashboard/index.d.ts.map +1 -1
- package/dist/cli/dashboard/index.js +29 -20
- package/dist/cli/dashboard/index.js.map +1 -1
- package/dist/cli/dashboard/index.test.js +34 -32
- package/dist/cli/dashboard/index.test.js.map +1 -1
- package/dist/cli/dashboard/panels/activity.d.ts +3 -3
- package/dist/cli/dashboard/panels/activity.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/activity.js +1 -1
- package/dist/cli/dashboard/panels/activity.js.map +1 -1
- package/dist/cli/dashboard/panels/agents.d.ts +3 -3
- package/dist/cli/dashboard/panels/agents.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/agents.js +2 -2
- package/dist/cli/dashboard/panels/agents.js.map +1 -1
- package/dist/cli/dashboard/panels/escalations.d.ts +3 -3
- package/dist/cli/dashboard/panels/escalations.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/escalations.js +1 -1
- package/dist/cli/dashboard/panels/escalations.js.map +1 -1
- package/dist/cli/dashboard/panels/merge-queue.d.ts +3 -3
- package/dist/cli/dashboard/panels/merge-queue.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/merge-queue.js +1 -1
- package/dist/cli/dashboard/panels/merge-queue.js.map +1 -1
- package/dist/cli/dashboard/panels/pipeline.d.ts +3 -3
- package/dist/cli/dashboard/panels/pipeline.d.ts.map +1 -1
- package/dist/cli/dashboard/panels/pipeline.js +1 -1
- package/dist/cli/dashboard/panels/pipeline.js.map +1 -1
- package/dist/config/schema.d.ts +85 -82
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +1 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/connectors/project-management/operations.d.ts +7 -7
- package/dist/connectors/project-management/operations.d.ts.map +1 -1
- package/dist/connectors/project-management/operations.js +2 -3
- package/dist/connectors/project-management/operations.js.map +1 -1
- package/dist/context-files/index.test.js +1 -0
- package/dist/context-files/index.test.js.map +1 -1
- package/dist/db/client.d.ts +6 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +7 -0
- package/dist/db/client.js.map +1 -1
- package/dist/db/postgres-provider.d.ts +43 -0
- package/dist/db/postgres-provider.d.ts.map +1 -0
- package/dist/db/postgres-provider.integration.test.d.ts +2 -0
- package/dist/db/postgres-provider.integration.test.d.ts.map +1 -0
- package/dist/db/postgres-provider.integration.test.js +399 -0
- package/dist/db/postgres-provider.integration.test.js.map +1 -0
- package/dist/db/postgres-provider.js +315 -0
- package/dist/db/postgres-provider.js.map +1 -0
- package/dist/db/postgres-provider.test.d.ts +2 -0
- package/dist/db/postgres-provider.test.d.ts.map +1 -0
- package/dist/db/postgres-provider.test.js +72 -0
- package/dist/db/postgres-provider.test.js.map +1 -0
- package/dist/db/provider.d.ts +59 -0
- package/dist/db/provider.d.ts.map +1 -0
- package/dist/db/provider.js +121 -0
- package/dist/db/provider.js.map +1 -0
- package/dist/db/provider.test.d.ts +2 -0
- package/dist/db/provider.test.d.ts.map +1 -0
- package/dist/db/provider.test.js +226 -0
- package/dist/db/provider.test.js.map +1 -0
- package/dist/db/queries/agents.d.ts +13 -13
- package/dist/db/queries/agents.d.ts.map +1 -1
- package/dist/db/queries/agents.js +27 -28
- package/dist/db/queries/agents.js.map +1 -1
- package/dist/db/queries/agents.test.js +113 -111
- package/dist/db/queries/agents.test.js.map +1 -1
- package/dist/db/queries/escalations.d.ts +16 -16
- package/dist/db/queries/escalations.d.ts.map +1 -1
- package/dist/db/queries/escalations.js +34 -35
- package/dist/db/queries/escalations.js.map +1 -1
- package/dist/db/queries/escalations.test.js +133 -131
- package/dist/db/queries/escalations.test.js.map +1 -1
- package/dist/db/queries/heartbeat.d.ts +5 -5
- package/dist/db/queries/heartbeat.d.ts.map +1 -1
- package/dist/db/queries/heartbeat.js +7 -23
- package/dist/db/queries/heartbeat.js.map +1 -1
- package/dist/db/queries/heartbeat.test.js +76 -76
- package/dist/db/queries/heartbeat.test.js.map +1 -1
- package/dist/db/queries/integration-sync.d.ts +7 -7
- package/dist/db/queries/integration-sync.d.ts.map +1 -1
- package/dist/db/queries/integration-sync.js +13 -14
- package/dist/db/queries/integration-sync.js.map +1 -1
- package/dist/db/queries/logs.d.ts +10 -10
- package/dist/db/queries/logs.d.ts.map +1 -1
- package/dist/db/queries/logs.js +44 -42
- package/dist/db/queries/logs.js.map +1 -1
- package/dist/db/queries/logs.test.js +149 -146
- package/dist/db/queries/logs.test.js.map +1 -1
- package/dist/db/queries/messages.d.ts +6 -6
- package/dist/db/queries/messages.d.ts.map +1 -1
- package/dist/db/queries/messages.js +12 -11
- package/dist/db/queries/messages.js.map +1 -1
- package/dist/db/queries/messages.test.js +47 -46
- package/dist/db/queries/messages.test.js.map +1 -1
- package/dist/db/queries/pull-requests.d.ts +18 -18
- package/dist/db/queries/pull-requests.d.ts.map +1 -1
- package/dist/db/queries/pull-requests.js +50 -48
- package/dist/db/queries/pull-requests.js.map +1 -1
- package/dist/db/queries/pull-requests.test.js +195 -198
- package/dist/db/queries/pull-requests.test.js.map +1 -1
- package/dist/db/queries/requirements.d.ts +8 -8
- package/dist/db/queries/requirements.d.ts.map +1 -1
- package/dist/db/queries/requirements.js +17 -18
- package/dist/db/queries/requirements.js.map +1 -1
- package/dist/db/queries/requirements.test.js +83 -81
- package/dist/db/queries/requirements.test.js.map +1 -1
- package/dist/db/queries/stories.d.ts +29 -29
- package/dist/db/queries/stories.d.ts.map +1 -1
- package/dist/db/queries/stories.js +58 -64
- package/dist/db/queries/stories.js.map +1 -1
- package/dist/db/queries/stories.test.js +172 -170
- package/dist/db/queries/stories.test.js.map +1 -1
- package/dist/db/queries/teams.d.ts +6 -6
- package/dist/db/queries/teams.d.ts.map +1 -1
- package/dist/db/queries/teams.js +11 -12
- package/dist/db/queries/teams.js.map +1 -1
- package/dist/db/queries/teams.test.js +36 -34
- package/dist/db/queries/teams.test.js.map +1 -1
- package/dist/integrations/jira/repair.test.js +26 -24
- package/dist/integrations/jira/repair.test.js.map +1 -1
- package/dist/integrations/jira/stories.d.ts +3 -3
- package/dist/integrations/jira/stories.d.ts.map +1 -1
- package/dist/integrations/jira/stories.js +12 -12
- package/dist/integrations/jira/stories.js.map +1 -1
- package/dist/integrations/jira/stories.test.js +10 -8
- package/dist/integrations/jira/stories.test.js.map +1 -1
- package/dist/integrations/jira/sync.d.ts +7 -7
- package/dist/integrations/jira/sync.d.ts.map +1 -1
- package/dist/integrations/jira/sync.js +17 -20
- package/dist/integrations/jira/sync.js.map +1 -1
- package/dist/integrations/jira/sync.test.js +63 -62
- package/dist/integrations/jira/sync.test.js.map +1 -1
- package/dist/integrations/jira/transitions.d.ts +3 -3
- package/dist/integrations/jira/transitions.d.ts.map +1 -1
- package/dist/integrations/jira/transitions.js +3 -3
- package/dist/integrations/jira/transitions.js.map +1 -1
- package/dist/orchestrator/agent-selector.d.ts +3 -3
- package/dist/orchestrator/agent-selector.d.ts.map +1 -1
- package/dist/orchestrator/agent-selector.js +5 -6
- package/dist/orchestrator/agent-selector.js.map +1 -1
- package/dist/orchestrator/dependency-resolver.d.ts +4 -4
- package/dist/orchestrator/dependency-resolver.d.ts.map +1 -1
- package/dist/orchestrator/dependency-resolver.js +6 -6
- package/dist/orchestrator/dependency-resolver.js.map +1 -1
- package/dist/orchestrator/feature-branch.d.ts +3 -3
- package/dist/orchestrator/feature-branch.d.ts.map +1 -1
- package/dist/orchestrator/feature-branch.js +9 -10
- package/dist/orchestrator/feature-branch.js.map +1 -1
- package/dist/orchestrator/feature-branch.test.js +80 -78
- package/dist/orchestrator/feature-branch.test.js.map +1 -1
- package/dist/orchestrator/orphan-recovery.d.ts +2 -2
- package/dist/orchestrator/orphan-recovery.d.ts.map +1 -1
- package/dist/orchestrator/orphan-recovery.js +10 -10
- package/dist/orchestrator/orphan-recovery.js.map +1 -1
- package/dist/orchestrator/scheduler.d.ts +4 -4
- package/dist/orchestrator/scheduler.d.ts.map +1 -1
- package/dist/orchestrator/scheduler.js +90 -76
- package/dist/orchestrator/scheduler.js.map +1 -1
- package/dist/orchestrator/scheduler.test.js +496 -374
- package/dist/orchestrator/scheduler.test.js.map +1 -1
- package/dist/utils/auto-merge.d.ts.map +1 -1
- package/dist/utils/auto-merge.js +74 -56
- package/dist/utils/auto-merge.js.map +1 -1
- package/dist/utils/auto-merge.test.js +101 -66
- package/dist/utils/auto-merge.test.js.map +1 -1
- package/dist/utils/cli-helpers.d.ts +5 -5
- package/dist/utils/cli-helpers.d.ts.map +1 -1
- package/dist/utils/cli-helpers.js +8 -9
- package/dist/utils/cli-helpers.js.map +1 -1
- package/dist/utils/cli-helpers.test.js +28 -30
- package/dist/utils/cli-helpers.test.js.map +1 -1
- package/dist/utils/paths.d.ts +6 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +12 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/paths.test.js +1 -0
- package/dist/utils/paths.test.js.map +1 -1
- package/dist/utils/pr-sync.d.ts +10 -10
- package/dist/utils/pr-sync.d.ts.map +1 -1
- package/dist/utils/pr-sync.js +20 -21
- package/dist/utils/pr-sync.js.map +1 -1
- package/dist/utils/pr-sync.test.js +52 -50
- package/dist/utils/pr-sync.test.js.map +1 -1
- package/dist/utils/with-hive-context.d.ts.map +1 -1
- package/dist/utils/with-hive-context.js +70 -1
- package/dist/utils/with-hive-context.js.map +1 -1
- package/package.json +3 -1
- package/src/agents/base-agent.test.ts +2 -1
- package/src/agents/base-agent.ts +32 -28
- package/src/agents/intermediate.ts +27 -18
- package/src/agents/junior.ts +27 -18
- package/src/agents/qa.ts +54 -40
- package/src/agents/senior.ts +42 -27
- package/src/agents/tech-lead.ts +42 -32
- package/src/cli/commands/add-repo.test.ts +1 -1
- package/src/cli/commands/add-repo.ts +2 -2
- package/src/cli/commands/agents.test.ts +7 -7
- package/src/cli/commands/agents.ts +12 -10
- package/src/cli/commands/approach.ts +2 -2
- package/src/cli/commands/approvals.test.ts +8 -8
- package/src/cli/commands/approvals.ts +9 -7
- package/src/cli/commands/assign.test.ts +19 -18
- package/src/cli/commands/assign.ts +4 -4
- package/src/cli/commands/cleanup.test.ts +5 -1
- package/src/cli/commands/cleanup.ts +11 -9
- package/src/cli/commands/escalations.test.ts +2 -2
- package/src/cli/commands/escalations.ts +9 -7
- package/src/cli/commands/init.test.ts +5 -0
- package/src/cli/commands/init.ts +53 -5
- package/src/cli/commands/manager/agent-monitoring.ts +3 -3
- package/src/cli/commands/manager/auditor-lifecycle.test.ts +21 -14
- package/src/cli/commands/manager/auditor-lifecycle.ts +3 -3
- package/src/cli/commands/manager/auto-reject-comment-only-reviews.test.ts +28 -23
- package/src/cli/commands/manager/escalation-handler.test.ts +13 -13
- package/src/cli/commands/manager/escalation-handler.ts +19 -12
- package/src/cli/commands/manager/feature-sign-off.test.ts +40 -31
- package/src/cli/commands/manager/feature-sign-off.ts +7 -7
- package/src/cli/commands/manager/feature-test-result.ts +13 -16
- package/src/cli/commands/manager/handoff-recovery.ts +20 -20
- package/src/cli/commands/manager/index.test.ts +4 -4
- package/src/cli/commands/manager/index.ts +58 -59
- package/src/cli/commands/manager/merged-story-cleanup.test.ts +28 -19
- package/src/cli/commands/manager/merged-story-cleanup.ts +11 -14
- package/src/cli/commands/manager/pr-sync-orchestrator.ts +115 -110
- package/src/cli/commands/manager/qa-review-handler.ts +50 -63
- package/src/cli/commands/manager/spin-down.ts +27 -25
- package/src/cli/commands/manager/stale-escalations.ts +2 -3
- package/src/cli/commands/manager/stuck-story-helpers.ts +10 -10
- package/src/cli/commands/manager/stuck-story-processor.ts +56 -62
- package/src/cli/commands/manager/tech-lead-lifecycle.ts +6 -6
- package/src/cli/commands/manager/types.ts +2 -3
- package/src/cli/commands/msg.test.ts +2 -2
- package/src/cli/commands/my-stories.test.ts +4 -2
- package/src/cli/commands/my-stories.ts +22 -27
- package/src/cli/commands/nuke.test.ts +1 -1
- package/src/cli/commands/pr.test.ts +10 -6
- package/src/cli/commands/pr.ts +41 -32
- package/src/cli/commands/progress.test.ts +1 -1
- package/src/cli/commands/progress.ts +11 -6
- package/src/cli/commands/req-headless.test.ts +170 -0
- package/src/cli/commands/req-spawn.test.ts +12 -2
- package/src/cli/commands/req.ts +13 -14
- package/src/cli/commands/resume.test.ts +1 -1
- package/src/cli/commands/resume.ts +7 -8
- package/src/cli/commands/status.test.ts +1 -1
- package/src/cli/commands/status.ts +52 -40
- package/src/cli/commands/stories.test.ts +4 -2
- package/src/cli/commands/stories.ts +11 -11
- package/src/cli/commands/teams.test.ts +2 -2
- package/src/cli/commands/teams.ts +11 -11
- package/src/cli/dashboard/index.test.ts +35 -34
- package/src/cli/dashboard/index.ts +34 -23
- package/src/cli/dashboard/panels/activity.ts +10 -4
- package/src/cli/dashboard/panels/agents.ts +8 -5
- package/src/cli/dashboard/panels/escalations.ts +4 -4
- package/src/cli/dashboard/panels/merge-queue.ts +4 -4
- package/src/cli/dashboard/panels/pipeline.ts +10 -4
- package/src/config/schema.ts +1 -0
- package/src/connectors/project-management/operations.ts +9 -10
- package/src/context-files/index.test.ts +1 -0
- package/src/db/client.ts +17 -0
- package/src/db/pg-migrations/001-full-schema.sql +209 -0
- package/src/db/postgres-provider.integration.test.ts +574 -0
- package/src/db/postgres-provider.test.ts +97 -0
- package/src/db/postgres-provider.ts +364 -0
- package/src/db/provider.test.ts +283 -0
- package/src/db/provider.ts +161 -0
- package/src/db/queries/agents.test.ts +114 -113
- package/src/db/queries/agents.ts +50 -36
- package/src/db/queries/escalations.test.ts +134 -133
- package/src/db/queries/escalations.ts +72 -57
- package/src/db/queries/heartbeat.test.ts +77 -78
- package/src/db/queries/heartbeat.ts +24 -46
- package/src/db/queries/integration-sync.ts +26 -26
- package/src/db/queries/logs.test.ts +151 -148
- package/src/db/queries/logs.ts +78 -53
- package/src/db/queries/messages.test.ts +48 -50
- package/src/db/queries/messages.ts +26 -18
- package/src/db/queries/pull-requests.test.ts +194 -199
- package/src/db/queries/pull-requests.ts +117 -88
- package/src/db/queries/requirements.test.ts +84 -83
- package/src/db/queries/requirements.ts +33 -28
- package/src/db/queries/stories.test.ts +173 -172
- package/src/db/queries/stories.ts +141 -110
- package/src/db/queries/teams.test.ts +37 -36
- package/src/db/queries/teams.ts +22 -14
- package/src/integrations/jira/repair.test.ts +27 -26
- package/src/integrations/jira/stories.test.ts +15 -16
- package/src/integrations/jira/stories.ts +15 -15
- package/src/integrations/jira/sync.test.ts +68 -68
- package/src/integrations/jira/sync.ts +29 -39
- package/src/integrations/jira/transitions.ts +6 -6
- package/src/orchestrator/agent-selector.ts +9 -8
- package/src/orchestrator/dependency-resolver.ts +16 -7
- package/src/orchestrator/feature-branch.test.ts +85 -80
- package/src/orchestrator/feature-branch.ts +13 -14
- package/src/orchestrator/orphan-recovery.ts +14 -13
- package/src/orchestrator/scheduler.test.ts +536 -394
- package/src/orchestrator/scheduler.ts +129 -115
- package/src/utils/auto-merge.test.ts +102 -68
- package/src/utils/auto-merge.ts +161 -168
- package/src/utils/cli-helpers.test.ts +30 -32
- package/src/utils/cli-helpers.ts +15 -11
- package/src/utils/paths.test.ts +1 -0
- package/src/utils/paths.ts +14 -1
- package/src/utils/pr-sync.test.ts +55 -52
- package/src/utils/pr-sync.ts +27 -32
- package/src/utils/with-hive-context.ts +89 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Licensed under the Hungry Ghost Hive License. See LICENSE.
|
|
2
2
|
|
|
3
|
-
import type { Database } from 'sql.js';
|
|
4
3
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
4
|
+
import { SqliteProvider } from '../provider.js';
|
|
5
5
|
import {
|
|
6
6
|
createPullRequest,
|
|
7
7
|
deletePullRequest,
|
|
@@ -23,20 +23,21 @@ import { createTeam } from './teams.js';
|
|
|
23
23
|
import { createTestDatabase } from './test-helpers.js';
|
|
24
24
|
|
|
25
25
|
describe('pull-requests queries', () => {
|
|
26
|
-
let db:
|
|
26
|
+
let db: SqliteProvider;
|
|
27
27
|
let teamId: string;
|
|
28
28
|
let storyId: string;
|
|
29
29
|
|
|
30
30
|
beforeEach(async () => {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const rawDb = await createTestDatabase();
|
|
32
|
+
db = new SqliteProvider(rawDb);
|
|
33
|
+
const team = await createTeam(db, {
|
|
33
34
|
repoUrl: 'https://github.com/test/repo.git',
|
|
34
35
|
repoPath: '/path/to/repo',
|
|
35
36
|
name: 'Test Team',
|
|
36
37
|
});
|
|
37
38
|
teamId = team.id;
|
|
38
39
|
|
|
39
|
-
const story = createStory(db, {
|
|
40
|
+
const story = await createStory(db, {
|
|
40
41
|
title: 'Test Story',
|
|
41
42
|
description: 'Test description',
|
|
42
43
|
teamId,
|
|
@@ -45,8 +46,8 @@ describe('pull-requests queries', () => {
|
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
describe('createPullRequest', () => {
|
|
48
|
-
it('should create a pull request with all fields', () => {
|
|
49
|
-
const pr = createPullRequest(db, {
|
|
49
|
+
it('should create a pull request with all fields', async () => {
|
|
50
|
+
const pr = await createPullRequest(db, {
|
|
50
51
|
storyId,
|
|
51
52
|
teamId,
|
|
52
53
|
branchName: 'feature/test-branch',
|
|
@@ -66,8 +67,8 @@ describe('pull-requests queries', () => {
|
|
|
66
67
|
expect(pr.created_at).toBeDefined();
|
|
67
68
|
});
|
|
68
69
|
|
|
69
|
-
it('should create PR with only required fields', () => {
|
|
70
|
-
const pr = createPullRequest(db, {
|
|
70
|
+
it('should create PR with only required fields', async () => {
|
|
71
|
+
const pr = await createPullRequest(db, {
|
|
71
72
|
branchName: 'feature/simple-branch',
|
|
72
73
|
});
|
|
73
74
|
|
|
@@ -78,15 +79,15 @@ describe('pull-requests queries', () => {
|
|
|
78
79
|
expect(pr.status).toBe('queued');
|
|
79
80
|
});
|
|
80
81
|
|
|
81
|
-
it('should generate unique IDs', () => {
|
|
82
|
-
const pr1 = createPullRequest(db, { branchName: 'branch-1' });
|
|
83
|
-
const pr2 = createPullRequest(db, { branchName: 'branch-2' });
|
|
82
|
+
it('should generate unique IDs', async () => {
|
|
83
|
+
const pr1 = await createPullRequest(db, { branchName: 'branch-1' });
|
|
84
|
+
const pr2 = await createPullRequest(db, { branchName: 'branch-2' });
|
|
84
85
|
|
|
85
86
|
expect(pr1.id).not.toBe(pr2.id);
|
|
86
87
|
});
|
|
87
88
|
|
|
88
|
-
it('should extract PR number from github_pr_url when creating PR', () => {
|
|
89
|
-
const pr = createPullRequest(db, {
|
|
89
|
+
it('should extract PR number from github_pr_url when creating PR', async () => {
|
|
90
|
+
const pr = await createPullRequest(db, {
|
|
90
91
|
storyId,
|
|
91
92
|
teamId,
|
|
92
93
|
branchName: 'feature/extract-test',
|
|
@@ -98,8 +99,8 @@ describe('pull-requests queries', () => {
|
|
|
98
99
|
expect(pr.github_pr_url).toBe('https://github.com/test/repo/pull/456');
|
|
99
100
|
});
|
|
100
101
|
|
|
101
|
-
it('should prefer explicit githubPrNumber over extracted from URL', () => {
|
|
102
|
-
const pr = createPullRequest(db, {
|
|
102
|
+
it('should prefer explicit githubPrNumber over extracted from URL', async () => {
|
|
103
|
+
const pr = await createPullRequest(db, {
|
|
103
104
|
branchName: 'feature/prefer-explicit',
|
|
104
105
|
githubPrNumber: 789,
|
|
105
106
|
githubPrUrl: 'https://github.com/test/repo/pull/456',
|
|
@@ -108,8 +109,8 @@ describe('pull-requests queries', () => {
|
|
|
108
109
|
expect(pr.github_pr_number).toBe(789);
|
|
109
110
|
});
|
|
110
111
|
|
|
111
|
-
it('should handle malformed github_pr_url gracefully', () => {
|
|
112
|
-
const pr = createPullRequest(db, {
|
|
112
|
+
it('should handle malformed github_pr_url gracefully', async () => {
|
|
113
|
+
const pr = await createPullRequest(db, {
|
|
113
114
|
branchName: 'feature/malformed-url',
|
|
114
115
|
githubPrUrl: 'https://github.com/test/repo',
|
|
115
116
|
});
|
|
@@ -120,74 +121,74 @@ describe('pull-requests queries', () => {
|
|
|
120
121
|
});
|
|
121
122
|
|
|
122
123
|
describe('getPullRequestById', () => {
|
|
123
|
-
it('should retrieve a PR by ID', () => {
|
|
124
|
-
const created = createPullRequest(db, {
|
|
124
|
+
it('should retrieve a PR by ID', async () => {
|
|
125
|
+
const created = await createPullRequest(db, {
|
|
125
126
|
branchName: 'feature/test',
|
|
126
127
|
storyId,
|
|
127
128
|
});
|
|
128
129
|
|
|
129
|
-
const retrieved = getPullRequestById(db, created.id);
|
|
130
|
+
const retrieved = await getPullRequestById(db, created.id);
|
|
130
131
|
|
|
131
132
|
expect(retrieved).toBeDefined();
|
|
132
133
|
expect(retrieved?.id).toBe(created.id);
|
|
133
134
|
expect(retrieved?.branch_name).toBe('feature/test');
|
|
134
135
|
});
|
|
135
136
|
|
|
136
|
-
it('should return undefined for non-existent PR', () => {
|
|
137
|
-
const result = getPullRequestById(db, 'non-existent-id');
|
|
137
|
+
it('should return undefined for non-existent PR', async () => {
|
|
138
|
+
const result = await getPullRequestById(db, 'non-existent-id');
|
|
138
139
|
expect(result).toBeUndefined();
|
|
139
140
|
});
|
|
140
141
|
});
|
|
141
142
|
|
|
142
143
|
describe('getPullRequestByStory', () => {
|
|
143
|
-
it('should retrieve a PR by story ID', () => {
|
|
144
|
-
const pr = createPullRequest(db, {
|
|
144
|
+
it('should retrieve a PR by story ID', async () => {
|
|
145
|
+
const pr = await createPullRequest(db, {
|
|
145
146
|
storyId,
|
|
146
147
|
branchName: 'feature/story-branch',
|
|
147
148
|
});
|
|
148
149
|
|
|
149
|
-
const retrieved = getPullRequestByStory(db, storyId);
|
|
150
|
+
const retrieved = await getPullRequestByStory(db, storyId);
|
|
150
151
|
|
|
151
152
|
expect(retrieved).toBeDefined();
|
|
152
153
|
expect(retrieved?.id).toBe(pr.id);
|
|
153
154
|
expect(retrieved?.story_id).toBe(storyId);
|
|
154
155
|
});
|
|
155
156
|
|
|
156
|
-
it('should return undefined when no PR for story', () => {
|
|
157
|
-
const result = getPullRequestByStory(db, 'non-existent-story');
|
|
157
|
+
it('should return undefined when no PR for story', async () => {
|
|
158
|
+
const result = await getPullRequestByStory(db, 'non-existent-story');
|
|
158
159
|
expect(result).toBeUndefined();
|
|
159
160
|
});
|
|
160
161
|
});
|
|
161
162
|
|
|
162
163
|
describe('getPullRequestByGithubNumber', () => {
|
|
163
|
-
it('should retrieve a PR by GitHub PR number', () => {
|
|
164
|
-
const pr = createPullRequest(db, {
|
|
164
|
+
it('should retrieve a PR by GitHub PR number', async () => {
|
|
165
|
+
const pr = await createPullRequest(db, {
|
|
165
166
|
branchName: 'feature/test',
|
|
166
167
|
githubPrNumber: 456,
|
|
167
168
|
});
|
|
168
169
|
|
|
169
|
-
const retrieved = getPullRequestByGithubNumber(db, 456);
|
|
170
|
+
const retrieved = await getPullRequestByGithubNumber(db, 456);
|
|
170
171
|
|
|
171
172
|
expect(retrieved).toBeDefined();
|
|
172
173
|
expect(retrieved?.id).toBe(pr.id);
|
|
173
174
|
expect(retrieved?.github_pr_number).toBe(456);
|
|
174
175
|
});
|
|
175
176
|
|
|
176
|
-
it('should return undefined for non-existent PR number', () => {
|
|
177
|
-
const result = getPullRequestByGithubNumber(db, 999);
|
|
177
|
+
it('should return undefined for non-existent PR number', async () => {
|
|
178
|
+
const result = await getPullRequestByGithubNumber(db, 999);
|
|
178
179
|
expect(result).toBeUndefined();
|
|
179
180
|
});
|
|
180
181
|
});
|
|
181
182
|
|
|
182
183
|
describe('getMergeQueue', () => {
|
|
183
|
-
it('should return queued and reviewing PRs', () => {
|
|
184
|
-
const pr1 = createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
185
|
-
const pr2 = createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
186
|
-
updatePullRequest(db, pr2.id, { status: 'reviewing' });
|
|
187
|
-
const pr3 = createPullRequest(db, { branchName: 'branch-3', teamId });
|
|
188
|
-
updatePullRequest(db, pr3.id, { status: 'merged' });
|
|
184
|
+
it('should return queued and reviewing PRs', async () => {
|
|
185
|
+
const pr1 = await createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
186
|
+
const pr2 = await createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
187
|
+
await updatePullRequest(db, pr2.id, { status: 'reviewing' });
|
|
188
|
+
const pr3 = await createPullRequest(db, { branchName: 'branch-3', teamId });
|
|
189
|
+
await updatePullRequest(db, pr3.id, { status: 'merged' });
|
|
189
190
|
|
|
190
|
-
const queue = getMergeQueue(db);
|
|
191
|
+
const queue = await getMergeQueue(db);
|
|
191
192
|
|
|
192
193
|
expect(queue).toHaveLength(2);
|
|
193
194
|
expect(queue.map(p => p.id)).toContain(pr1.id);
|
|
@@ -195,27 +196,27 @@ describe('pull-requests queries', () => {
|
|
|
195
196
|
expect(queue.map(p => p.id)).not.toContain(pr3.id);
|
|
196
197
|
});
|
|
197
198
|
|
|
198
|
-
it('should filter by team when teamId provided', () => {
|
|
199
|
-
const team2 = createTeam(db, {
|
|
199
|
+
it('should filter by team when teamId provided', async () => {
|
|
200
|
+
const team2 = await createTeam(db, {
|
|
200
201
|
repoUrl: 'https://github.com/test/repo2.git',
|
|
201
202
|
repoPath: '/path/to/repo2',
|
|
202
203
|
name: 'Team 2',
|
|
203
204
|
});
|
|
204
205
|
|
|
205
|
-
const pr1 = createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
206
|
-
createPullRequest(db, { branchName: 'branch-2', teamId: team2.id });
|
|
206
|
+
const pr1 = await createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
207
|
+
await createPullRequest(db, { branchName: 'branch-2', teamId: team2.id });
|
|
207
208
|
|
|
208
|
-
const queue = getMergeQueue(db, teamId);
|
|
209
|
+
const queue = await getMergeQueue(db, teamId);
|
|
209
210
|
|
|
210
211
|
expect(queue).toHaveLength(1);
|
|
211
212
|
expect(queue[0].id).toBe(pr1.id);
|
|
212
213
|
});
|
|
213
214
|
|
|
214
|
-
it('should order by created_at ASC', () => {
|
|
215
|
-
const pr1 = createPullRequest(db, { branchName: 'first', teamId });
|
|
216
|
-
const pr2 = createPullRequest(db, { branchName: 'second', teamId });
|
|
215
|
+
it('should order by created_at ASC', async () => {
|
|
216
|
+
const pr1 = await createPullRequest(db, { branchName: 'first', teamId });
|
|
217
|
+
const pr2 = await createPullRequest(db, { branchName: 'second', teamId });
|
|
217
218
|
|
|
218
|
-
const queue = getMergeQueue(db);
|
|
219
|
+
const queue = await getMergeQueue(db);
|
|
219
220
|
|
|
220
221
|
expect(queue[0].id).toBe(pr1.id);
|
|
221
222
|
expect(queue[1].id).toBe(pr2.id);
|
|
@@ -223,75 +224,75 @@ describe('pull-requests queries', () => {
|
|
|
223
224
|
});
|
|
224
225
|
|
|
225
226
|
describe('getNextInQueue', () => {
|
|
226
|
-
it('should return the oldest queued PR', () => {
|
|
227
|
-
createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
228
|
-
const pr2 = createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
229
|
-
updatePullRequest(db, pr2.id, { status: 'reviewing' });
|
|
230
|
-
createPullRequest(db, { branchName: 'branch-3', teamId });
|
|
227
|
+
it('should return the oldest queued PR', async () => {
|
|
228
|
+
await createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
229
|
+
const pr2 = await createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
230
|
+
await updatePullRequest(db, pr2.id, { status: 'reviewing' });
|
|
231
|
+
await createPullRequest(db, { branchName: 'branch-3', teamId });
|
|
231
232
|
|
|
232
|
-
const next = getNextInQueue(db);
|
|
233
|
+
const next = await getNextInQueue(db);
|
|
233
234
|
|
|
234
235
|
expect(next).toBeDefined();
|
|
235
236
|
expect(next?.id).not.toBe(pr2.id); // pr2 is reviewing, not queued
|
|
236
237
|
expect(next?.status).toBe('queued');
|
|
237
238
|
});
|
|
238
239
|
|
|
239
|
-
it('should filter by team when teamId provided', () => {
|
|
240
|
-
const team2 = createTeam(db, {
|
|
240
|
+
it('should filter by team when teamId provided', async () => {
|
|
241
|
+
const team2 = await createTeam(db, {
|
|
241
242
|
repoUrl: 'https://github.com/test/repo2.git',
|
|
242
243
|
repoPath: '/path/to/repo2',
|
|
243
244
|
name: 'Team 2',
|
|
244
245
|
});
|
|
245
246
|
|
|
246
|
-
createPullRequest(db, { branchName: 'branch-1', teamId: team2.id });
|
|
247
|
-
const pr2 = createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
247
|
+
await createPullRequest(db, { branchName: 'branch-1', teamId: team2.id });
|
|
248
|
+
const pr2 = await createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
248
249
|
|
|
249
|
-
const next = getNextInQueue(db, teamId);
|
|
250
|
+
const next = await getNextInQueue(db, teamId);
|
|
250
251
|
|
|
251
252
|
expect(next?.id).toBe(pr2.id);
|
|
252
253
|
});
|
|
253
254
|
|
|
254
|
-
it('should return undefined when no queued PRs', () => {
|
|
255
|
-
const pr = createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
256
|
-
updatePullRequest(db, pr.id, { status: 'merged' });
|
|
255
|
+
it('should return undefined when no queued PRs', async () => {
|
|
256
|
+
const pr = await createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
257
|
+
await updatePullRequest(db, pr.id, { status: 'merged' });
|
|
257
258
|
|
|
258
|
-
const next = getNextInQueue(db);
|
|
259
|
+
const next = await getNextInQueue(db);
|
|
259
260
|
|
|
260
261
|
expect(next).toBeUndefined();
|
|
261
262
|
});
|
|
262
263
|
});
|
|
263
264
|
|
|
264
265
|
describe('getQueuePosition', () => {
|
|
265
|
-
it('should return correct position in queue', () => {
|
|
266
|
-
const pr1 = createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
267
|
-
const pr2 = createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
268
|
-
const pr3 = createPullRequest(db, { branchName: 'branch-3', teamId });
|
|
266
|
+
it('should return correct position in queue', async () => {
|
|
267
|
+
const pr1 = await createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
268
|
+
const pr2 = await createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
269
|
+
const pr3 = await createPullRequest(db, { branchName: 'branch-3', teamId });
|
|
269
270
|
|
|
270
|
-
expect(getQueuePosition(db, pr1.id)).toBe(1);
|
|
271
|
-
expect(getQueuePosition(db, pr2.id)).toBe(2);
|
|
272
|
-
expect(getQueuePosition(db, pr3.id)).toBe(3);
|
|
271
|
+
expect(await getQueuePosition(db, pr1.id)).toBe(1);
|
|
272
|
+
expect(await getQueuePosition(db, pr2.id)).toBe(2);
|
|
273
|
+
expect(await getQueuePosition(db, pr3.id)).toBe(3);
|
|
273
274
|
});
|
|
274
275
|
|
|
275
|
-
it('should return -1 for PR not in queue', () => {
|
|
276
|
-
const pr = createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
277
|
-
updatePullRequest(db, pr.id, { status: 'merged' });
|
|
276
|
+
it('should return -1 for PR not in queue', async () => {
|
|
277
|
+
const pr = await createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
278
|
+
await updatePullRequest(db, pr.id, { status: 'merged' });
|
|
278
279
|
|
|
279
|
-
expect(getQueuePosition(db, pr.id)).toBe(-1);
|
|
280
|
+
expect(await getQueuePosition(db, pr.id)).toBe(-1);
|
|
280
281
|
});
|
|
281
282
|
|
|
282
|
-
it('should return -1 for non-existent PR', () => {
|
|
283
|
-
expect(getQueuePosition(db, 'non-existent-id')).toBe(-1);
|
|
283
|
+
it('should return -1 for non-existent PR', async () => {
|
|
284
|
+
expect(await getQueuePosition(db, 'non-existent-id')).toBe(-1);
|
|
284
285
|
});
|
|
285
286
|
});
|
|
286
287
|
|
|
287
288
|
describe('getPullRequestsByStatus', () => {
|
|
288
|
-
it('should filter PRs by status', () => {
|
|
289
|
-
const pr1 = createPullRequest(db, { branchName: 'branch-1' });
|
|
290
|
-
const pr2 = createPullRequest(db, { branchName: 'branch-2' });
|
|
291
|
-
updatePullRequest(db, pr2.id, { status: 'approved' });
|
|
289
|
+
it('should filter PRs by status', async () => {
|
|
290
|
+
const pr1 = await createPullRequest(db, { branchName: 'branch-1' });
|
|
291
|
+
const pr2 = await createPullRequest(db, { branchName: 'branch-2' });
|
|
292
|
+
await updatePullRequest(db, pr2.id, { status: 'approved' });
|
|
292
293
|
|
|
293
|
-
const queued = getPullRequestsByStatus(db, 'queued');
|
|
294
|
-
const approved = getPullRequestsByStatus(db, 'approved');
|
|
294
|
+
const queued = await getPullRequestsByStatus(db, 'queued');
|
|
295
|
+
const approved = await getPullRequestsByStatus(db, 'approved');
|
|
295
296
|
|
|
296
297
|
expect(queued).toHaveLength(1);
|
|
297
298
|
expect(queued[0].id).toBe(pr1.id);
|
|
@@ -299,11 +300,11 @@ describe('pull-requests queries', () => {
|
|
|
299
300
|
expect(approved[0].id).toBe(pr2.id);
|
|
300
301
|
});
|
|
301
302
|
|
|
302
|
-
it('should order by created_at DESC', () => {
|
|
303
|
-
const pr1 = createPullRequest(db, { branchName: 'first' });
|
|
304
|
-
const pr2 = createPullRequest(db, { branchName: 'second' });
|
|
303
|
+
it('should order by created_at DESC', async () => {
|
|
304
|
+
const pr1 = await createPullRequest(db, { branchName: 'first' });
|
|
305
|
+
const pr2 = await createPullRequest(db, { branchName: 'second' });
|
|
305
306
|
|
|
306
|
-
const queued = getPullRequestsByStatus(db, 'queued');
|
|
307
|
+
const queued = await getPullRequestsByStatus(db, 'queued');
|
|
307
308
|
|
|
308
309
|
expect(queued).toHaveLength(2);
|
|
309
310
|
// Verify both PRs are present
|
|
@@ -313,27 +314,27 @@ describe('pull-requests queries', () => {
|
|
|
313
314
|
});
|
|
314
315
|
|
|
315
316
|
describe('getApprovedPullRequests', () => {
|
|
316
|
-
it('should return only approved PRs', () => {
|
|
317
|
-
createPullRequest(db, { branchName: 'branch-1' });
|
|
318
|
-
const pr2 = createPullRequest(db, { branchName: 'branch-2' });
|
|
319
|
-
updatePullRequest(db, pr2.id, { status: 'approved' });
|
|
320
|
-
const pr3 = createPullRequest(db, { branchName: 'branch-3' });
|
|
321
|
-
updatePullRequest(db, pr3.id, { status: 'approved' });
|
|
317
|
+
it('should return only approved PRs', async () => {
|
|
318
|
+
await createPullRequest(db, { branchName: 'branch-1' });
|
|
319
|
+
const pr2 = await createPullRequest(db, { branchName: 'branch-2' });
|
|
320
|
+
await updatePullRequest(db, pr2.id, { status: 'approved' });
|
|
321
|
+
const pr3 = await createPullRequest(db, { branchName: 'branch-3' });
|
|
322
|
+
await updatePullRequest(db, pr3.id, { status: 'approved' });
|
|
322
323
|
|
|
323
|
-
const approved = getApprovedPullRequests(db);
|
|
324
|
+
const approved = await getApprovedPullRequests(db);
|
|
324
325
|
|
|
325
326
|
expect(approved).toHaveLength(2);
|
|
326
327
|
expect(approved.map(p => p.id)).toContain(pr2.id);
|
|
327
328
|
expect(approved.map(p => p.id)).toContain(pr3.id);
|
|
328
329
|
});
|
|
329
330
|
|
|
330
|
-
it('should order by created_at ASC', () => {
|
|
331
|
-
const pr1 = createPullRequest(db, { branchName: 'first' });
|
|
332
|
-
updatePullRequest(db, pr1.id, { status: 'approved' });
|
|
333
|
-
const pr2 = createPullRequest(db, { branchName: 'second' });
|
|
334
|
-
updatePullRequest(db, pr2.id, { status: 'approved' });
|
|
331
|
+
it('should order by created_at ASC', async () => {
|
|
332
|
+
const pr1 = await createPullRequest(db, { branchName: 'first' });
|
|
333
|
+
await updatePullRequest(db, pr1.id, { status: 'approved' });
|
|
334
|
+
const pr2 = await createPullRequest(db, { branchName: 'second' });
|
|
335
|
+
await updatePullRequest(db, pr2.id, { status: 'approved' });
|
|
335
336
|
|
|
336
|
-
const approved = getApprovedPullRequests(db);
|
|
337
|
+
const approved = await getApprovedPullRequests(db);
|
|
337
338
|
|
|
338
339
|
expect(approved[0].id).toBe(pr1.id);
|
|
339
340
|
expect(approved[1].id).toBe(pr2.id);
|
|
@@ -341,11 +342,11 @@ describe('pull-requests queries', () => {
|
|
|
341
342
|
});
|
|
342
343
|
|
|
343
344
|
describe('getAllPullRequests', () => {
|
|
344
|
-
it('should return all PRs ordered by created_at DESC', () => {
|
|
345
|
-
const pr1 = createPullRequest(db, { branchName: 'first' });
|
|
346
|
-
const pr2 = createPullRequest(db, { branchName: 'second' });
|
|
345
|
+
it('should return all PRs ordered by created_at DESC', async () => {
|
|
346
|
+
const pr1 = await createPullRequest(db, { branchName: 'first' });
|
|
347
|
+
const pr2 = await createPullRequest(db, { branchName: 'second' });
|
|
347
348
|
|
|
348
|
-
const prs = getAllPullRequests(db);
|
|
349
|
+
const prs = await getAllPullRequests(db);
|
|
349
350
|
|
|
350
351
|
expect(prs).toHaveLength(2);
|
|
351
352
|
// Verify both PRs are present
|
|
@@ -355,17 +356,17 @@ describe('pull-requests queries', () => {
|
|
|
355
356
|
});
|
|
356
357
|
|
|
357
358
|
describe('getPullRequestsByTeam', () => {
|
|
358
|
-
it('should filter PRs by team', () => {
|
|
359
|
-
const team2 = createTeam(db, {
|
|
359
|
+
it('should filter PRs by team', async () => {
|
|
360
|
+
const team2 = await createTeam(db, {
|
|
360
361
|
repoUrl: 'https://github.com/test/repo2.git',
|
|
361
362
|
repoPath: '/path/to/repo2',
|
|
362
363
|
name: 'Team 2',
|
|
363
364
|
});
|
|
364
365
|
|
|
365
|
-
const pr1 = createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
366
|
-
createPullRequest(db, { branchName: 'branch-2', teamId: team2.id });
|
|
366
|
+
const pr1 = await createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
367
|
+
await createPullRequest(db, { branchName: 'branch-2', teamId: team2.id });
|
|
367
368
|
|
|
368
|
-
const teamPrs = getPullRequestsByTeam(db, teamId);
|
|
369
|
+
const teamPrs = await getPullRequestsByTeam(db, teamId);
|
|
369
370
|
|
|
370
371
|
expect(teamPrs).toHaveLength(1);
|
|
371
372
|
expect(teamPrs[0].id).toBe(pr1.id);
|
|
@@ -373,54 +374,54 @@ describe('pull-requests queries', () => {
|
|
|
373
374
|
});
|
|
374
375
|
|
|
375
376
|
describe('updatePullRequest', () => {
|
|
376
|
-
it('should update PR status', () => {
|
|
377
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
377
|
+
it('should update PR status', async () => {
|
|
378
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
378
379
|
|
|
379
|
-
const updated = updatePullRequest(db, pr.id, { status: 'reviewing' });
|
|
380
|
+
const updated = await updatePullRequest(db, pr.id, { status: 'reviewing' });
|
|
380
381
|
|
|
381
382
|
expect(updated?.status).toBe('reviewing');
|
|
382
383
|
});
|
|
383
384
|
|
|
384
|
-
it('should set reviewed_at when status changes to reviewing', () => {
|
|
385
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
385
|
+
it('should set reviewed_at when status changes to reviewing', async () => {
|
|
386
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
386
387
|
|
|
387
|
-
const updated = updatePullRequest(db, pr.id, { status: 'reviewing' });
|
|
388
|
+
const updated = await updatePullRequest(db, pr.id, { status: 'reviewing' });
|
|
388
389
|
|
|
389
390
|
expect(updated?.reviewed_at).toBeDefined();
|
|
390
391
|
});
|
|
391
392
|
|
|
392
|
-
it('should set reviewed_at when status changes to approved', () => {
|
|
393
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
393
|
+
it('should set reviewed_at when status changes to approved', async () => {
|
|
394
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
394
395
|
|
|
395
|
-
const updated = updatePullRequest(db, pr.id, { status: 'approved' });
|
|
396
|
+
const updated = await updatePullRequest(db, pr.id, { status: 'approved' });
|
|
396
397
|
|
|
397
398
|
expect(updated?.reviewed_at).toBeDefined();
|
|
398
399
|
});
|
|
399
400
|
|
|
400
|
-
it('should update reviewedBy', () => {
|
|
401
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
401
|
+
it('should update reviewedBy', async () => {
|
|
402
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
402
403
|
|
|
403
|
-
const updated = updatePullRequest(db, pr.id, {
|
|
404
|
+
const updated = await updatePullRequest(db, pr.id, {
|
|
404
405
|
reviewedBy: 'qa-agent-123',
|
|
405
406
|
});
|
|
406
407
|
|
|
407
408
|
expect(updated?.reviewed_by).toBe('qa-agent-123');
|
|
408
409
|
});
|
|
409
410
|
|
|
410
|
-
it('should update reviewNotes', () => {
|
|
411
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
411
|
+
it('should update reviewNotes', async () => {
|
|
412
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
412
413
|
|
|
413
|
-
const updated = updatePullRequest(db, pr.id, {
|
|
414
|
+
const updated = await updatePullRequest(db, pr.id, {
|
|
414
415
|
reviewNotes: 'LGTM! Good work.',
|
|
415
416
|
});
|
|
416
417
|
|
|
417
418
|
expect(updated?.review_notes).toBe('LGTM! Good work.');
|
|
418
419
|
});
|
|
419
420
|
|
|
420
|
-
it('should update GitHub PR details', () => {
|
|
421
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
421
|
+
it('should update GitHub PR details', async () => {
|
|
422
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
422
423
|
|
|
423
|
-
const updated = updatePullRequest(db, pr.id, {
|
|
424
|
+
const updated = await updatePullRequest(db, pr.id, {
|
|
424
425
|
githubPrNumber: 789,
|
|
425
426
|
githubPrUrl: 'https://github.com/test/repo/pull/789',
|
|
426
427
|
});
|
|
@@ -429,10 +430,10 @@ describe('pull-requests queries', () => {
|
|
|
429
430
|
expect(updated?.github_pr_url).toBe('https://github.com/test/repo/pull/789');
|
|
430
431
|
});
|
|
431
432
|
|
|
432
|
-
it('should update multiple fields at once', () => {
|
|
433
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
433
|
+
it('should update multiple fields at once', async () => {
|
|
434
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
434
435
|
|
|
435
|
-
const updated = updatePullRequest(db, pr.id, {
|
|
436
|
+
const updated = await updatePullRequest(db, pr.id, {
|
|
436
437
|
status: 'approved',
|
|
437
438
|
reviewedBy: 'qa-agent',
|
|
438
439
|
reviewNotes: 'Approved',
|
|
@@ -443,151 +444,151 @@ describe('pull-requests queries', () => {
|
|
|
443
444
|
expect(updated?.review_notes).toBe('Approved');
|
|
444
445
|
});
|
|
445
446
|
|
|
446
|
-
it('should update updated_at timestamp', () => {
|
|
447
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
447
|
+
it('should update updated_at timestamp', async () => {
|
|
448
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
448
449
|
|
|
449
|
-
const updated = updatePullRequest(db, pr.id, { status: 'reviewing' });
|
|
450
|
+
const updated = await updatePullRequest(db, pr.id, { status: 'reviewing' });
|
|
450
451
|
|
|
451
452
|
// Verify updated_at exists and is a valid timestamp
|
|
452
453
|
expect(updated?.updated_at).toBeDefined();
|
|
453
454
|
expect(typeof updated?.updated_at).toBe('string');
|
|
454
455
|
});
|
|
455
456
|
|
|
456
|
-
it('should return PR when no updates provided', () => {
|
|
457
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
457
|
+
it('should return PR when no updates provided', async () => {
|
|
458
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
458
459
|
|
|
459
|
-
const updated = updatePullRequest(db, pr.id, {});
|
|
460
|
+
const updated = await updatePullRequest(db, pr.id, {});
|
|
460
461
|
|
|
461
462
|
expect(updated?.id).toBe(pr.id);
|
|
462
463
|
});
|
|
463
464
|
|
|
464
|
-
it('should return undefined for non-existent PR', () => {
|
|
465
|
-
const updated = updatePullRequest(db, 'non-existent-id', { status: 'reviewing' });
|
|
465
|
+
it('should return undefined for non-existent PR', async () => {
|
|
466
|
+
const updated = await updatePullRequest(db, 'non-existent-id', { status: 'reviewing' });
|
|
466
467
|
expect(updated).toBeUndefined();
|
|
467
468
|
});
|
|
468
469
|
});
|
|
469
470
|
|
|
470
471
|
describe('deletePullRequest', () => {
|
|
471
|
-
it('should delete a PR', () => {
|
|
472
|
-
const pr = createPullRequest(db, { branchName: 'to-delete' });
|
|
472
|
+
it('should delete a PR', async () => {
|
|
473
|
+
const pr = await createPullRequest(db, { branchName: 'to-delete' });
|
|
473
474
|
|
|
474
|
-
deletePullRequest(db, pr.id);
|
|
475
|
+
await deletePullRequest(db, pr.id);
|
|
475
476
|
|
|
476
|
-
const retrieved = getPullRequestById(db, pr.id);
|
|
477
|
+
const retrieved = await getPullRequestById(db, pr.id);
|
|
477
478
|
expect(retrieved).toBeUndefined();
|
|
478
479
|
});
|
|
479
480
|
|
|
480
|
-
it('should not throw when deleting non-existent PR', () => {
|
|
481
|
-
expect(
|
|
481
|
+
it('should not throw when deleting non-existent PR', async () => {
|
|
482
|
+
await expect(deletePullRequest(db, 'non-existent-id')).resolves.not.toThrow();
|
|
482
483
|
});
|
|
483
484
|
});
|
|
484
485
|
|
|
485
486
|
describe('isAgentReviewingPR', () => {
|
|
486
|
-
it('should return true if agent has a PR in reviewing status', () => {
|
|
487
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
488
|
-
updatePullRequest(db, pr.id, {
|
|
487
|
+
it('should return true if agent has a PR in reviewing status', async () => {
|
|
488
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
489
|
+
await updatePullRequest(db, pr.id, {
|
|
489
490
|
status: 'reviewing',
|
|
490
491
|
reviewedBy: 'qa-agent-1',
|
|
491
492
|
});
|
|
492
493
|
|
|
493
|
-
expect(isAgentReviewingPR(db, 'qa-agent-1')).toBe(true);
|
|
494
|
+
expect(await isAgentReviewingPR(db, 'qa-agent-1')).toBe(true);
|
|
494
495
|
});
|
|
495
496
|
|
|
496
|
-
it('should return false if agent has no PRs in reviewing status', () => {
|
|
497
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
498
|
-
updatePullRequest(db, pr.id, {
|
|
497
|
+
it('should return false if agent has no PRs in reviewing status', async () => {
|
|
498
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
499
|
+
await updatePullRequest(db, pr.id, {
|
|
499
500
|
status: 'approved',
|
|
500
501
|
reviewedBy: 'qa-agent-1',
|
|
501
502
|
});
|
|
502
503
|
|
|
503
|
-
expect(isAgentReviewingPR(db, 'qa-agent-1')).toBe(false);
|
|
504
|
+
expect(await isAgentReviewingPR(db, 'qa-agent-1')).toBe(false);
|
|
504
505
|
});
|
|
505
506
|
|
|
506
|
-
it('should return false if agent has never reviewed any PR', () => {
|
|
507
|
-
expect(isAgentReviewingPR(db, 'non-existent-agent')).toBe(false);
|
|
507
|
+
it('should return false if agent has never reviewed any PR', async () => {
|
|
508
|
+
expect(await isAgentReviewingPR(db, 'non-existent-agent')).toBe(false);
|
|
508
509
|
});
|
|
509
510
|
|
|
510
|
-
it('should not count PRs reviewed by other agents', () => {
|
|
511
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
512
|
-
updatePullRequest(db, pr.id, {
|
|
511
|
+
it('should not count PRs reviewed by other agents', async () => {
|
|
512
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
513
|
+
await updatePullRequest(db, pr.id, {
|
|
513
514
|
status: 'reviewing',
|
|
514
515
|
reviewedBy: 'qa-agent-1',
|
|
515
516
|
});
|
|
516
517
|
|
|
517
|
-
expect(isAgentReviewingPR(db, 'qa-agent-2')).toBe(false);
|
|
518
|
+
expect(await isAgentReviewingPR(db, 'qa-agent-2')).toBe(false);
|
|
518
519
|
});
|
|
519
520
|
|
|
520
|
-
it('should return true only if status is exactly reviewing', () => {
|
|
521
|
+
it('should return true only if status is exactly reviewing', async () => {
|
|
521
522
|
const statuses: Array<
|
|
522
523
|
'queued' | 'reviewing' | 'approved' | 'merged' | 'rejected' | 'closed'
|
|
523
524
|
> = ['queued', 'approved', 'merged', 'rejected', 'closed'];
|
|
524
525
|
|
|
525
526
|
for (const status of statuses) {
|
|
526
|
-
const pr = createPullRequest(db, { branchName: `test-${status}` });
|
|
527
|
-
updatePullRequest(db, pr.id, {
|
|
527
|
+
const pr = await createPullRequest(db, { branchName: `test-${status}` });
|
|
528
|
+
await updatePullRequest(db, pr.id, {
|
|
528
529
|
status,
|
|
529
530
|
reviewedBy: 'qa-agent-test',
|
|
530
531
|
});
|
|
531
532
|
}
|
|
532
533
|
|
|
533
|
-
expect(isAgentReviewingPR(db, 'qa-agent-test')).toBe(false);
|
|
534
|
+
expect(await isAgentReviewingPR(db, 'qa-agent-test')).toBe(false);
|
|
534
535
|
});
|
|
535
536
|
|
|
536
|
-
it('should handle multiple PRs and return true if any is reviewing', () => {
|
|
537
|
-
const pr1 = createPullRequest(db, { branchName: 'test-1' });
|
|
538
|
-
updatePullRequest(db, pr1.id, {
|
|
537
|
+
it('should handle multiple PRs and return true if any is reviewing', async () => {
|
|
538
|
+
const pr1 = await createPullRequest(db, { branchName: 'test-1' });
|
|
539
|
+
await updatePullRequest(db, pr1.id, {
|
|
539
540
|
status: 'approved',
|
|
540
541
|
reviewedBy: 'qa-agent-1',
|
|
541
542
|
});
|
|
542
543
|
|
|
543
|
-
const pr2 = createPullRequest(db, { branchName: 'test-2' });
|
|
544
|
-
updatePullRequest(db, pr2.id, {
|
|
544
|
+
const pr2 = await createPullRequest(db, { branchName: 'test-2' });
|
|
545
|
+
await updatePullRequest(db, pr2.id, {
|
|
545
546
|
status: 'reviewing',
|
|
546
547
|
reviewedBy: 'qa-agent-1',
|
|
547
548
|
});
|
|
548
549
|
|
|
549
|
-
expect(isAgentReviewingPR(db, 'qa-agent-1')).toBe(true);
|
|
550
|
+
expect(await isAgentReviewingPR(db, 'qa-agent-1')).toBe(true);
|
|
550
551
|
});
|
|
551
552
|
});
|
|
552
553
|
|
|
553
554
|
describe('edge cases', () => {
|
|
554
|
-
it('should handle all PR statuses', () => {
|
|
555
|
+
it('should handle all PR statuses', async () => {
|
|
555
556
|
const statuses: Array<
|
|
556
557
|
'queued' | 'reviewing' | 'approved' | 'merged' | 'rejected' | 'closed'
|
|
557
558
|
> = ['queued', 'reviewing', 'approved', 'merged', 'rejected', 'closed'];
|
|
558
559
|
|
|
559
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
560
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
560
561
|
|
|
561
|
-
|
|
562
|
-
const updated = updatePullRequest(db, pr.id, { status });
|
|
562
|
+
for (const status of statuses) {
|
|
563
|
+
const updated = await updatePullRequest(db, pr.id, { status });
|
|
563
564
|
expect(updated?.status).toBe(status);
|
|
564
|
-
}
|
|
565
|
+
}
|
|
565
566
|
});
|
|
566
567
|
|
|
567
|
-
it('should handle very long review notes', () => {
|
|
568
|
-
const pr = createPullRequest(db, { branchName: 'test' });
|
|
568
|
+
it('should handle very long review notes', async () => {
|
|
569
|
+
const pr = await createPullRequest(db, { branchName: 'test' });
|
|
569
570
|
const longNotes = 'A'.repeat(50000);
|
|
570
571
|
|
|
571
|
-
const updated = updatePullRequest(db, pr.id, { reviewNotes: longNotes });
|
|
572
|
+
const updated = await updatePullRequest(db, pr.id, { reviewNotes: longNotes });
|
|
572
573
|
|
|
573
574
|
expect(updated?.review_notes).toBe(longNotes);
|
|
574
575
|
});
|
|
575
576
|
|
|
576
|
-
it('should handle special characters in branch names', () => {
|
|
577
|
-
const pr = createPullRequest(db, {
|
|
577
|
+
it('should handle special characters in branch names', async () => {
|
|
578
|
+
const pr = await createPullRequest(db, {
|
|
578
579
|
branchName: 'feature/STORY-123_fix-bug-with-dashes',
|
|
579
580
|
});
|
|
580
581
|
|
|
581
582
|
expect(pr.branch_name).toBe('feature/STORY-123_fix-bug-with-dashes');
|
|
582
583
|
});
|
|
583
584
|
|
|
584
|
-
it('should handle null fields', () => {
|
|
585
|
-
const pr = createPullRequest(db, {
|
|
585
|
+
it('should handle null fields', async () => {
|
|
586
|
+
const pr = await createPullRequest(db, {
|
|
586
587
|
branchName: 'test',
|
|
587
588
|
submittedBy: 'agent-1',
|
|
588
589
|
});
|
|
589
590
|
|
|
590
|
-
const updated = updatePullRequest(db, pr.id, {
|
|
591
|
+
const updated = await updatePullRequest(db, pr.id, {
|
|
591
592
|
reviewedBy: null,
|
|
592
593
|
reviewNotes: null,
|
|
593
594
|
});
|
|
@@ -599,12 +600,12 @@ describe('pull-requests queries', () => {
|
|
|
599
600
|
|
|
600
601
|
describe('getPrioritizedMergeQueue', () => {
|
|
601
602
|
it('should prioritize by age when no story dependencies', async () => {
|
|
602
|
-
const pr1 = createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
603
|
-
const pr2 = createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
604
|
-
const pr3 = createPullRequest(db, { branchName: 'branch-3', teamId });
|
|
603
|
+
const pr1 = await createPullRequest(db, { branchName: 'branch-1', teamId });
|
|
604
|
+
const pr2 = await createPullRequest(db, { branchName: 'branch-2', teamId });
|
|
605
|
+
const pr3 = await createPullRequest(db, { branchName: 'branch-3', teamId });
|
|
605
606
|
|
|
606
607
|
const { getPrioritizedMergeQueue } = await import('./pull-requests.js');
|
|
607
|
-
const queue = getPrioritizedMergeQueue(db, teamId);
|
|
608
|
+
const queue = await getPrioritizedMergeQueue(db, teamId);
|
|
608
609
|
|
|
609
610
|
// Should be ordered: pr1 (oldest), pr2, pr3 (newest)
|
|
610
611
|
expect(queue[0].id).toBe(pr1.id);
|
|
@@ -614,17 +615,17 @@ describe('pull-requests queries', () => {
|
|
|
614
615
|
|
|
615
616
|
it('should prioritize PRs with satisfied dependencies', async () => {
|
|
616
617
|
// Create two base stories: story1 and story2
|
|
617
|
-
const story1 = createStory(db, {
|
|
618
|
+
const story1 = await createStory(db, {
|
|
618
619
|
title: 'Story 1 - Base',
|
|
619
620
|
description: 'Base story',
|
|
620
621
|
teamId,
|
|
621
622
|
});
|
|
622
|
-
const story2 = createStory(db, {
|
|
623
|
+
const story2 = await createStory(db, {
|
|
623
624
|
title: 'Story 2 - Dependent',
|
|
624
625
|
description: 'Dependent story',
|
|
625
626
|
teamId,
|
|
626
627
|
});
|
|
627
|
-
const story3 = createStory(db, {
|
|
628
|
+
const story3 = await createStory(db, {
|
|
628
629
|
title: 'Story 3 - Independent',
|
|
629
630
|
description: 'Independent story',
|
|
630
631
|
teamId,
|
|
@@ -632,16 +633,16 @@ describe('pull-requests queries', () => {
|
|
|
632
633
|
|
|
633
634
|
// Add dependency: story2 depends on story1
|
|
634
635
|
const { addStoryDependency } = await import('./stories.js');
|
|
635
|
-
addStoryDependency(db, story2.id, story1.id);
|
|
636
|
+
await addStoryDependency(db, story2.id, story1.id);
|
|
636
637
|
|
|
637
638
|
// Create PRs in order: story3 (independent, oldest), story2 (dependent, newer), story1 (base, newest)
|
|
638
|
-
const pr3 = createPullRequest(db, {
|
|
639
|
+
const pr3 = await createPullRequest(db, {
|
|
639
640
|
storyId: story3.id,
|
|
640
641
|
branchName: 'feature/story3-independent',
|
|
641
642
|
teamId,
|
|
642
643
|
});
|
|
643
644
|
|
|
644
|
-
const pr2_unsatisfied = createPullRequest(db, {
|
|
645
|
+
const pr2_unsatisfied = await createPullRequest(db, {
|
|
645
646
|
storyId: story2.id,
|
|
646
647
|
branchName: 'feature/story2-unsatisfied',
|
|
647
648
|
teamId,
|
|
@@ -649,16 +650,10 @@ describe('pull-requests queries', () => {
|
|
|
649
650
|
|
|
650
651
|
// Update story1 to merged status (satisfies story2's dependency)
|
|
651
652
|
const { updateStory } = await import('./stories.js');
|
|
652
|
-
updateStory(db, story1.id, { status: 'merged' });
|
|
653
|
+
await updateStory(db, story1.id, { status: 'merged' });
|
|
653
654
|
|
|
654
655
|
const { getPrioritizedMergeQueue } = await import('./pull-requests.js');
|
|
655
|
-
const queue = getPrioritizedMergeQueue(db, teamId);
|
|
656
|
-
|
|
657
|
-
// Expected order:
|
|
658
|
-
// 1. pr2_unsatisfied (has unsatisfied dependency) - should be deprioritized
|
|
659
|
-
// 2. pr3 (independent, no dependencies) - by age after unsatisfied ones
|
|
660
|
-
// Actually: dependencies satisfied > no dependencies
|
|
661
|
-
// So: pr2 should be LAST (unsatisfied), pr3 and pr2_before_merge should be by age
|
|
656
|
+
const queue = await getPrioritizedMergeQueue(db, teamId);
|
|
662
657
|
|
|
663
658
|
const indexIndependent = queue.findIndex(p => p.id === pr3.id);
|
|
664
659
|
const indexUnsatisfied = queue.findIndex(p => p.id === pr2_unsatisfied.id);
|