-
Notifications
You must be signed in to change notification settings - Fork 199
[chat] Add chat/test entrypoint for consumer test utilities #352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0c48c10
feat(chat): add chat/testing entrypoint for consumer test utilities
matchai 1a434bf
Rename chat/testing to chat/test
matchai ed129ae
Make id/channelId optional, use ThreadImplConfigWithAdapter for full …
matchai 812282d
Fix lint: formatting and import sort order
matchai e794d71
fix(chat): address review issues in chat/test entrypoint
matchai abd79ba
refactor(chat): extract BaseThreadOptions, derive CreateTestThreadOpt…
matchai c41ee19
fix(chat): avoid undefined overrides stomping createTestMessage defaults
matchai e62f1e7
refactor(chat): slim public surface of chat/test
matchai 68d1927
revert(chat): remove BaseThreadOptions refactor from thread.ts
matchai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import type { MessageData } from "./message"; | ||
| import { createTestMessage as _createTestMessage } from "./mock-adapter"; | ||
| import type { Author } from "./types"; | ||
|
|
||
| export { | ||
| createMockAdapter, | ||
| createMockState, | ||
| createTestThread, | ||
| type MockStateAdapter, | ||
| mockLogger, | ||
| } from "./mock-adapter"; | ||
|
|
||
| let messageCounter = 0; | ||
|
|
||
| /** Create a test message with sensible defaults. Only `text` is required. Extra properties are spread as MessageData overrides. */ | ||
| export function createTestMessage( | ||
| opts: { | ||
| text: string; | ||
| id?: string; | ||
| author?: Partial<Author>; | ||
| raw?: unknown; | ||
| edited?: boolean; | ||
| } & Omit< | ||
| Partial<MessageData>, | ||
| "text" | "id" | "author" | "raw" | "formatted" | ||
| > | ||
| ) { | ||
| const { text, id, author, raw, edited, ...rest } = opts; | ||
| return _createTestMessage(id ?? `msg-${++messageCounter}`, text, { | ||
| raw: raw ?? {}, | ||
| metadata: edited != null ? { dateSent: new Date(), edited } : undefined, | ||
| author: author | ||
| ? { | ||
| userId: author.userId ?? "U000", | ||
| userName: author.userName ?? "testuser", | ||
| fullName: author.fullName ?? "Test User", | ||
| isBot: author.isBot ?? false, | ||
| isMe: author.isMe ?? false, | ||
| } | ||
| : undefined, | ||
| ...rest, | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| import { defineConfig } from "tsup"; | ||
|
|
||
| export default defineConfig({ | ||
| entry: ["src/index.ts", "src/jsx-runtime.ts"], | ||
| entry: ["src/index.ts", "src/jsx-runtime.ts", "src/test.ts"], | ||
| format: ["esm"], | ||
| dts: true, | ||
| clean: true, | ||
| sourcemap: false, | ||
| external: ["vitest"], | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.