T-HUB/packages/connector-slack/src/contract.test.ts
glass beadian aa5e262f3a Tactical Media Broadcast Hub — initial release
Self-hosted multi-platform broadcast newsroom for activist collectives:
publishing pipeline with group approval and DST-proof scheduling, TweetDeck-style
column wall with hostile-content-safe rendering, live control room with Auto
Director, bridged chat governance with polls and quorum, distributed sandboxed
transcode workers, encrypted content-addressed archive, monthly analytics.

MIT licensed. See README.md and docs/.
2026-10-10 11:56:42 +00:00

36 lines
1.3 KiB
TypeScript

import type { ConnectorConnection } from "@tactical-media-broadcast-hub/core";
import { connectorContractTests } from "@tactical-media-broadcast-hub/connector-sdk/testing";
import { createSlackConnector } from "./index.js";
const connection: ConnectorConnection = {
id: "conn-slack",
workspaceId: "ws-1",
provider: "slack",
channelId: "C0123456789",
credentialId: { kind: "credential-ref", id: "cred-slack" },
fields: {
botToken: "xoxb-test-token",
teamId: "T0123456789",
},
createdAt: new Date(),
};
const fetchImpl: typeof fetch = async (input, init): Promise<Response> => {
const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
if (url === "https://slack.com/api/auth.test") {
if (new Headers(init?.headers).get("authorization") !== "Bearer xoxb-test-token") {
return new Response(JSON.stringify({ ok: false, error: "invalid_auth" }));
}
return new Response(JSON.stringify({
ok: true,
team: "AnarchoPoster",
team_id: "T0123456789",
user: "anarchoposter",
user_id: "U0123456789",
bot_id: "B0123456789",
}));
}
return new Response(JSON.stringify({ ok: false, error: `unexpected request: ${url}` }));
};
connectorContractTests(createSlackConnector({ fetchImpl }), { connection });