Repository navigation
Conversation
📝 WalkthroughRecorridoSe agregó una nueva suite de pruebas unitarias en Vitest que valida el comportamiento de cuatro servicios relacionados con órdenes: Cambios
Esfuerzo estimado de revisión de código🎯 2 (Simple) | ⏱️ ~10 minutos PRs posiblemente relacionados
Revisores sugeridos
Poema
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/unit/order/order.test.js (1)
364-394: Las aserciones de filtros son débiles y no verifican el comportamiento real.Los tests para
order_status, múltiples estados y rango de fechas solo verifican que$transactionfue llamado, pero no comprueban que los filtros se apliquen correctamente. Esto significa que si la lógica de filtrado estuviera rota, los tests seguirían pasando.Considerar inspeccionar los argumentos pasados a las queries dentro de la transacción para verificar que los filtros
order_statusydate_from/date_tose construyan correctamente.♻️ Ejemplo de aserción más robusta para el filtro de status
it("aplica filtro por order_status correctamente", async () => { prisma.stores.findFirst.mockResolvedValue({ id_store: 10 }); - prisma.$transaction.mockResolvedValue([[mockOrderFromDB], 1]); + prisma.$transaction.mockImplementation(async (queries) => { + // Capturar y verificar los argumentos de las queries + return [[mockOrderFromDB], 1]; + }); await getStoreOrdersService(1, 10, { order_status: "PENDING" }); - const [findManyCall] = prisma.$transaction.mock.calls[0][0]; - // verificamos que la transacción fue llamada - expect(prisma.$transaction).toHaveBeenCalled(); + expect(prisma.$transaction).toHaveBeenCalled(); + // TODO: Verificar que el where clause incluye { order_status: "PENDING" } });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/order/order.test.js` around lines 364 - 394, The tests for getStoreOrdersService currently only assert prisma.$transaction was called; update each test to inspect the actual query arguments passed into prisma.$transaction (mock.calls[0][0]) and assert the generated Prisma where clauses include the expected filters: for order_status verify the where includes a condition on order_status (or an OR/IN array) matching "PENDING" or ["PENDING","PROCESSING"], and for date_from/date_to verify the where contains created_at (or the appropriate date field) with gte/lte bounds for "2026-01-01" and "2026-12-31"; locate the calls via getStoreOrdersService and prisma.$transaction to make these assertions instead of only checking that the transaction was invoked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/unit/order/order.test.js`:
- Around line 364-394: The tests for getStoreOrdersService currently only assert
prisma.$transaction was called; update each test to inspect the actual query
arguments passed into prisma.$transaction (mock.calls[0][0]) and assert the
generated Prisma where clauses include the expected filters: for order_status
verify the where includes a condition on order_status (or an OR/IN array)
matching "PENDING" or ["PENDING","PROCESSING"], and for date_from/date_to verify
the where contains created_at (or the appropriate date field) with gte/lte
bounds for "2026-01-01" and "2026-12-31"; locate the calls via
getStoreOrdersService and prisma.$transaction to make these assertions instead
of only checking that the transaction was invoked.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: be8aa19b-4ea2-4e9b-b64b-5b4d9d00aff4
📒 Files selected for processing (1)
tests/unit/order/order.test.js
Summary by CodeRabbit
Notas de Lanzamiento