Wachato CRM: versión marca blanca configurable por entorno
CRM de WhatsApp, Instagram, Messenger y TikTok de Wachato, basado en Vocero CRM (MIT), listo para desplegar un negocio por instancia: - Marca blanca: nombre, color, moneda y giro del negocio desde el .env (BRAND_NAME, BRAND_ACCENT, BRAND_CURRENCY, BUSINESS_DESCRIPTION); se aplican una vez y luego manda Ajustes → Marca. - Superadmin sembrado al arrancar (SUPERADMIN_*), idempotente. - Servicios y precios, campos personalizados, exportación a Excel/PDF, respaldos, agenda, atribución de anuncios y transcripción de notas de voz. - Diseño con contraste AAA, tema claro y oscuro. - Despliegue: docker compose (Caddy opcional), plantillas para paneles con reverse proxy (deploy/aapanel), imagen publicada en GHCR por la CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
6edc6020d5
1316 files changed
+308543
No files matched your search
@@ -0,0 +1,91 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
/**
|
||||
* FR-031 / FR-082: una conversación de prueba del Laboratorio JAMÁS alcanza
|
||||
* la API de WhatsApp — sendText lanza antes de cualquier llamada Graph.
|
||||
*/
|
||||
|
||||
const graphRequest = vi.fn();
|
||||
|
||||
vi.mock("@/lib/meta/client", async (importOriginal) => {
|
||||
const original =
|
||||
await importOriginal<typeof import("@/lib/meta/client")>();
|
||||
return { ...original, graphRequest };
|
||||
});
|
||||
|
||||
function makeChain(rows: unknown[]) {
|
||||
const chain: Record<string, unknown> = {};
|
||||
for (const m of ["from", "innerJoin", "where", "orderBy"]) {
|
||||
chain[m] = () => chain;
|
||||
}
|
||||
chain.limit = () => Promise.resolve(rows);
|
||||
return chain;
|
||||
}
|
||||
|
||||
const selectRows: unknown[][] = [];
|
||||
|
||||
vi.mock("@/lib/db", () => ({
|
||||
getDb: () => ({
|
||||
select: () => makeChain(selectRows.shift() ?? []),
|
||||
}),
|
||||
schema: {
|
||||
conversation: { contactId: "contactId", id: "id" },
|
||||
contact: { id: "id" },
|
||||
message: {},
|
||||
},
|
||||
}));
|
||||
|
||||
describe("sandbox del Laboratorio en el sender", () => {
|
||||
beforeEach(() => {
|
||||
graphRequest.mockReset();
|
||||
selectRows.length = 0;
|
||||
});
|
||||
|
||||
it("conversación is_test → lanza sandbox_violation y NO llama a Graph", async () => {
|
||||
selectRows.push([
|
||||
{
|
||||
conversation: {
|
||||
id: "cv_test",
|
||||
organizationId: "org_1",
|
||||
isTest: true,
|
||||
lastInboundAt: new Date(),
|
||||
},
|
||||
contact: { id: "ct_1", phone: "5215511111111" },
|
||||
},
|
||||
]);
|
||||
const { sendText, SendError } = await import("@/server/inbox/send");
|
||||
|
||||
await expect(
|
||||
sendText({
|
||||
conversationId: "cv_test",
|
||||
organizationId: "org_1",
|
||||
text: "hola",
|
||||
})
|
||||
).rejects.toMatchObject({ code: "sandbox_violation" });
|
||||
|
||||
expect(graphRequest).not.toHaveBeenCalled();
|
||||
|
||||
// sanity: el error es del tipo tipado
|
||||
try {
|
||||
selectRows.push([
|
||||
{
|
||||
conversation: {
|
||||
id: "cv_test",
|
||||
organizationId: "org_1",
|
||||
isTest: true,
|
||||
lastInboundAt: new Date(),
|
||||
},
|
||||
contact: { id: "ct_1", phone: "5215511111111" },
|
||||
},
|
||||
]);
|
||||
await sendText({
|
||||
conversationId: "cv_test",
|
||||
organizationId: "org_1",
|
||||
text: "hola",
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).toBeInstanceOf(SendError);
|
||||
}
|
||||
expect(graphRequest).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user