-
Notifications
You must be signed in to change notification settings - Fork 13.9k
fix: Deleted thread not being displayed correctly in thread context #41484
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
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4b82d5d
fix: deleted thread not being displayed correctly
dougfabris 52beb17
test: add unit tests
dougfabris d4c3eb4
fix: DiscussionListRow missing translation fn
dougfabris 35737e2
chore: use MessageTypes
dougfabris 4ca7fcb
chore: capitalize
dougfabris 78307c7
test: update test
dougfabris 7717148
chore: changeset
dougfabris b197de8
fix: use options object
dougfabris 7c5cdd0
chore: changeset
dougfabris 88f4c26
chore: escapeHTML messageType.text
dougfabris 65bd1bf
i18n: sanitize translation
dougfabris eaeab92
test: update translation key in assertion
dougfabris 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@rocket.chat/message-types': patch | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Fixes an issue where deleted thread messages display as empty in thread context |
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
72 changes: 72 additions & 0 deletions
72
...meteor/client/views/room/contextualBar/Threads/hooks/useNormalizedThreadTitleHtml.spec.ts
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,72 @@ | ||
| import type { IThreadMainMessage } from '@rocket.chat/core-typings'; | ||
| import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
| import { renderHook } from '@testing-library/react'; | ||
|
|
||
| import { useNormalizedThreadTitleHtml } from './useNormalizedThreadTitleHtml'; | ||
| import { filterMarkdown } from '../../../../../../app/markdown/lib/markdown'; | ||
|
|
||
| jest.mock('../../../../../../app/markdown/lib/markdown', () => ({ | ||
| filterMarkdown: jest.fn((text: string) => text), | ||
| })); | ||
|
|
||
| jest.mock('../../../../../../app/emoji/client/emojiParser', () => ({ | ||
| emojiParser: jest.fn((text: string) => text), | ||
| })); | ||
|
|
||
| const mockedFilterMarkdown = jest.mocked(filterMarkdown); | ||
|
|
||
| const baseMessage = { | ||
| _id: 'msg-id', | ||
| rid: 'rid', | ||
| ts: new Date(), | ||
| u: { _id: 'uid', username: 'user' }, | ||
| _updatedAt: new Date(), | ||
| tcount: 1, | ||
| tlm: new Date(), | ||
| replies: [], | ||
| } as unknown as IThreadMainMessage; | ||
|
|
||
| describe('useNormalizedThreadTitleHtml', () => { | ||
| afterEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('should return the "Message_removed" translation for a removed message without content', () => { | ||
| const message = { | ||
| ...baseMessage, | ||
| t: 'rm', | ||
| msg: '', | ||
| editedAt: new Date(), | ||
| editedBy: { _id: 'uid', username: 'user' }, | ||
| } as unknown as IThreadMainMessage; | ||
|
|
||
| const { result } = renderHook(() => useNormalizedThreadTitleHtml(message), { | ||
| wrapper: mockAppRoot().build(), | ||
| }); | ||
|
|
||
| expect(result.current).toBe('Message_removed'); | ||
|
dougfabris marked this conversation as resolved.
|
||
| expect(mockedFilterMarkdown).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should return the normalized message content for a regular message', () => { | ||
| const message = { ...baseMessage, msg: 'Hello world' } as unknown as IThreadMainMessage; | ||
|
|
||
| const { result } = renderHook(() => useNormalizedThreadTitleHtml(message), { | ||
| wrapper: mockAppRoot().build(), | ||
| }); | ||
|
|
||
| expect(result.current).toBe('Hello world'); | ||
| expect(mockedFilterMarkdown).toHaveBeenCalledWith('Hello world'); | ||
| }); | ||
|
|
||
| it('should render the message content when a `t: rm` message still has content', () => { | ||
| const message = { ...baseMessage, t: 'rm', msg: 'Hello world' } as unknown as IThreadMainMessage; | ||
|
|
||
| const { result } = renderHook(() => useNormalizedThreadTitleHtml(message), { | ||
| wrapper: mockAppRoot().build(), | ||
| }); | ||
|
|
||
| expect(result.current).not.toBe('Message_removed'); | ||
| expect(result.current).toBe('Hello world'); | ||
| }); | ||
| }); | ||
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
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
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
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.