mirror of
https://github.com/vercel/chat.git
synced 2026-09-14 18:32:29 +08:00
4717a38407
Adds support for Slack's [data table](https://docs.slack.dev/reference/block-kit/blocks/data-table-block) and [data visualization](https://docs.slack.dev/reference/block-kit/blocks/data-visualization-block) Block Kit blocks. - **`chat`**: new cross-platform `ChartElement` + `Chart()` builder (JSX supported) mirroring Slack's model — pie `segments`, or bar/area/line `series` against shared `categories`. `Table()` gains optional `caption` and `pageSize`. Charts degrade to a text table on other platforms via the shared card fallback (`chartElementToFallbackText`). - **`@chat-adapter/slack`**: card tables now render as paginated, sortable `data_table` blocks by default (header-only tables keep the plain `table` block; oversized tables still fall back to ASCII). Charts render as `data_visualization` blocks; charts violating Slack constraints — including the undocumented **max 2 charts per message** — fall back to a text rendering instead of an API rejection. Same treatment in the `@chat-adapter/slack/blocks` subpath. - **`postMessage`** now surfaces Slack's per-block validation messages on `invalid_blocks` errors (this is how the 2-chart limit was found). - Example app gets a **Show Charts** button and table pagination on **Show Table**; docs, feature matrices, and changeset updated. Verified live against Slack: data table pagination/sorting and both chart types render natively. <table> <tr> <th>Data Table</th> <th>Data Charts</th> </tr> <tr> <td><img width="979" height="896" alt="CleanShot 2026-07-12 at 23 28 32" src="https://github.com/user-attachments/assets/3307bd90-9322-452f-86fb-07d46446822d" /></td> <td><img width="955" height="879" alt="CleanShot 2026-07-12 at 23 29 02" src="https://github.com/user-attachments/assets/ddb31a1b-e3fd-457c-a2e6-bde4934afebe" /></td> </tr> </table> --------- Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
Integration Tests
Integration tests for the Chat SDK that verify real-world webhook payloads are handled correctly.
Test Categories
- Unit tests (
slack.test.ts,teams.test.ts,gchat.test.ts) - Test adapter functionality with mock payloads - Replay tests (
replay*.test.ts) - Replay actual production webhook recordings - Emulator tests (
src/emulator/<adapter>/*.test.ts) - Drive the SDK against an in-process Emulate.dev server, one per supported adapter (@emulators/slack,@emulators/github). Assertions read the emulator's stateful store (messages, comments, reactions, installations) instead of mock call records. Each adapter is wired in via itsapiUrlconfig. Inbound deliveries: the Slack flow re-signsevent_callbackpayloads withx-slack-signaturevia a small in-test forwarder before handing them tochat.webhooks.slack(...), while the GitHub flow is a near-passthrough because the emulator'sWebhookDispatcheralready signs withX-Hub-Signature-256exactly as the adapter expects. Helpers live insrc/emulator/slack/utils.tsandsrc/emulator/github/utils.ts.
Replay Tests
Replay tests use recorded webhook payloads from production to verify the SDK handles real interactions correctly.
See fixtures/replay/README.md for:
- How to record new fixtures
- Fixture format documentation
- SHA-based recording workflow
- Platform-specific webhook formats
Running Tests
# Run all integration tests
pnpm --filter @chat-adapter/integration-tests test
# Run with watch mode
pnpm --filter @chat-adapter/integration-tests test:watch