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 4 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. 🙏 |
|



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