FluxyChat

Reference

Integration test emulators (webhook replay)

Replay recorded Slack, Discord, and Matrix webhook payloads in Vitest without hitting production platforms.

FluxyChat ships a fixture replay harness for bridge webhook routes. Record real payloads once, commit them as JSON, and replay them in CI to catch parser regressions before deploy.

Layout

apps/worker/src/lib/
  integration-emulator.js      # loadFixture, replayWebhookFixture
  bridge-webhook-parsers.js    # Slack / Discord parsers
  fixtures/webhooks/*.json     # Recorded payloads + expectations
  integration-emulator.test.js # Replay suite

Run replay tests

cd apps/worker
npm test -- --run src/lib/integration-emulator.test.js

Add a fixture

  1. Capture the webhook body from bridge logs or a staging tunnel (Slack Events API, Discord interactions, Matrix appservice).
  2. Create fixtures/webhooks/my-case.json:
{
  "name": "slack-mention",
  "platform": "slack",
  "bridgeId": "br_slack_fixture",
  "payload": { "type": "event_callback", "event": { "..." : "..." } },
  "expect": { "status": 200, "ok": true }
}
  1. Add "my-case" to the replay loop in integration-emulator.test.js (or use dynamic listWebhookFixtures() only).
  2. Run Vitest — assertFixtureExpectations validates status and response shape.

Supported routes

PlatformPathParser
SlackPOST /webhooks/bridge/slack/:bridgeIdparseSlackWebhookBody
DiscordPOST /webhooks/bridge/discord/:bridgeIdparseDiscordWebhookBody
MatrixPOST /webhooks/matrix/:bridgeIdappservice transaction processor

API helpers

import {
  loadWebhookFixture,
  createBridgeWebhookRequest,
  replayWebhookFixture,
} from "../lib/integration-emulator.js";
import { dispatchBridgeWebhookRoutes } from "../routes/bridge-webhook-http.js";

const fixture = loadWebhookFixture("slack-message");
const result = await replayWebhookFixture(dispatchBridgeWebhookRoutes, env, h, fixture);

On this page