-
Notifications
You must be signed in to change notification settings - Fork 13.8k
regression: unfollowed thread message marked as unread #40644
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
bdce66b
regression: unfollowed thread message marked as unread
MartinSchoeler 5076003
lint
MartinSchoeler f092460
Merge branch 'release-8.5.0' into reg-unread
MartinSchoeler fda4c5f
Merge branch 'release-8.5.0' into reg-unread
julio-rocketchat 71f4622
review: Implement jumpContext url param
MartinSchoeler acc4ce6
test: add thread jump test
MartinSchoeler 68815cc
chore: fix jump to thread message e2e test (#40690)
MartinSchoeler 8b1185b
Merge branch 'release-8.5.0' into reg-unread
MartinSchoeler a5f7cb5
fix: clear issue from conflict
MartinSchoeler 267b2da
fix review
MartinSchoeler dfc4054
add more test case
MartinSchoeler 7abc0d7
update existing test
MartinSchoeler 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
132 changes: 132 additions & 0 deletions
132
apps/meteor/client/views/room/MessageList/hooks/useTryToJumpToThreadMessage.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,132 @@ | ||
| import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
| import { renderHook, waitFor } from '@testing-library/react'; | ||
|
|
||
| import useTryToJumpToThreadMessage from './useTryToJumpToThreadMessage'; | ||
| import { RoomHistoryManager } from '../../../../../app/ui-utils/client'; | ||
|
|
||
| jest.mock('../../../../../app/ui-utils/client', () => ({ | ||
| RoomHistoryManager: { | ||
| getSurroundingMessages: jest.fn().mockResolvedValue(undefined), | ||
| isLoaded: jest.fn().mockReturnValue(false), | ||
| getMore: jest.fn().mockResolvedValue(undefined), | ||
| }, | ||
| })); | ||
|
|
||
| jest.mock('../../../../lib/RoomManager', () => ({ | ||
| RoomManager: { | ||
| opened: undefined as string | undefined, | ||
| }, | ||
| })); | ||
|
|
||
| jest.mock('../../../../lib/rooms/roomCoordinator', () => ({ | ||
| roomCoordinator: { | ||
| openRouteLink: jest.fn(), | ||
| }, | ||
| })); | ||
|
|
||
| jest.mock('../../../../providers/RouterProvider', () => ({ | ||
| router: { | ||
| getSearchParameters: jest.fn().mockReturnValue({}), | ||
| getRouteParameters: jest.fn().mockReturnValue({}), | ||
| }, | ||
| })); | ||
|
|
||
| jest.mock('../../../../stores', () => ({ | ||
| Subscriptions: { | ||
| state: { | ||
| find: jest.fn().mockReturnValue(undefined), | ||
| }, | ||
| }, | ||
| })); | ||
|
|
||
| const mockedRoomHistoryManager = jest.mocked(RoomHistoryManager); | ||
|
|
||
| afterEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| describe('useTryToJumpToThreadMessage', () => { | ||
| describe('early return when msg param is absent or jumpContext is jumpToUnread', () => { | ||
| it('should not navigate or load messages when msg search parameter is absent', () => { | ||
| const endpointSpy = jest.fn(); | ||
|
|
||
| renderHook(() => useTryToJumpToThreadMessage(), { | ||
| wrapper: mockAppRoot().withEndpoint('GET', '/v1/chat.getMessage', endpointSpy).build(), | ||
| }); | ||
|
|
||
| expect(endpointSpy).not.toHaveBeenCalled(); | ||
| expect(mockedRoomHistoryManager.getSurroundingMessages).not.toHaveBeenCalled(); | ||
| expect(mockedRoomHistoryManager.getMore).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should not navigate or load messages when jumpContext is jumpToUnread', async () => { | ||
| const threadMessage = { | ||
| _id: 'msg-1', | ||
| rid: 'room-1', | ||
| tmid: 'parent-msg-1', | ||
| ts: new Date('2024-01-01T00:00:00Z').toISOString(), | ||
| u: { _id: 'user-1', username: 'john' }, | ||
| msg: 'Thread reply', | ||
| _updatedAt: new Date('2024-01-01T00:00:00Z').toISOString(), | ||
| }; | ||
|
|
||
| const endpointSpy = jest.fn().mockResolvedValue({ message: threadMessage }); | ||
|
|
||
| renderHook(() => useTryToJumpToThreadMessage(), { | ||
| wrapper: mockAppRoot() | ||
| .withRouter({ getSearchParameters: () => ({ msg: 'msg-1', jumpContext: 'jumpToUnread' }) }) | ||
| .withEndpoint('GET', '/v1/chat.getMessage', endpointSpy) | ||
| .withMethod('getRoomById', () => ({ _id: 'room-1', t: 'c', name: 'general' }) as any) | ||
| .build(), | ||
| }); | ||
|
|
||
| await waitFor(() => { | ||
| expect(endpointSpy).toHaveBeenCalledWith({ msgId: 'msg-1' }); | ||
| }); | ||
|
|
||
| await waitFor(async () => { | ||
| await new Promise((resolve) => setTimeout(resolve, 300)); | ||
| expect(mockedRoomHistoryManager.getMore).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| expect(mockedRoomHistoryManager.getSurroundingMessages).not.toHaveBeenCalled(); | ||
| expect(mockedRoomHistoryManager.getMore).not.toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('when jumpContext is absent', () => { | ||
| it('should load more messages when jumpContext is null', async () => { | ||
| const threadMessage = { | ||
| _id: 'msg-1', | ||
| rid: 'room-1', | ||
| tmid: 'parent-msg-1', | ||
| ts: new Date('2024-01-01T00:00:00Z').toISOString(), | ||
| u: { _id: 'user-1', username: 'john' }, | ||
| msg: 'Thread reply', | ||
| _updatedAt: new Date('2024-01-01T00:00:00Z').toISOString(), | ||
| }; | ||
|
|
||
| mockedRoomHistoryManager.isLoaded.mockReturnValue(false); | ||
|
|
||
| const endpointSpy = jest.fn().mockResolvedValue({ message: threadMessage }); | ||
|
|
||
| renderHook(() => useTryToJumpToThreadMessage(), { | ||
| wrapper: mockAppRoot() | ||
| .withRouter({ getSearchParameters: () => ({ msg: 'msg-1' }) }) | ||
| .withEndpoint('GET', '/v1/chat.getMessage', endpointSpy) | ||
| .withMethod('getRoomById', () => ({ _id: 'room-1', t: 'c', name: 'general' }) as any) | ||
| .build(), | ||
| }); | ||
|
|
||
| await waitFor(() => { | ||
| expect(endpointSpy).toHaveBeenCalledWith({ msgId: 'msg-1' }); | ||
| }); | ||
|
|
||
| await waitFor(() => { | ||
| expect(mockedRoomHistoryManager.getMore).toHaveBeenCalledWith('room-1'); | ||
| }); | ||
|
|
||
| expect(mockedRoomHistoryManager.getSurroundingMessages).not.toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
| }); |
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.
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.