Skip to content
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

regression: Messagebox sending message instead of just selecting popup suggestion #32890

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const useComposerBoxPopup = <T extends { _id: string; sort?: number }>({
setPopup(undefined);
setFocused(undefined);
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
}
});

Expand All @@ -192,7 +192,7 @@ export const useComposerBoxPopup = <T extends { _id: string; sort?: number }>({
select(focused);

event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
return true;
}
if (event.which === keys.ARROW_UP && !(event.shiftKey || event.ctrlKey || event.altKey || event.metaKey)) {
Expand All @@ -211,7 +211,7 @@ export const useComposerBoxPopup = <T extends { _id: string; sort?: number }>({
return (focusedIndex > 0 ? list[focusedIndex - 1] : list[list.length - 1]) as T;
});
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
return true;
}
if (event.which === keys.ARROW_DOWN && !(event.shiftKey || event.ctrlKey || event.altKey || event.metaKey)) {
Expand All @@ -230,7 +230,7 @@ export const useComposerBoxPopup = <T extends { _id: string; sort?: number }>({
return (focusedIndex < list.length - 1 ? list[focusedIndex + 1] : list[0]) as T;
});
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
return true;
}
});
Expand Down
35 changes: 35 additions & 0 deletions apps/meteor/tests/e2e/message-composer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,39 @@ test.describe.serial('message-composer', () => {

await expect(poHomeChannel.composer).toHaveValue(`[hello composer](${url})`);
});

test('should select popup item and not send the message when pressing enter', async ({ page }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.sendMessage('hello composer');

await test.step('mention popup', async () => {
await page.keyboard.type('hello composer @all');

await page.keyboard.press('Enter');

await expect(poHomeChannel.composer).toHaveValue('hello composer @all ');

await poHomeChannel.composer.fill('');
});

await test.step('emoji popup', async () => {
await page.keyboard.type('hello composer :flag_br');

await page.keyboard.press('Enter');

await expect(poHomeChannel.composer).toHaveValue('hello composer :flag_br: ');

await poHomeChannel.composer.fill('');
});

await test.step('slash command', async () => {
await page.keyboard.type('/gim');

await page.keyboard.press('Enter');

await expect(poHomeChannel.composer).toHaveValue('/gimme ');

await poHomeChannel.composer.fill('');
Copy link
Member

@jessicaschelly jessicaschelly Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could move this to an afterEach? Since it could be helpful for the other tests as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If having the input empty is a prerequisite, it should be in the beforeEach. and one after all to cleanup

also is not type deprecated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I decided to use test and test.step, which does not provider before/after callbacks. This decision was made to favor performance of the tests, since have one test for each of those would open a new page during execution.

});
});
});
Loading