better database filters #167
Conversation
|
Warning Review limit reached
Next review available in: 20 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughLas páginas delegan la obtención y transformación de datos a casos de uso resueltos por el contenedor. Se añaden modelos de carrito y checkout, carga del formulario de producto, búsquedas masivas, navegación de portadas y reglas de frontera arquitectónica. ChangesApplication boundaries and composition
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CheckoutPage
participant GetCheckoutViewUseCase
participant GetCartViewUseCase
participant PaidOrderCountPort
CheckoutPage->>GetCheckoutViewUseCase: execute(dto)
GetCheckoutViewUseCase->>GetCartViewUseCase: obtener CartViewData
GetCheckoutViewUseCase->>PaidOrderCountPort: contar pedidos pagados
GetCheckoutViewUseCase-->>CheckoutPage: devolver CheckoutViewData
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 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.
Actionable comments posted: 5
🧹 Nitpick comments (3)
app/[locale]/seller/products/[id]/edit/page.tsx (1)
20-22: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsiderar redirigir al inicio de sesión.
Para mejorar la experiencia del usuario y mantener la consistencia (de manera similar a cómo se maneja en
app/[locale]/seller/orders/page.tsx), podrías considerar el uso deredirectpara enviar a los usuarios no autenticados a la página de inicio de sesión, en lugar de mostrar un error 404.💡 Posible mejora
Asegúrate de agregar
redirecta las importaciones denext/navigation:- if (!session?.id) { - notFound(); - } + if (!session?.id) { + redirect(`/${locale}/auth/signin?callbackUrl=/${locale}/seller/products/${id}/edit`); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@app/`[locale]/seller/products/[id]/edit/page.tsx around lines 20 - 22, Replace the notFound() handling in the unauthenticated branch of the edit page with the existing login redirect pattern used by the seller orders page, importing redirect from next/navigation as needed. Preserve the current authenticated flow.tests/unit/modules/products/application/get-seller-product-form-use-case.test.ts (1)
73-104: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAñade cobertura para un producto inexistente.
La suite cubre un propietario incorrecto, pero no la rama
!product. Añade un caso con el repositorio vacío y verificaNotFoundError.Propuesta de prueba
+ it('rejects a missing product', async () => { + const useCase = new GetSellerProductFormUseCase( + new MemoryProductRepository(), + new ListCategoriesUseCase(categoryRepository()), + sellerLookup('seller-1'), + ); + + await expect( + useCase.execute({ + userId: 'user-1', + productId: 'missing-product', + locale: 'es', + }), + ).rejects.toBeInstanceOf(NotFoundError); + });As per coding guidelines, tests must include “invalid inputs” and “error conditions”.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/modules/products/application/get-seller-product-form-use-case.test.ts` around lines 73 - 104, añade un caso de prueba para producto inexistente junto al test de propiedad incorrecta, usando un MemoryProductRepository vacío y ejecutando GetSellerProductFormUseCase con un productId que no existe; verifica que useCase.execute rechace con NotFoundError para cubrir la rama !product.Source: Coding guidelines
tests/unit/composition-root/container-use-case-cache.test.ts (1)
14-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winVerifica cada dependencia que invalida la vista del carrito.
Repite la aserción al sustituir
CartProductRepositoryyCustomizationLookup; comprueba también que estas sustituciones reconstruyen el checkout derivado. Ahora solo queda protegida la ruta deCartRepository.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/composition-root/container-use-case-cache.test.ts` around lines 14 - 23, Amplía la prueba `rebuilds the cart view after replacing the cart repository` para verificar que sustituir `CartProductRepository` y `CustomizationLookup` también invalida y reconstruye `getCartViewUseCase()`. Añade aserciones independientes tras cada reemplazo, manteniendo la comprobación existente para `CartRepository` y cubriendo igualmente la reconstrucción del checkout derivado.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@modules/cart/application/get-checkout-view-use-case.ts`:
- Around line 95-107: Actualiza emptyCheckoutView para que un checkout sin
artículos devuelva shipping y total en cero, en lugar de usar SHIPPING_COST.
Mantén sin cambios los demás valores del estado vacío.
In `@modules/cart/infrastructure/cart-product-repository-adapter.ts`:
- Line 6: El adaptador CartProductRepositoryAdapter importa y ejecuta lógica de
dominio de Products mediante resolveDisplay, cruzando el límite modular.
Sustituye esa dependencia por un puerto/query de Products que devuelva
directamente el nombre localizado, y actualiza el adaptador para transformar
únicamente ese contrato en ProductSnapshot, eliminando la importación y uso de
resolveDisplay.
In `@tests/unit/modules/cart/application/get-cart-view-use-case.test.ts`:
- Around line 12-120: Extend the GetCartViewUseCase tests with an empty-cart
case using the existing repository fakes: save a cart whose items array is
empty, execute the use case, and assert the result is { items: [] }. Configure
or inspect the product and customization repositories to verify neither is
queried during processing.
In `@tests/unit/modules/cart/application/get-checkout-view-use-case.test.ts`:
- Around line 14-76: The GetCheckoutViewUseCase tests only cover the discounted
first-purchase path. Add tests covering an empty cart with shipping and total
equal to zero, mixed currencies that reject with ValidationError, and a repeat
buyer with no discount, reusing the existing repositories and execute setup from
the current test.
In
`@tests/unit/modules/cart/infrastructure/cart-product-repository-adapter.test.ts`:
- Around line 6-15: Amplía la prueba alrededor de
CartProductRepositoryAdapter.findByIds para que el mock findByIds devuelva un
producto de ejemplo en lugar de un arreglo vacío y verifica el resultado
transformado por el adaptador. Incluye aserciones sobre displayName, sellerName,
imageUrl e images, manteniendo también la comprobación de que la delegación usa
los IDs y la categoría esperados.
---
Nitpick comments:
In `@app/`[locale]/seller/products/[id]/edit/page.tsx:
- Around line 20-22: Replace the notFound() handling in the unauthenticated
branch of the edit page with the existing login redirect pattern used by the
seller orders page, importing redirect from next/navigation as needed. Preserve
the current authenticated flow.
In `@tests/unit/composition-root/container-use-case-cache.test.ts`:
- Around line 14-23: Amplía la prueba `rebuilds the cart view after replacing
the cart repository` para verificar que sustituir `CartProductRepository` y
`CustomizationLookup` también invalida y reconstruye `getCartViewUseCase()`.
Añade aserciones independientes tras cada reemplazo, manteniendo la comprobación
existente para `CartRepository` y cubriendo igualmente la reconstrucción del
checkout derivado.
In
`@tests/unit/modules/products/application/get-seller-product-form-use-case.test.ts`:
- Around line 73-104: añade un caso de prueba para producto inexistente junto al
test de propiedad incorrecta, usando un MemoryProductRepository vacío y
ejecutando GetSellerProductFormUseCase con un productId que no existe; verifica
que useCase.execute rechace con NotFoundError para cubrir la rama !product.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: fcc9c5a0-6795-4ccc-8371-5fe844094023
📒 Files selected for processing (50)
app/[locale]/admin/configuration/page.tsxapp/[locale]/admin/sellers/[sellerId]/page.tsxapp/[locale]/admin/sellers/[sellerId]/products/page.tsxapp/[locale]/admin/sellers/page.tsxapp/[locale]/cart/page.tsxapp/[locale]/checkout/page.tsxapp/[locale]/orders/[orderId]/page.tsxapp/[locale]/orders/page.tsxapp/[locale]/page.module.cssapp/[locale]/page.tsxapp/[locale]/products/[id]/page.tsxapp/[locale]/seller/orders/[orderId]/page.tsxapp/[locale]/seller/orders/page.tsxapp/[locale]/seller/products/[id]/edit/page.tsxapp/[locale]/seller/products/new/page.tsxapp/[locale]/seller/products/page.tsxcomponents/products/infinite-product-list.tsxcomposition-root/container.tsdocs/architecture.mdmodules/cart/application/get-cart-view-use-case.tsmodules/cart/application/get-checkout-view-use-case.tsmodules/cart/domain/product-snapshot.tsmodules/cart/infrastructure/cart-product-repository-adapter.tsmodules/orders/infrastructure/product-repository-adapter.tsmodules/products/application/get-seller-product-form-use-case.tsmodules/products/application/list-categories-use-case.tsmodules/products/domain/product-repository.tsmodules/products/domain/seller-ownership-lookup-port.tsmodules/products/infrastructure/prisma-product-repository.tsmodules/products/infrastructure/seller-ownership-lookup-adapter.tstests/doubles/memory-cart-product-repository.tstests/doubles/memory-product-repository.tstests/unit/app/[locale]/admin/configuration/page.test.tsxtests/unit/app/[locale]/admin/sellers/[sellerId]/page.test.tsxtests/unit/app/[locale]/admin/sellers/[sellerId]/products/page.test.tsxtests/unit/app/[locale]/admin/sellers/page.test.tsxtests/unit/app/[locale]/checkout/page.test.tsxtests/unit/app/[locale]/orders/page.test.tsxtests/unit/app/[locale]/page.test.tsxtests/unit/app/[locale]/products/[id]/page.test.tsxtests/unit/app/[locale]/seller/orders/page.test.tsxtests/unit/app/[locale]/seller/products/page.test.tsxtests/unit/components/products/infinite-product-list.test.tsxtests/unit/composition-root/container-use-case-cache.test.tstests/unit/modules/cart/application/get-cart-view-use-case.test.tstests/unit/modules/cart/application/get-checkout-view-use-case.test.tstests/unit/modules/cart/infrastructure/cart-product-repository-adapter.test.tstests/unit/modules/products/application/get-seller-product-form-use-case.test.tstests/unit/modules/products/application/list-categories-use-case.test.tstests/unit/modules/products/infrastructure/prisma-product-repository.test.ts
💤 Files with no reviewable changes (10)
- tests/unit/app/[locale]/checkout/page.test.tsx
- tests/unit/app/[locale]/admin/sellers/[sellerId]/products/page.test.tsx
- tests/unit/app/[locale]/admin/configuration/page.test.tsx
- tests/unit/app/[locale]/admin/sellers/[sellerId]/page.test.tsx
- tests/unit/app/[locale]/orders/page.test.tsx
- tests/unit/app/[locale]/admin/sellers/page.test.tsx
- tests/unit/app/[locale]/page.test.tsx
- tests/unit/app/[locale]/products/[id]/page.test.tsx
- tests/unit/app/[locale]/seller/products/page.test.tsx
- tests/unit/app/[locale]/seller/orders/page.test.tsx
Summary by CodeRabbit
Nuevas funcionalidades
Mejoras visuales
Pruebas