Skip to content

Testing

Arona ships fakes for both platforms. A test mounts a real component, dispatches a fake interaction, and asserts the edited payload. No token and no network are needed.

@arona/platform-discord/testing provides FakeChannel, payload finders, and interaction fakes:

import { mountMessage } from "@arona/platform-discord";
import {
FakeChannel,
fakeButtonInteraction,
findButtonCustomId,
} from "@arona/platform-discord/testing";
const channel = new FakeChannel();
const { root } = await Effect.runPromise(mountMessage(channel.asRef(), Counter, {}));
const customId = findButtonCustomId(channel.sent[0]);
await Effect.runPromise(root.interactionListener(fakeButtonInteraction(customId)));
expect(channel.edits).toHaveLength(1);

The channel records every payload. The root routes the fake interaction through the same listener the gateway uses.

@arona/platform-slack/testing provides FakeSlackClient, messageRef, blocksOf, and fakeAction:

import { SlackWebClient, mountMessage } from "@arona/platform-slack";
import { FakeSlackClient, fakeAction, messageRef } from "@arona/platform-slack/testing";
const client = new FakeSlackClient();
const { root } = await Effect.runPromise(
mountMessage(messageRef(), App, {}).pipe(Effect.provideService(SlackWebClient, client)),
);
const action = blocksOf(client.sent[0]).find((block) => block.type === "actions");
const [increment] = action?.elements ?? [];
await Effect.runPromise(root.interactionListener(fakeAction(increment.action_id).payload));

blocksOf narrows a rendered message to its blocks. fakeAction returns the payload and records acknowledgements, so a test can assert that the action was acknowledged.

The session stores, interaction ids, lease protocol, message targets, and serializer parity have property tests. Each derived state table is checked against its XState declaration. A bounded TLA+ model checks the session protocol.

Terminal window
vpr test # workspace tests, including property tests
./specs/check.sh # TLA+ model check, needs a JRE

See docs/notes/INVARIANTS.md for the catalogue.