-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: quote has no effect on older thread messages #7535
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
Open
OtavioStasiak
wants to merge
6
commits into
develop
Choose a base branch
from
fix.quote-not-working-on-old-messages
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0a42eb7
fix: Quote has no effect on older thread messages
OtavioStasiak a0994bb
fix: Quote has no effect on older thread messages
OtavioStasiak d911ce1
chore: e2e test
OtavioStasiak 9a90617
Merge branch 'develop' into fix.quote-not-working-on-old-messages
OtavioStasiak 3c640bc
Merge branch 'develop' into fix.quote-not-working-on-old-messages
OtavioStasiak a0b0043
fix: e2e test
OtavioStasiak 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,113 @@ | ||
| appId: ${APP_ID} | ||
| name: Quote a message inside a thread | ||
| onFlowStart: | ||
| - runFlow: '../../helpers/setup.yaml' | ||
| onFlowComplete: | ||
| - evalScript: ${output.utils.deleteCreatedUsers()} | ||
| tags: | ||
| - test-13 | ||
|
|
||
| --- | ||
| - evalScript: ${output.user = output.utils.createUser()} | ||
| - evalScript: ${output.room = output.utils.createRandomRoom(output.user.username, output.user.password)} | ||
|
|
||
| - runFlow: | ||
| file: '../../helpers/login-with-deeplink.yaml' | ||
| env: | ||
| USERNAME: ${output.user.username} | ||
| PASSWORD: ${output.user.password} | ||
| - runFlow: | ||
| file: '../../helpers/navigate-to-room.yaml' | ||
| env: | ||
| ROOM: ${output.room.name} | ||
|
|
||
| # should create a thread with a reply | ||
| - runFlow: | ||
| file: '../../helpers/send-message.yaml' | ||
| env: | ||
| message: thread | ||
| - tapOn: | ||
| id: 'room-view-messages' | ||
| - longPressOn: | ||
| id: 'message-content-thread' | ||
| - extendedWaitUntil: | ||
| visible: | ||
| text: 'Reply in thread' | ||
| timeout: 60000 | ||
| - tapOn: | ||
| text: 'Reply in thread' | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: 'message-composer-input-thread' | ||
| timeout: 60000 | ||
| - tapOn: | ||
| id: 'message-composer-input-thread' | ||
| - inputText: quotable | ||
| - tapOn: | ||
| id: 'message-composer-send' | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: 'message-content-quotable' | ||
| timeout: 60000 | ||
|
|
||
| # Reload with a clean local DB so the reply only exists in `thread_messages`, not `messages`. | ||
| # Quoting used a messages-only lookup, so it couldn't resolve the reply and silently did nothing. | ||
| - runFlow: | ||
| file: '../../helpers/login-with-deeplink.yaml' | ||
| env: | ||
| USERNAME: ${output.user.username} | ||
| PASSWORD: ${output.user.password} | ||
| CLEAR_STATE: true | ||
| - runFlow: | ||
| file: '../../helpers/navigate-to-room.yaml' | ||
| env: | ||
| ROOM: ${output.room.name} | ||
|
|
||
| # should open the thread | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: 'message-thread-button-thread' | ||
| timeout: 60000 | ||
| - tapOn: | ||
| id: 'message-thread-button-thread' | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: 'message-content-quotable' | ||
| timeout: 60000 | ||
|
|
||
| # should quote the thread reply | ||
| - longPressOn: | ||
| id: 'message-content-quotable' | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: 'action-sheet' | ||
| timeout: 60000 | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: 'message-actions-quote' | ||
| timeout: 60000 | ||
| - tapOn: | ||
| id: 'message-actions-quote' | ||
|
|
||
| # should show the quote preview in the composer | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: 'composer-quote-.*' | ||
| timeout: 60000 | ||
| - assertVisible: | ||
| id: 'composer-quote-remove-.*' | ||
|
|
||
| # should send the message with the quote attached | ||
| - tapOn: | ||
| id: 'message-composer-input-thread' | ||
| - inputText: quotedinthread | ||
| - tapOn: | ||
| id: 'message-composer-send' | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: 'message-content-.*quotedinthread' | ||
| timeout: 60000 | ||
| - extendedWaitUntil: | ||
| visible: | ||
| id: 'reply-.*-quotable' | ||
| timeout: 60000 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import database from '../index'; | ||
| import { MESSAGES_TABLE } from '../model/Message'; | ||
| import { type TMessageModel, type TThreadMessageModel } from '../../../definitions'; | ||
| import { getMessageById } from './Message'; | ||
| import { getThreadMessageById } from './ThreadMessage'; | ||
|
|
||
| jest.mock('../index', () => ({ | ||
| __esModule: true, | ||
| default: { | ||
| active: { | ||
| get: jest.fn() | ||
| } | ||
| } | ||
| })); | ||
|
|
||
| jest.mock('./ThreadMessage', () => ({ | ||
| getThreadMessageById: jest.fn() | ||
| })); | ||
|
|
||
| const mockGet = database.active.get as jest.Mock; | ||
| const mockGetThreadMessageById = getThreadMessageById as jest.MockedFunction<typeof getThreadMessageById>; | ||
|
|
||
| describe('getMessageById', () => { | ||
| let mockFind: jest.Mock; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| mockFind = jest.fn(); | ||
| mockGet.mockReturnValue({ find: mockFind }); | ||
| }); | ||
|
|
||
| it('returns null when messageId is empty and does not query the database', async () => { | ||
| const result = await getMessageById(''); | ||
|
|
||
| expect(result).toBeNull(); | ||
| expect(mockGet).not.toHaveBeenCalled(); | ||
| expect(mockGetThreadMessageById).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| describe('without tmid', () => { | ||
| it('resolves the message from the messages table', async () => { | ||
| const message = { id: 'message1', msg: 'Test' } as unknown as TMessageModel; | ||
| mockFind.mockResolvedValue(message); | ||
|
|
||
| const result = await getMessageById('message1'); | ||
|
|
||
| expect(result).toBe(message); | ||
| expect(mockGet).toHaveBeenCalledWith(MESSAGES_TABLE); | ||
| expect(mockFind).toHaveBeenCalledWith('message1'); | ||
| }); | ||
|
|
||
| it('does not look in the thread messages table', async () => { | ||
| mockFind.mockResolvedValue({ id: 'message1' }); | ||
|
|
||
| await getMessageById('message1'); | ||
|
|
||
| expect(mockGetThreadMessageById).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('returns null when the message does not exist', async () => { | ||
| mockFind.mockRejectedValue(new Error('not found')); | ||
|
|
||
| const result = await getMessageById('nonexistent'); | ||
|
|
||
| expect(result).toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('with tmid', () => { | ||
| it('prefers the thread messages table', async () => { | ||
| const threadMessage = { id: 'message1', msg: 'Thread reply' } as unknown as TThreadMessageModel; | ||
| mockGetThreadMessageById.mockResolvedValue(threadMessage as any); | ||
|
|
||
| const result = await getMessageById('message1', 'thread-id'); | ||
|
|
||
| expect(result).toBe(threadMessage); | ||
| expect(mockGetThreadMessageById).toHaveBeenCalledWith('message1'); | ||
| expect(mockFind).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('falls back to the messages table when not a thread message', async () => { | ||
| const parent = { id: 'parent', msg: 'Thread parent' } as unknown as TMessageModel; | ||
| mockGetThreadMessageById.mockResolvedValue(null); | ||
| mockFind.mockResolvedValue(parent); | ||
|
|
||
| const result = await getMessageById('parent', 'thread-id'); | ||
|
|
||
| expect(result).toBe(parent); | ||
| expect(mockGetThreadMessageById).toHaveBeenCalledWith('parent'); | ||
| expect(mockFind).toHaveBeenCalledWith('parent'); | ||
| }); | ||
|
|
||
| it('returns null when the message is in neither table', async () => { | ||
| mockGetThreadMessageById.mockResolvedValue(null); | ||
| mockFind.mockRejectedValue(new Error('not found')); | ||
|
|
||
| const result = await getMessageById('nonexistent', 'thread-id'); | ||
|
|
||
| expect(result).toBeNull(); | ||
| }); | ||
| }); | ||
| }); |
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.