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,95 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
/**
|
||||
* #86 — Quién entra a la guía y a dónde manda la raíz. Las dos páginas se
|
||||
* prueban con sus dependencias falsas: solo interesa la decisión.
|
||||
*/
|
||||
|
||||
const getSessionOrNull = vi.hoisted(() => vi.fn());
|
||||
const guideStatus = vi.hoisted(() => vi.fn());
|
||||
const guideFirst = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("@/lib/auth/session", () => ({ getSessionOrNull }));
|
||||
vi.mock("@/server/onboarding/guide", () => ({ guideStatus, guideFirst }));
|
||||
vi.mock("@/components/onboarding/onboarding-client", () => ({
|
||||
OnboardingClient: () => null,
|
||||
}));
|
||||
vi.mock("next/navigation", () => ({
|
||||
redirect: (path: string) => {
|
||||
throw new Error(`redirect:${path}`);
|
||||
},
|
||||
}));
|
||||
vi.mock("@/lib/db", () => ({
|
||||
getDb: () => ({
|
||||
select: () => ({
|
||||
from: () => ({
|
||||
where: () => ({ limit: () => Promise.resolve([{ name: "Sofi" }]) }),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
schema: { agentProfile: { organizationId: "organization_id", name: "name" } },
|
||||
}));
|
||||
|
||||
import OnboardingPage from "@/app/(app)/onboarding/page";
|
||||
import Home from "@/app/page";
|
||||
import { canConfigure } from "@/lib/auth/roles";
|
||||
|
||||
const owner = { userId: "usr_1", organizationId: "org_1", role: "owner" };
|
||||
const member = { userId: "usr_2", organizationId: "org_1", role: "member" };
|
||||
|
||||
beforeEach(() => {
|
||||
getSessionOrNull.mockReset();
|
||||
guideStatus.mockReset();
|
||||
guideFirst.mockReset();
|
||||
});
|
||||
|
||||
describe("quién configura", () => {
|
||||
it("el propietario y un admin; un miembro del equipo no", () => {
|
||||
expect(canConfigure("owner")).toBe(true);
|
||||
expect(canConfigure("admin")).toBe(true);
|
||||
expect(canConfigure("member")).toBe(false);
|
||||
expect(canConfigure(undefined)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("/onboarding", () => {
|
||||
it("sin sesión manda al login", async () => {
|
||||
getSessionOrNull.mockResolvedValue(null);
|
||||
await expect(OnboardingPage()).rejects.toThrow("redirect:/login");
|
||||
});
|
||||
|
||||
it("un miembro del equipo va a la Bandeja: no puede hacer ningún paso", async () => {
|
||||
getSessionOrNull.mockResolvedValue(member);
|
||||
await expect(OnboardingPage()).rejects.toThrow("redirect:/inbox");
|
||||
expect(guideStatus).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("el propietario ve la guía resuelta en el servidor", async () => {
|
||||
getSessionOrNull.mockResolvedValue(owner);
|
||||
guideStatus.mockResolvedValue({ steps: [], complete: false, enabled: false });
|
||||
const page = (await OnboardingPage()) as { props: { agentName: string | null } };
|
||||
expect(guideStatus).toHaveBeenCalledWith("org_1");
|
||||
expect(page.props.agentName).toBe("Sofi");
|
||||
});
|
||||
});
|
||||
|
||||
describe("la raíz", () => {
|
||||
it("sin sesión sigue yendo a la Bandeja (que manda al login)", async () => {
|
||||
getSessionOrNull.mockResolvedValue(null);
|
||||
await expect(Home()).rejects.toThrow("redirect:/inbox");
|
||||
expect(guideFirst).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("al dueño con pasos pendientes lo manda a la guía", async () => {
|
||||
getSessionOrNull.mockResolvedValue(owner);
|
||||
guideFirst.mockResolvedValue(true);
|
||||
await expect(Home()).rejects.toThrow("redirect:/onboarding");
|
||||
expect(guideFirst).toHaveBeenCalledWith(owner);
|
||||
});
|
||||
|
||||
it("con todo listo y el agente encendido, a la Bandeja como siempre", async () => {
|
||||
getSessionOrNull.mockResolvedValue(owner);
|
||||
guideFirst.mockResolvedValue(false);
|
||||
await expect(Home()).rejects.toThrow("redirect:/inbox");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user