Skip to content

test(adapters): adopt shared @chat-adapter/tests factories and matchers#674

Open
bensabic wants to merge 11 commits into
tests/connect-contract-adoptfrom
tests/factories-matchers
Open

test(adapters): adopt shared @chat-adapter/tests factories and matchers#674
bensabic wants to merge 11 commits into
tests/connect-contract-adoptfrom
tests/factories-matchers

Conversation

@bensabic

@bensabic bensabic commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Wires @chat-adapter/tests as a devDependency and registers its matchers via setupFiles: ["@chat-adapter/tests/setup"] across all 11 platform adapters, then replaces bespoke local mockLogger/createMockState/createMockChatInstance with the shared factories and adopts toHaveDispatched/not.toHaveDispatched where clean.

  • 10 adapters migrated (gchat, messenger, teams, whatsapp, telegram, discord, twilio, linear, github, slack). Positional createMockChatInstance(...) call sites converted to the options API (slack 100, linear 35).
  • web left as-is — its suite uses the real Chat/createMemoryState for e2e, so the shared factories don't apply.
  • Platform SDK mocks (Octokit, WebClient, socket-mode, @linear/sdk, fetch) and the Phase 1 connectWebhookContract descriptors are left intact.

Net ~−540 lines of duplicated test scaffolding. Stacked on #673. Tests-only, no changeset.

bensabic added 11 commits July 3, 2026 12:04
Add `@chat-adapter/tests` as a devDependency and register its matchers via
`setupFiles: ["@chat-adapter/tests/setup"]` across all 11 platform
adapters, so adapter suites can adopt the shared factories and matchers.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Replace the local mockLogger/createMockState/createMockChatInstance and
inline logger literals with the shared factories, convert call sites to
the options-based createMockChatInstance, and adopt toHaveDispatched.
Keeps the bespoke createMockStateAdapter (uses .storage + constrained spy
behavior) and the Google SDK mocks local.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Replace the local mockLogger/createMockChat with the shared factories
(createMockChat kept as a thin wrapper preserving userName + logger
wiring) and adopt not.toHaveDispatched for the echo-message cases.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Replace the inline mock chat/state objects in index.test.ts with the
shared createMockChatInstance/createMockState (seeding the aadObjectId via
state.cache), dropping redundant casts. Platform SDK mocks stay local.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Replace the inline mockChat and no-op loggers with createMockChatInstance
/ createMockLogger, drop the now-unneeded casts, and adopt
not.toHaveDispatched. Keeps fetch/HMAC and getList history stubs local.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Replace the local mockLogger with the shared singleton and delegate
createMockChat to createMockChatInstance (thin wrapper preserving the
"mybot" default), and adopt not.toHaveDispatched for the clean cases.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Remove the local mockLogger literals and the gateway mockChat object,
replace ~20 inline `as unknown as ChatInstance` mocks with
createMockChatInstance() (overrides where needed), and adopt
not.toHaveDispatched for the clean case. discord.js mocks stay local.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Replace the inline mockChat() helper with createMockChatInstance() and
drop the now-unused ChatInstance import. Twilio fetch/credential mocks
stay local.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Remove the local createMockLogger/createMockState/createMockChatInstance,
import the shared ones, convert 35 positional createMockChatInstance call
sites to the options API, and adopt toHaveDispatched. LinearClient mocks
and the Phase 1 connectWebhookContract descriptor stay intact.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Replace the local mockLogger/createMockState and 17 inline mock-chat
literals with the shared factories, and adopt not.toHaveDispatched.
Octokit mocks and the Phase 1 connectWebhookContract descriptor stay
intact.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
Remove the local mockLogger/createMockState/createMockChatInstance,
import the shared ones, convert 100 positional createMockChatInstance
call sites to the options API, and adopt toHaveDispatched for the clean
cases. WebClient/socket-mode mocks and the Phase 1 connectWebhookContract
descriptor stay intact.

Signed-off-by: Ben Sabic <bensabic@users.noreply.github.com>
@bensabic bensabic requested a review from a team as a code owner July 3, 2026 03:32
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chat Ready Ready Preview, Comment, Open in v0 Jul 3, 2026 3:32am
chat-sdk-nextjs-chat Ready Ready Preview, Comment, Open in v0 Jul 3, 2026 3:32am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant