Skip to main content
Glama
mmarqueti

WhatsApp Cloud API MCP Server

by mmarqueti
webhook.test.ts1.98 kB
import { describe, it, expect, vi, beforeEach } from 'vitest'; import request from 'supertest'; import express from 'express'; import { webhookRouter } from '../webhook.js'; import { config } from '../../config/env.js'; // Mock config vi.mock('../../config/env.js', () => ({ config: { META_VERIFY_TOKEN: 'test-token', META_WHATSAPP_TOKEN: 'test-token', META_WHATSAPP_PHONE_ID: 'test-phone-id', PORT: 4000 } })); const app = express(); app.use(express.json()); app.use('/webhook', webhookRouter); describe('Webhook Integration', () => { beforeEach(() => { // Clear storage before each test // We need to access the private array or just add a clear method to storage // For now, we can just assume it works or add a clear method if needed. // But since we are testing ingestion, we can just check if count increases. }); describe('GET /webhook', () => { it('should verify token correctly', async () => { const response = await request(app) .get('/webhook') .query({ 'hub.mode': 'subscribe', 'hub.verify_token': 'test-token', 'hub.challenge': '12345' }); expect(response.status).toBe(200); expect(response.text).toBe('12345'); }); it('should reject invalid token', async () => { const response = await request(app) .get('/webhook') .query({ 'hub.mode': 'subscribe', 'hub.verify_token': 'wrong-token', 'hub.challenge': '12345' }); expect(response.status).toBe(403); }); it('should reject missing params', async () => { const response = await request(app) .get('/webhook'); expect(response.status).toBe(400); }); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mmarqueti/whatsapp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server