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.
Comparisons
sameMessage
unstableReturns 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;}): booleanErrors
ConformanceFailure
unstableError 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;}NoSuchElement
unstableError 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
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
testand the bot's user id tobot. - Every capability is on by default.
measuredefaults 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
nativeStreamon, a stream takes up tomessageLengthand lasts 10 minutes. - The native stream behaves the way Slack's was found to. An append past
limits.streamLengthfails withTooLargeand adds nothing. A stream pastlimits.streamAge, onClock, is closed. An append withoutflushholds 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 refuseseditanddelete. - With
buttonsorselectson, a message takes 25 elements, and an element's id plus encoded value 100 code points. Withmodalson, a modal's id plus encoded metadata takes 100 code points, and a modal 5 fields. Each limit is there only with its capability. interactgives a handler 3 seconds by default, onClock.- With
commandson,limits.followUpAgeis 15 minutes. - Two layers merged with different platforms share one
Chat, so routing can be tested. TheChatTestservice 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
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; };}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
Service that controls the fake adapter built by layer.
Details
makeThreadcreates a fresh address: a channel by default, a direct conversation, or a thread under a user's message in a fresh channel.userPostsputs another identity's message in a thread and returns its event without delivering it.deliverdelivers an event the way an adapter does, by calling theChatHandlerservice.messagesis what a thread shows now, oldest first, andcallsis every call the adapter received.failNextmakes the nexttimescalls ofopfail withreason.landedmakes the write happen anyway, which is whatuncertainmeans. The native stream's ops arenativeStream.start,nativeStream.appendandnativeStream.stop.refuseFilesmakes the nexttimesposts with files faildeniedwith detailfile_refused, storing nothing. Text-only posts do not consume it.clickStopis a user clicking stop on a native stream. It closes nothing, as on Slack: the stream keeps taking text, andNativeStream.stopthen reportsstopped: true.closeStreamcloses a native stream from outside, so the next append givesclosed, orstoppedafter a click.clickbuilds the click on elementidof a message from what the fake stored atpostoredit, without delivering it. For a select,optionis the encoded value of the option to choose, the first by default. It failsNoSuchElementwhen the message has no such element, or no such option, or is gone.commandbuilds a command typed atthread, without delivering it.textdefaults to the empty string. The fake has no registration, so any id can be typed.submitbuilds the submit of a modal. It takes the click or the command that opened it, because anOpenModalreply does not say where it was opened from and aModalSubmittedhas to. A command gives a submit with nomessageId.valuesare by field id, still encoded, and an empty one is left out, as for an optional field left empty.interactdelivers an interaction the way an adapter does: throughChatInteraction.handlewith the layer'sinteractionDeadline, then the fake's own checks on anOpenModal(themodalscapability,limits.modalMetadataLengthagainst the modal's id plus its encoded metadata, andlimits.modalFields), callingHandler.refusedwhen one fails. It succeeds with the handler's reply as it returned it, orLate. AnOpenModalshows incallsas opopenModal.- For a command,
interactruns the checks ofposton aRespond(the element capabilities,limits.messageLengthand the element limits), and refuses a privateRespondorDeferwithoutephemeral. ARespondshows incallsas oprespond, and afollowUpas opfollowUp, each with the command's thread and the Markdown. Neither is stored as a message. - The fake's
followUpsucceeds once for aDeferthatinteractreturned, insidelimits.followUpAgeonClock. Later, a second time, or for a deferral the fake never saw, it failsNotFoundwith detailinteraction_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
unstableChecks 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.platformis the platform, and the thread survives its string codec.- The event encodes and decodes through its Schema unchanged,
rawincluded, and two decodes have the samededupeKey. - A reaction's
dedupeKeydiffers 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>checkInteraction
unstableChecks the invariants every interaction holds, for a click, a submit or a command from a fixture.
Details
thread.platformis the platform, and the thread survives its string codec.- The interaction encodes and decodes through its Schema unchanged,
rawincluded. - A
ModalSubmitted'smessageIdis non-empty when it is there. A modal a command opened has none. - A
CommandInvokedhas a non-emptyid.
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>checkMessage
unstableChecks 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 withparseMentionas a token of the mention's kind and id. thread.platformis the platform, and the thread survives its string codec.- The message encodes and decodes through its Schema unchanged,
rawincluded. - Every attachment has an id and no URL.
replyTo.isSelfis set exactly whenreplyTo.authorIdis.
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
unstableCreates 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
Chatand a way to make another identity's message appear inthread, 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 anunsupported/{capability}rule for every capability. When the capability is listed, it calls the op and fails if the op fails withUnsupported, 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 whenfailNextis given.post/refusedFileexists only whenrefuseFilesis given. - The rules that need a click exist only when
interactionsis 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 recordingChatInteraction.Handlerto the hook, so the rules still need onlyChatandRegistry. modalErrorshas no inverse rule: without it anerrorsreply is a degraded answer, not a refusal.- The
command/*rules andunsupported/ephemeralexist only wheninteractions.commandis given.unsupported/commandsalways runs: it callsfollowUpwith a deferral the suite builds by hand, which must failUnsupportedwithoutcommands, 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>>>The click hook of conformance: a way to click, for the adapter under
test.
Details
clickclicks the elementidon a message the suite posted, through the adapter's real entry, and failsNoSuchElementwhen the message carries no such element.optionis as inChatTest.click.submitsubmits the modal the last click or command opened, and submits it again after anerrorsreply. It does nothing when no modal is open: the rule then fails on the submit its handler never saw.commandsends a command typed atthreadthrough 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.Handlerand 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>;}