Skip to content
// EFFECT DAYS 2026

ChatTest unstable

Testing tools for chat adapters and their consumers.

layer builds a whole chat in memory: Chat, its registry and one fake adapter with configurable capabilities and fault injection. conformance is the suite of rules every adapter obeys, as plain Effects keyed by rule name. checkMessage, checkEvent and checkInteraction assert the invariants every message, event and interaction holds, for fixture tests and live runs.

Details

The fake adapter's mention syntax is <@id> for a user, <@&id> for a role, <#id> for a channel and <!id> for a broadcast.

12 exports Since v4.1.5 Source

Comparisons

sameMessage

unstable
Since v4.1.5

Returns whether two reads of a message are the same message.

Details

It compares id, thread, author.id, author.isBot, author.isSelf, text, mentions, replyTo, timestamp and the attachment ids in order. raw, author.name and the optional attachment fields are left out.

Signature

declare function sameMessage(a: {
readonly attachments: readonly Array<{
readonly contentType?: string;
readonly id: string;
readonly name?: string;
readonly size?: number;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: "role" | "user" | "channel" | "broadcast";
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
}, b: {
readonly attachments: readonly Array<{
readonly contentType?: string;
readonly id: string;
readonly name?: string;
readonly size?: number;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: "role" | "user" | "channel" | "broadcast";
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
}): boolean

Errors

Since v4.1.5

Error for a conformance rule or invariant that did not hold.

Details

rule names what failed, and expected and actual say how. A platform error behind the failure is in cause.

Signature

declare class ConformanceFailure extends {
readonly _tag: "ConformanceFailure";
readonly actual: string;
readonly cause?: unknown;
readonly expected: string;
readonly rule: string;
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "ConformanceFailure";
readonly actual: string;
readonly cause?: unknown;
readonly expected: string;
readonly rule: string;
}, options?: MakeOptions]);
message: string;
}
Since v4.1.5

Error for a click on an element the message does not carry, or on a message that is gone.

Signature

declare class NoSuchElement extends {
readonly _tag: "NoSuchElement";
readonly id: string;
readonly messageId: string;
} & YieldableError<this> {
constructor(...args: [props: {
readonly _tag?: "NoSuchElement";
readonly id: string;
readonly messageId: string;
}, options?: MakeOptions]);
}

Layers

layer

unstable
Since v4.1.5

Creates a whole chat in memory: Chat, its registry and one fake adapter.

When to use

Use to test code that posts and reads through Chat, and to run the conformance suite against the fake adapter.

Details

  • The platform defaults to test and the bot's user id to bot.
  • Every capability is on by default.
  • measure defaults to a count of code points, and the fake checks every length with it.
  • The default limits are 4000 per message, 10 files of up to 10 MiB, and no write interval. With nativeStream on, a stream takes up to messageLength and lasts 10 minutes.
  • The native stream behaves the way Slack's was found to. An append past limits.streamLength fails with TooLarge and adds nothing. A stream past limits.streamAge, on Clock, is closed. An append without flush holds back an unclosed < tail of up to 100 characters, or a trailing high surrogate. Any other lone surrogate is stored as U+FFFD. An open stream refuses edit and delete.
  • With buttons or selects on, a message takes 25 elements, and an element's id plus encoded value 100 code points. With modals on, a modal's id plus encoded metadata takes 100 code points, and a modal 5 fields. Each limit is there only with its capability.
  • interact gives a handler 3 seconds by default, on Clock.
  • With commands on, limits.followUpAge is 15 minutes.
  • Two layers merged with different platforms share one Chat, so routing can be tested. The ChatTest service in context is the last one merged.

Signature

declare function layer(options?: {
readonly capabilities?: readonly Array<"getUser" | "edit" | "delete" | "fetchMessage" | "history" | "download" | "startThread" | "getThread" | "opener" | "files" | "replyTo" | "nativeStream" | "buttons" | "selects" | "modals" | "modalErrors" | "commands" | "ephemeral">;
readonly interactionDeadline?: Duration;
readonly limits?: Partial<{
readonly actionDataLength?: number;
readonly actionsPerMessage?: number;
readonly filesPerMessage: number;
readonly followUpAge?: Duration;
readonly messageLength: number;
readonly minWriteInterval: Duration;
readonly modalFields?: number;
readonly modalMetadataLength?: number;
readonly streamAge?: Duration;
readonly streamLength?: number;
readonly uploadBytes: number;
}>;
readonly measure?: (markdown: string, actions?: readonly Array<{
readonly _tag: "Button";
readonly id: string;
readonly label: string;
readonly style?: "default" | "primary" | "danger";
readonly value?: string;
} | {
readonly _tag: "LinkButton";
readonly label: string;
readonly url: string;
} | {
readonly _tag: "Select";
readonly id: string;
readonly options: readonly Array<{
readonly label: string;
readonly value: string;
}>;
readonly placeholder?: string;
readonly selected?: string;
}>) => number;
readonly platform?: string;
readonly selfId?: string;
}): Layer<Chat | Registry | ChatTest>

Models

Call

interface unstable
Since v4.1.5

One call the fake adapter received, in order. Every attempt is a call, so a retried request shows up once per attempt.

Signature

interface Call {
readonly files?: readonly Array<File>;
readonly markdown?: string;
readonly messageId?: string;
readonly op: string;
readonly outcome: "Unknown" | "NotFound" | "Forbidden" | "InvalidRequest" | "RateLimited" | "Unsupported" | "Transport" | "PlatformUnavailable" | "NoAdapter" | "Unauthenticated" | "TooLarge" | "InvalidResponse" | "ok";
readonly thread: {
readonly id: string;
readonly platform: string;
};
}

ParseMention

type unstable
Since v4.1.5

Reads a slice of ChatMessage.text as one of the platform's mention tokens.

Details

The core does not know any platform's syntax, so the caller supplies it. A slice that is not a mention token returns None.

Signature

type ParseMention = (slice: string) => Option.Option<{
readonly id: string;
readonly kind: Mention["kind"];
}>

Services

ChatTest

unstable
Since v4.1.5

Service that controls the fake adapter built by layer.

Details

  • makeThread creates a fresh address: a channel by default, a direct conversation, or a thread under a user's message in a fresh channel.
  • userPosts puts another identity's message in a thread and returns its event without delivering it. deliver delivers an event the way an adapter does, by calling the ChatHandler service.
  • messages is what a thread shows now, oldest first, and calls is every call the adapter received.
  • failNext makes the next times calls of op fail with reason. landed makes the write happen anyway, which is what uncertain means. The native stream's ops are nativeStream.start, nativeStream.append and nativeStream.stop.
  • refuseFiles makes the next times posts with files fail denied with detail file_refused, storing nothing. Text-only posts do not consume it.
  • clickStop is a user clicking stop on a native stream. It closes nothing, as on Slack: the stream keeps taking text, and NativeStream.stop then reports stopped: true.
  • closeStream closes a native stream from outside, so the next append gives closed, or stopped after a click.
  • click builds the click on element id of a message from what the fake stored at post or edit, without delivering it. For a select, option is the encoded value of the option to choose, the first by default. It fails NoSuchElement when the message has no such element, or no such option, or is gone.
  • command builds a command typed at thread, without delivering it. text defaults to the empty string. The fake has no registration, so any id can be typed.
  • submit builds the submit of a modal. It takes the click or the command that opened it, because an OpenModal reply does not say where it was opened from and a ModalSubmitted has to. A command gives a submit with no messageId. values are by field id, still encoded, and an empty one is left out, as for an optional field left empty.
  • interact delivers an interaction the way an adapter does: through ChatInteraction.handle with the layer's interactionDeadline, then the fake's own checks on an OpenModal (the modals capability, limits.modalMetadataLength against the modal's id plus its encoded metadata, and limits.modalFields), calling Handler.refused when one fails. It succeeds with the handler's reply as it returned it, or Late. An OpenModal shows in calls as op openModal.
  • For a command, interact runs the checks of post on a Respond (the element capabilities, limits.messageLength and the element limits), and refuses a private Respond or Defer without ephemeral. A Respond shows in calls as op respond, and a followUp as op followUp, each with the command's thread and the Markdown. Neither is stored as a message.
  • The fake's followUp succeeds once for a Defer that interact returned, inside limits.followUpAge on Clock. Later, a second time, or for a deferral the fake never saw, it fails NotFound with detail interaction_expired. Failing the second call is stricter than either platform, to catch a handler that relies on more than one: Slack posts another message and Discord replaces the first.

Signature

declare class ChatTest extends Shape<"effect/chat/ChatTest", {
readonly calls: Effect<readonly Array<Call>>;
readonly click: (messageId: string, id: string, options?: {
readonly option?: string;
readonly userId?: string;
}) => Effect<{
readonly _tag: "ButtonClicked";
readonly id: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly value?: string;
} | {
readonly _tag: "SelectChanged";
readonly id: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly value: string;
}, NoSuchElement>;
readonly clickStop: (messageId: string) => Effect<void>;
readonly closeStream: (messageId: string) => Effect<void>;
readonly command: (thread: {
readonly id: string;
readonly platform: string;
}, id: string, options?: {
readonly text?: string;
readonly userId?: string;
}) => Effect<{
readonly _tag: "CommandInvoked";
readonly id: string;
readonly raw: Json;
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
}>;
readonly deliver: (event: {
readonly _tag: "MessageCreated";
readonly kind: "channel" | "thread" | "direct";
readonly message: {
readonly attachments: readonly Array<{
readonly contentType?: string;
readonly id: string;
readonly name?: string;
readonly size?: number;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: "role" | "user" | "channel" | "broadcast";
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
};
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
} | {
readonly _tag: "ReactionAdded";
readonly emoji: string;
readonly messageAuthorId?: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp?: Utc;
readonly userId: string;
} | {
readonly _tag: "ReactionRemoved";
readonly emoji: string;
readonly messageAuthorId?: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp?: Utc;
readonly userId: string;
} | {
readonly _tag: "StopRequested";
readonly id: string;
readonly messageIds: readonly Array<string>;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
}) => Effect<void, NotAccepted, ChatHandler>;
readonly failNext: (op: string, reason: ChatErrorReason, options?: {
readonly landed?: boolean;
readonly times?: number;
}) => Effect<void>;
readonly interact: {
(event: {
readonly _tag: "ButtonClicked";
readonly id: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly value?: string;
} | {
readonly _tag: "SelectChanged";
readonly id: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly value: string;
}): Effect<{
readonly _tag: "Late";
} | ClickReply, never, Handler>;
(event: {
readonly _tag: "ModalSubmitted";
readonly id: string;
readonly messageId?: string;
readonly metadata?: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly values: {
[key: string]: string;
};
}): Effect<{
readonly _tag: "Late";
} | SubmitReply, never, Handler>;
(event: {
readonly _tag: "CommandInvoked";
readonly id: string;
readonly raw: Json;
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
}): Effect<{
readonly _tag: "Late";
} | CommandReply, never, Handler>;
};
readonly makeThread: (kind?: "channel" | "thread" | "direct") => Effect<{
readonly id: string;
readonly platform: string;
}>;
readonly messages: (thread: {
readonly id: string;
readonly platform: string;
}) => Effect<readonly Array<{
readonly attachments: readonly Array<{
readonly contentType?: string;
readonly id: string;
readonly name?: string;
readonly size?: number;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: "role" | "user" | "channel" | "broadcast";
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
}>>;
readonly platform: string;
readonly refuseFiles: (options?: {
readonly times?: number;
}) => Effect<void>;
readonly selfId: string;
readonly submit: (from: {
readonly _tag: "CommandInvoked";
readonly id: string;
readonly raw: Json;
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
} | {
readonly _tag: "ButtonClicked";
readonly id: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly value?: string;
} | {
readonly _tag: "SelectChanged";
readonly id: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly value: string;
}, opened: {
readonly _tag: "OpenModal";
readonly modal: {
readonly _tag: "Modal";
readonly elements: readonly Array<{
readonly _tag: "TextInput";
readonly id: string;
readonly initial?: string;
readonly label: string;
readonly maxLength?: number;
readonly minLength?: number;
readonly multiline?: boolean;
readonly optional?: boolean;
readonly placeholder?: string;
} | {
readonly _tag: "SelectInput";
readonly id: string;
readonly initial?: string;
readonly label: string;
readonly optional?: boolean;
readonly options: readonly Array<{
readonly label: ...;
readonly value: ...;
}>;
readonly placeholder?: string;
} | {
readonly _tag: "Text";
readonly text: string;
}>;
readonly id: string;
readonly metadata?: string;
readonly submitLabel?: string;
readonly title: string;
};
}, values: Readonly<Record<string, string>>, options?: {
readonly userId?: string;
}) => Effect<{
readonly _tag: "ModalSubmitted";
readonly id: string;
readonly messageId?: string;
readonly metadata?: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly values: {
[key: string]: string;
};
}>;
readonly userPosts: (thread: {
readonly id: string;
readonly platform: string;
}, message: {
readonly authorId?: string;
readonly files?: readonly Array<File>;
readonly isBot?: boolean;
readonly mentionsSelf?: boolean;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
}) => Effect<{
readonly _tag: "MessageCreated";
readonly kind: "channel" | "thread" | "direct";
readonly message: {
readonly attachments: readonly Array<{
readonly contentType?: ... | ...;
readonly id: string;
readonly name?: ... | ...;
readonly size?: ... | ...;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: ... | ... | ... | ...;
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: ... | ...;
readonly isSelf?: ... | ... | ...;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
};
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
} | {
readonly _tag: "ReactionAdded";
readonly emoji: string;
readonly messageAuthorId?: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp?: Utc;
readonly userId: string;
} | {
readonly _tag: "ReactionRemoved";
readonly emoji: string;
readonly messageAuthorId?: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp?: Utc;
readonly userId: string;
} | {
readonly _tag: "StopRequested";
readonly id: string;
readonly messageIds: readonly Array<string>;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
}>;
}, this> {
constructor(_: never);
}

Testing

checkEvent

unstable
Since v4.1.5

Checks the invariants every event holds, for fixture tests and live runs.

Details

  • A message event's message passes checkMessage, and the event's thread is the message's.
  • thread.platform is the platform, and the thread survives its string codec.
  • The event encodes and decodes through its Schema unchanged, raw included, and two decodes have the same dedupeKey.
  • A reaction's dedupeKey differs between added and removed.

Signature

declare function checkEvent(event: {
readonly _tag: "MessageCreated";
readonly kind: "channel" | "thread" | "direct";
readonly message: {
readonly attachments: readonly Array<{
readonly contentType?: string;
readonly id: string;
readonly name?: string;
readonly size?: number;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: "role" | "user" | "channel" | "broadcast";
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
};
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
} | {
readonly _tag: "ReactionAdded";
readonly emoji: string;
readonly messageAuthorId?: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp?: Utc;
readonly userId: string;
} | {
readonly _tag: "ReactionRemoved";
readonly emoji: string;
readonly messageAuthorId?: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp?: Utc;
readonly userId: string;
} | {
readonly _tag: "StopRequested";
readonly id: string;
readonly messageIds: readonly Array<string>;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
}, options: {
readonly parseMention: ParseMention;
readonly platform: string;
}): Effect<void, ConformanceFailure>
Since v4.1.5

Checks the invariants every interaction holds, for a click, a submit or a command from a fixture.

Details

  • thread.platform is the platform, and the thread survives its string codec.
  • The interaction encodes and decodes through its Schema unchanged, raw included.
  • A ModalSubmitted's messageId is non-empty when it is there. A modal a command opened has none.
  • A CommandInvoked has a non-empty id.

It takes no parseMention and checks no dedupe key, since an interaction carries neither.

Signature

declare function checkInteraction(interaction: {
readonly _tag: "CommandInvoked";
readonly id: string;
readonly raw: Json;
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
} | {
readonly _tag: "ButtonClicked";
readonly id: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly value?: string;
} | {
readonly _tag: "SelectChanged";
readonly id: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly value: string;
} | {
readonly _tag: "ModalSubmitted";
readonly id: string;
readonly messageId?: string;
readonly metadata?: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
readonly values: {
[key: string]: string;
};
}, options: {
readonly platform: string;
}): Effect<void, ConformanceFailure>
Since v4.1.5

Checks the invariants every message holds, for fixture tests and live runs.

Details

  • Every mention sits inside text, mentions do not overlap, and each slice parses with parseMention as a token of the mention's kind and id.
  • thread.platform is the platform, and the thread survives its string codec.
  • The message encodes and decodes through its Schema unchanged, raw included.
  • Every attachment has an id and no URL.
  • replyTo.isSelf is set exactly when replyTo.authorId is.

Signature

declare function checkMessage(message: {
readonly attachments: readonly Array<{
readonly contentType?: string;
readonly id: string;
readonly name?: string;
readonly size?: number;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: "role" | "user" | "channel" | "broadcast";
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
}, options: {
readonly parseMention: ParseMention;
readonly platform: string;
}): Effect<void, ConformanceFailure>

conformance

unstable
Since v4.1.5

Creates the conformance suite, as plain Effects keyed by rule name, so any test runner can run them.

Details

  • Each rule needs the adapter under test registered in Chat and a way to make another identity's message appear in thread, which must be a channel the suite may write to.
  • A rule is never skipped. When the descriptor lacks a capability a rule needs, the rule becomes its inverse: the op fails with Unsupported. There is an unsupported/{capability} rule for every capability. When the capability is listed, it calls the op and fails if the op fails with Unsupported, so a descriptor that lies in either direction fails.
  • A listed capability never fails with Unsupported, which every rule checks as it goes.
  • The three retries/* rules exist only when failNext is given. post/refusedFile exists only when refuseFiles is given.
  • The rules that need a click exist only when interactions is given, since neither platform has an API that clicks. A live run leaves it out and runs only the outbound rules. The suite provides its own recording ChatInteraction.Handler to the hook, so the rules still need only Chat and Registry.
  • modalErrors has no inverse rule: without it an errors reply is a degraded answer, not a refusal.
  • The command/* rules and unsupported/ephemeral exist only when interactions.command is given. unsupported/commands always runs: it calls followUp with a deferral the suite builds by hand, which must fail Unsupported without commands, and fail some other way with it.
  • Every rule deletes what it posted when it ends, pass or fail, when the platform can delete.

Gotchas

Rule names are stable, an existing rule is never tightened, and a new rule arrives only behind a new capability or with a changeset saying third-party adapters may start failing. unsupported/buttons and unsupported/selects are such rules: an adapter that ignores actions and posts anyway fails them. So is unsupported/commands: an adapter whose followUp does anything but fail Unsupported fails it. The retries/retrySafe rule waits for real time, so run the suite on a live Clock.

Signature

declare function conformance(options: {
readonly failNext?: (op: string, reason: ChatErrorReason, options?: {
readonly landed?: boolean;
readonly times?: number;
}) => Effect<void>;
readonly interactions?: Interactions;
readonly parseMention: ParseMention;
readonly platform: string;
readonly refuseFiles?: () => Effect<void>;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userPosts: (thread: {
readonly id: string;
readonly platform: string;
}, text: string) => Effect<{
readonly _tag: "MessageCreated";
readonly kind: "channel" | "thread" | "direct";
readonly message: {
readonly attachments: readonly Array<{
readonly contentType?: string;
readonly id: string;
readonly name?: string;
readonly size?: number;
}>;
readonly author: {
readonly id: string;
readonly isBot: boolean;
readonly isSelf: boolean;
readonly name?: string;
};
readonly id: string;
readonly mentions: readonly Array<{
readonly end: number;
readonly id: string;
readonly isSelf: boolean;
readonly kind: "role" | "user" | "channel" | "broadcast";
readonly start: number;
}>;
readonly raw: Json;
readonly replyTo?: {
readonly authorId?: string;
readonly isSelf?: boolean;
readonly messageId: string;
};
readonly text: string;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp: Utc;
};
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
} | {
readonly _tag: "ReactionAdded";
readonly emoji: string;
readonly messageAuthorId?: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp?: Utc;
readonly userId: string;
} | {
readonly _tag: "ReactionRemoved";
readonly emoji: string;
readonly messageAuthorId?: string;
readonly messageId: string;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly timestamp?: Utc;
readonly userId: string;
} | {
readonly _tag: "StopRequested";
readonly id: string;
readonly messageIds: readonly Array<string>;
readonly raw: Json;
readonly thread: {
readonly id: string;
readonly platform: string;
};
readonly userId: string;
}>;
}): Readonly<Record<string, Effect.Effect<void, ConformanceFailure, Chat.Chat | Registry>>>

Interactions

interface unstable
Since v4.1.5

The click hook of conformance: a way to click, for the adapter under test.

Details

  • click clicks the element id on a message the suite posted, through the adapter's real entry, and fails NoSuchElement when the message carries no such element. option is as in ChatTest.click.
  • submit submits the modal the last click or command opened, and submits it again after an errors reply. It does nothing when no modal is open: the rule then fails on the submit its handler never saw.
  • command sends a command typed at thread through the adapter's real entry. The command rules exist only when it is given. It is optional, so a hook written before commands still fits.
  • All three need ChatInteraction.Handler and nothing else. The suite provides its own recording handler, so the entry must take its handler at the call, not at layer build.

Signature

interface Interactions {
readonly click: (messageId: string, id: string, options?: {
readonly option?: string;
}) => Effect<void, NoSuchElement, Handler>;
readonly command?: (thread: {
readonly id: string;
readonly platform: string;
}, id: string, options?: {
readonly text?: string;
}) => Effect<void, never, Handler>;
readonly submit: (values: Readonly<Record<string, string>>) => Effect<void, never, Handler>;
}