-
Notifications
You must be signed in to change notification settings - Fork 77
[LG-5935] feat(message-feed) InitialMessage Subcomponent #3490
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
Merged
shaneeza
merged 48 commits into
s/initial-message-integration
from
LG-5935-initial-message
Feb 3, 2026
+630
−36
Merged
Changes from 47 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
45120ed
refactor(MessageFeed): convert to CompoundComponent and temp remove a…
shaneeza 1277ed5
Merge branch 's/initial-message-integration' of github.com:mongodb/le…
shaneeza defdad3
refactor(MessageFeed): enhance component structure
shaneeza 958d58a
feat(MessageFeed): add MessageFeedContext
shaneeza c701f84
docs(MessageFeed): add changeset
shaneeza a6d7616
fix(MessageFeed): update error message for context provider
shaneeza e427185
refactor(Message): undo message changes
shaneeza 0d9295d
chore(MessageFeed): add compound-component dependency
shaneeza eb31dd4
chore(pnpm-lock): add compound-component to dependencies
shaneeza fbb16db
chore(MessageFeed): update dependencies for compound-component integr…
shaneeza 478ee3c
refactor(MessageFeed): move shared types
shaneeza 43fc610
Merge branch 'LG-5932-message-feed-compound' of github.com:mongodb/le…
shaneeza 8b67331
refactor(InitialMessage): update import path for shared types and use…
shaneeza 8926ff5
feat(InitialMessage): integrate MessageFeedContext to manage initial …
shaneeza bd83d5f
chore(changeset): update dependency version for @lg-chat/message-feed
shaneeza 6441471
fix(tsconfig): add missing newline at end of file
shaneeza 9e0a42e
fix(MessageFeedContext): handle error boundary for React 17 in contex…
shaneeza bebc9bf
Merge branch 'LG-5932-message-feed-compound' of github.com:mongodb/le…
shaneeza 7dcc812
feat(InitialMessage): implement styles and update component structure…
shaneeza 3516dd6
feat(InitialMessage): enhance initial message component with structur…
shaneeza 87414ee
refactor(InitialMessage): replace hardcoded title and description wit…
shaneeza 7caaef2
feat(ChatWindow): add initial message prompts and enhance message han…
shaneeza e41b22b
refactor(ChatWindow): remove enableHideOnSelect prop from Suggested P…
shaneeza 5f6e619
test(InitialMessage): add unit tests for accessibility, rendering, an…
shaneeza 1d87c3b
merge conflict
shaneeza 1ef0ae9
test(MessageFeed): enhance tests with scrollTo mock and update query …
shaneeza d4adca5
refactor(InitialMessage): simplify getWrapperStyles function and remo…
shaneeza 52846e0
chore(MessageFeed): update dependencies and tsconfig to include new L…
shaneeza eb70b3f
refactor(ChatWindow): rename initial message component and update pro…
shaneeza a33deba
chore(MessageFeed): remove unused @leafygreen-ui/hooks dependency fro…
shaneeza d7f10d4
refactor(MessageFeed): remove commented-out MyMessage component from …
shaneeza 298ffc1
chore(MessageFeed): update changeset
shaneeza 770c81f
refactor(InitialMessage): update styles for title and description com…
shaneeza 5e005d2
refactor(InitialMessage): adjust inner wrapper styles with focus ring…
shaneeza bce10f3
refactor(InitialMessage): restructure inner wrapper and remove descri…
shaneeza c075973
refactor(InitialMessage): integrate LeafyGreenProvider for dark mode …
shaneeza 9a145bc
refactor(InitialMessage): remove LeafyGreenProvider and streamline co…
shaneeza 499fc40
feat(InitialMessage): add generated story for initialMessage
shaneeza 338cbec
refactor(InitialMessage): update AssistantAvatar size and adjust prop…
shaneeza 9db8c4d
fix(InitialMessage): export InitialMessageProps type for better type …
shaneeza 748ef93
refactor(InitialMessage): Components to components
shaneeza da60688
refactor(InitialMessage): update import paths from Components to comp…
shaneeza 730e077
feat(InitialMessage): add interactive story for message addition with…
shaneeza 308b6b5
fix(InitialMessage): add visibility property to transition styles for…
shaneeza 9572937
feat(MessageFeed): enhance InitialMessage stories with new message ha…
shaneeza 72f8c20
refactor(MessageFeed): simplify initial message handling by removing …
shaneeza abf16ff
refactor(MessageFeed): export InitialMessageProps type for better acc…
shaneeza e4afa54
chore(MessageFeed): disable Chromatic snapshots for InitialMessage st…
shaneeza 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
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,121 @@ | ||
| import React from 'react'; | ||
| import { render, screen } from '@testing-library/react'; | ||
|
|
||
| import { | ||
| INITIAL_MESSAGE_DESCRIPTION, | ||
| INITIAL_MESSAGE_TITLE, | ||
| } from '../components/InitialMessage/constants'; | ||
|
|
||
| import { MessageFeed } from './MessageFeed'; | ||
|
|
||
| jest.mock('@lg-chat/lg-markdown', () => ({ | ||
| LGMarkdown: jest.fn(({ children }) => <div>{children}</div>), | ||
| })); | ||
|
|
||
| describe('MessageFeed', () => { | ||
| const originalScrollTo = Element.prototype.scrollTo; | ||
|
|
||
| beforeAll(() => { | ||
| // Mock scrollTo since it's not implemented in JSDOM | ||
| Element.prototype.scrollTo = jest.fn(function mock( | ||
| this: Element, | ||
| x?: number | ScrollToOptions, | ||
| y?: number, | ||
| ) { | ||
| if (typeof x === 'object' && x !== null) { | ||
| // Handle ScrollToOptions | ||
| if ('top' in x) { | ||
| (this as HTMLElement).scrollTop = x.top ?? 0; | ||
| } | ||
|
|
||
| if ('left' in x) { | ||
| (this as HTMLElement).scrollLeft = x.left ?? 0; | ||
| } | ||
| } else if (typeof x === 'number' && typeof y === 'number') { | ||
| // Handle two number arguments | ||
| (this as HTMLElement).scrollLeft = x; | ||
| (this as HTMLElement).scrollTop = y; | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| afterAll(() => { | ||
| // Restore original scrollTo if it existed, otherwise delete the mock | ||
| if (originalScrollTo) { | ||
| Element.prototype.scrollTo = originalScrollTo; | ||
| } else { | ||
| delete (Element.prototype as Partial<Element>).scrollTo; | ||
| } | ||
| }); | ||
|
|
||
| test('renders children', () => { | ||
| render( | ||
| <MessageFeed> | ||
| <div>Hello, how can I help you today?</div> | ||
| <div>Hello, fellow message</div> | ||
| </MessageFeed>, | ||
| ); | ||
| expect( | ||
| screen.getByText('Hello, how can I help you today?'), | ||
| ).toBeInTheDocument(); | ||
| expect(screen.getByText('Hello, fellow message')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders the initial message if the initial message is a child and there are no other children', () => { | ||
| render( | ||
| <MessageFeed> | ||
| <MessageFeed.InitialMessage> | ||
| <div>I heard you like MongoDB</div> | ||
| </MessageFeed.InitialMessage> | ||
| </MessageFeed>, | ||
| ); | ||
| expect(screen.getByText(INITIAL_MESSAGE_TITLE)).toBeInTheDocument(); | ||
| expect(screen.getByText(INITIAL_MESSAGE_DESCRIPTION)).toBeInTheDocument(); | ||
| expect(screen.getByText('I heard you like MongoDB')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('hides the initial message if the initial message is a child and there are other children', () => { | ||
| render( | ||
| <MessageFeed> | ||
| <MessageFeed.InitialMessage> | ||
| <div>I heard you like MongoDB</div> | ||
| </MessageFeed.InitialMessage> | ||
| <div>Hello, fellow message</div> | ||
| </MessageFeed>, | ||
| ); | ||
| expect(screen.queryByText(INITIAL_MESSAGE_TITLE)).not.toBeVisible(); | ||
| expect(screen.queryByText(INITIAL_MESSAGE_DESCRIPTION)).not.toBeVisible(); | ||
| expect(screen.queryByText('I heard you like MongoDB')).not.toBeVisible(); | ||
| expect(screen.getByText('Hello, fellow message')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('hides the initial message when a new message is added', () => { | ||
| const { rerender } = render( | ||
| <MessageFeed> | ||
| <MessageFeed.InitialMessage> | ||
| <div>I heard you like MongoDB</div> | ||
| </MessageFeed.InitialMessage> | ||
| </MessageFeed>, | ||
| ); | ||
|
|
||
| expect(screen.getByText(INITIAL_MESSAGE_TITLE)).toBeInTheDocument(); | ||
| expect(screen.getByText(INITIAL_MESSAGE_DESCRIPTION)).toBeInTheDocument(); | ||
| expect(screen.getByText('I heard you like MongoDB')).toBeInTheDocument(); | ||
|
|
||
| rerender( | ||
| <MessageFeed> | ||
| <MessageFeed.InitialMessage> | ||
| <div>I heard you like MongoDB</div> | ||
| </MessageFeed.InitialMessage> | ||
| <div>Hello, how can I help you today?</div> | ||
| </MessageFeed>, | ||
| ); | ||
|
|
||
| expect(screen.getByText(INITIAL_MESSAGE_TITLE)).not.toBeVisible(); | ||
| expect(screen.getByText(INITIAL_MESSAGE_DESCRIPTION)).not.toBeVisible(); | ||
| expect(screen.getByText('I heard you like MongoDB')).not.toBeVisible(); | ||
| expect( | ||
| screen.getByText('Hello, how can I help you today?'), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.