Skip to content

fix(negocios): PUT/DELETE URL mismatch and add E2E CRUD coverage - #7

Merged
casasleonj merged 1 commit into
mainfrom
fix/negocios-put-delete-url
Jul 7, 2026
Merged

casasleonj merged 1 commit into
mainfrom
fix/negocios-put-delete-url

Conversation

@casasleonj

Copy link
Copy Markdown
Owner

What

Fixes a critical bug where negocio edit and delete from the UI were failing silently with "Error de conexión", and adds full E2E CRUD coverage for the negocio section.

Bug root cause

  • src/app/api/negocios/route.ts PUT/DELETE handlers extracted the negocio id from url.pathname.split('/').pop().
  • The clients (NegocioForm and NegocioDetailModal) called /api/negocios/:id (path param).
  • There is no /api/negocios/[id]/route.ts file, so those requests hit a 404 and res.json() threw → "Error de conexión".

Fix

  • Server now reads id from ?id= query param.
  • Clients now call /api/negocios?id=... for PUT and DELETE.

New E2E test

e2e/negocios-crud.spec.ts covers all admin UI contexts:

  1. Create negocio from cliente detail.
  2. View negocio detail modal.
  3. Edit negocio from detail modal.
  4. Edit negocio from card pencil button.
  5. "Ver pedidos" link navigates to /pedidos?clienteId=....
  6. Delete negocio.
  7. Delete blocked when negocio has pedidos asociados.

Verification

  • npx tsc --noEmit ✅
  • npm run test -- --run ✅ 1836 passed
  • npx playwright test e2e/negocios-crud.spec.ts --project=chromium ✅ 7 passed

Files changed

  • src/app/api/negocios/route.ts
  • src/components/negocio-form.tsx
  • src/components/negocio-detail-modal.tsx
  • e2e/fixtures.ts
  • e2e/negocios-crud.spec.ts (new)

- Fix /api/negocios PUT and DELETE to read id from ?id= query param
  (route.ts was parsing pathname but clients called /api/negocios/:id).
- Update NegocioForm edit URL to /api/negocios?id=...
- Update NegocioDetailModal delete URL to /api/negocios?id=...
- Extend createNegocio E2E helper with referencia, linkUbicacion, horaApertura.
- Add e2e/negocios-crud.spec.ts covering admin CRUD from /clientes:
  create, detail modal, edit from detail, edit from card, Ver pedidos link,
  delete, and delete-blocked when negocio has pedidos.

Verification:
- npx tsc --noEmit ✅
- npm run test -- --run ✅ 1836 passed
- npx playwright test e2e/negocios-crud.spec.ts --project=chromium ✅ 7 passed
@vercel

vercel Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bambu_demo_multimodelo Ready Ready Preview, Comment Jul 7, 2026 5:48pm

@casasleonj
casasleonj merged commit d36a6ba into main Jul 7, 2026
1 check passed
@casasleonj
casasleonj deleted the fix/negocios-put-delete-url branch July 17, 2026 16:01

This branch was successfully deployed

1 active deployment
Preview — 9037e39f Deployed Jul 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant