testing library

Test doubles for hosts integrating Kata CX.

Import this instead of stubbing HTTP by hand:

final middleware = FakeMiddleware()..settingsBody = '{"botName":"Acme"}';
await KataCx.setupWithCustomServer(
  token: 'acme.proj.nst',
  widgetToken: 'cw_test',
  baseUrl: 'https://example.test',
  transport: middleware,
  storeBackend: InMemoryStoreBackend(),
);

Kept out of the main library so nothing here ships in a release build unless a consumer asks for it.

Do not await KataCx.reset() from tearDown after a testWidgets body. The store's write queue belongs to the test's FakeAsync zone, and once the body returns nothing pumps that clock again, so the await never resolves. Reset inside the test body, or use tearDown(() => unawaited(KataCx.reset())) — the static state is cleared synchronously either way.

Classes

FakeMiddleware
A stand-in for genai-middleware, routing on the request path.
InMemoryStoreBackend
In-memory backend, for tests and for a host that opts out of persistence.
KataCxRequest
One outgoing HTTP request, in the small subset of HTTP this SDK needs.
KataCxResponse
A complete (non-streamed) HTTP response.
KataCxStoreBackend
Key-value persistence behind KataCxStore.
KataCxTransport
Platform HTTP, with the one capability the CX widget actually needs from it: a response body that can be read progressively.

Exceptions / Errors

KataCxHttpException
Raised when a request cannot be completed, or completes non-2xx on a call where the status is the transport's to police.