test: unit tests for task queue (priority, retry, dead letter) - #452
test: unit tests for task queue (priority, retry, dead letter)#452Kaycee276 wants to merge 5 commits into
Conversation
|
Hi @Kaycee276 👋 — the tests themselves look good (+158, clean diff, Sonar green), but the required CI fails at Fix: rebase your branch onto the latest |
|
Hi @leocagli I've pushed an update that addresses your feedback:
The CI should be completely green now. Let me know if anything else is needed! |
|
Hi @Kaycee276 👋 — quick update: video/screenshots are not required to merge anymore, just a bonus — if you add one it'll be considered for GrantFox rewards on this issue. So I'll review this on code + checks alone now. 🙏 |
Needs a rebase — and that is our fault, not yoursWe just merged a batch of PRs that had been waiting far too long for review. Yours was in that batch and was green, but the merges ahead of it touched overlapping files, so this branch now conflicts with To get it in: git fetch origin
git rebase origin/main
# resolve conflicts, then
git push --force-with-leaseOnce CI goes green again, comment here and it gets merged — no second review round needed for the parts that were already approved. Sorry for the churn. The delay that caused this was on our side: this PR sat for weeks while other work landed on top of it. |
|



Title
test: unit tests for task queue (priority, retry, dead letter)
Context
PR #178 introduced a task queue with priority ordering, a dead-letter queue, and retry logic with backoff, but it did not include tests or fully expose the
dequeue(),peekNext(), andretryAll()methods. This PR fulfills the acceptance criteria for issue #186 by implementing the missing methods and writing comprehensive unit tests.Implementation Details
peekNext()tolib/agent-runtime/task-queue.ts: Retrieves the highest-priority pending task without modifying its state.dequeue()tolib/agent-runtime/task-queue.ts: UsespeekNext()to get the next task and transitions its status to"leased".retryAll()tolib/agent-runtime/task-queue.ts: Iterates over the dead-letter queue and callsretryDeadLetterTask()on all failed tasks.lib/task-queue/__tests__/task-queue.test.ts:vi.useFakeTimers()to fast-forward through the N retry attempts and verify the task eventually moves to thedead-letterqueue.retryAll()accurately resets dead-letter tasks back topending.dequeue()on an empty queue safely returnsnull.Requestobjects to test both thePOST /api/tasksandGET /api/tasks/[id]Next.js route handlers directly.Verification
enqueueTask,failTask, or API routes.closes #186