test: the SPA's chat tests on the port, client, store and link embeds
- vitest runs app/**/*.test.ts and tests/**/*.test.ts; the SPA's chatEvents, chatFormat, chatText, chatUnread and realtime tests sit next to their ports with only import paths changed - linkEmbeds: escaping, http(s) only, rel and target, registry order - client: every endpoint, refresh-and-retry, unauthorized, 422, upload - store: bootstrap, anonymous and non-member starts, lazy joins, DMs, live messages and unread, threads, pins, reactions, slash commands, polling without realtime, onUserEvent, DM-only actions
This commit is contained in:
@@ -197,7 +197,7 @@ Typing `/` at the start of the composer opens the commands of `GET {botsApiBase}
|
||||
| `ChatReactionBar`, `ChatStagingChips`, `ChatDeleteDialog`, `ChatMemberPicker`, `ChatMentionPopup`, `ChatCommandPicker`, `ChatLinkEmbed` | Parts of the above |
|
||||
| `ChatAvatar`, `ChatIcon`, `ChatNotices` | Initials avatar, stroke icons, short notices |
|
||||
|
||||
Composables: `useChat()` (the store, one per app, state in `useState` keys prefixed `chat:`), `useChatApi()` (the HTTP client bound to runtime config and the hook), `useChatNotice()`. The pure modules in `app/lib/` are imported explicitly, never auto-imported: `client.ts` (`createChatClient`, `ChatApiError`, `userIdFromToken`), `realtime.ts`, `linkEmbeds.ts`, `chatEvents.ts`, `chatFormat.ts`, `chatText.ts`, `chatUnread.ts`, `format.ts`, `attachments.ts`.
|
||||
Composables: `useChat()` (the store, one per app, state in `useState` keys prefixed `chat:`), `useChatApi()` (the HTTP client bound to runtime config and the hook), `useChatNotice()`. The pure modules in `app/lib/` are imported explicitly, never auto-imported: `client.ts` (`createChatClient`, `ChatApiError`, `userIdFromToken`), `realtime.ts`, `linkEmbeds.ts`, `chatEvents.ts`, `chatFormat.ts`, `chatText.ts`, `chatUnread.ts`, `format.ts`, `attachments.ts`, `slots.ts` (`dmActionsTarget`, the DM-only rule of the conversation-actions slot).
|
||||
|
||||
## Tokens
|
||||
|
||||
@@ -225,7 +225,12 @@ pnpm build:playground
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
pnpm test # vitest: the HTTP client (tests/smoke.test.ts)
|
||||
pnpm test # vitest in Node: app/**/*.test.ts and tests/**/*.test.ts
|
||||
```
|
||||
|
||||
- `app/lib/chatEvents.test.ts`, `chatFormat.test.ts`, `chatText.test.ts`, `chatUnread.test.ts` and `realtime.test.ts` are the Golem15 SPA's tests of the modules ported here, with only their import paths changed (`vitest.config.ts` maps the SPA's `@/api/http` to `tests/support/http.ts`).
|
||||
- `app/lib/linkEmbeds.test.ts`: `linkify` (escaped input, http(s) only, `target` and `rel`), `messageUrls` and the renderer registry.
|
||||
- `tests/client.test.ts`: every endpoint's URL, method and body, the 401 refresh-and-retry, `unauthorized`, the 422 mapping and the multipart upload.
|
||||
- `tests/store.test.ts`: `useChat` with stubbed Nuxt composables, a fake client and a fake realtime client: the bootstrap (and the anonymous, non-member and no-host cases), lazy channel joins, DMs, live messages and unread counts, threads, pins, reactions, slash commands, polling without realtime, `onUserEvent` and the DM-only `conversation-actions` rule.
|
||||
|
||||
The consuming application covers the components with browser checks.
|
||||
|
||||
Reference in New Issue
Block a user