Skip to content

Commit

Permalink
fix: Read receipts menu item enabled condition (#31695)
Browse files Browse the repository at this point in the history
Co-authored-by: csuadev <[email protected]>
Co-authored-by: Douglas Fabris <[email protected]>
  • Loading branch information
3 people authored May 16, 2024
1 parent b01cdce commit 3650e27
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-geckos-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix an issue where read receipts menu item wasn't considering the enabled setting to be displayed
2 changes: 1 addition & 1 deletion apps/meteor/ee/client/startup/readReceipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ReadReceiptsModal from '../../../client/views/room/modals/ReadReceiptsMod

Meteor.startup(() => {
Tracker.autorun(() => {
const enabled = settings.get('Message_Read_Receipt_Store_Users');
const enabled = settings.get('Message_Read_Receipt_Enabled') && settings.get('Message_Read_Receipt_Store_Users');

if (!enabled) {
return MessageAction.removeButton('receipt-detail');
Expand Down
58 changes: 38 additions & 20 deletions apps/meteor/tests/e2e/read-receipts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ test.describe.serial('read-receipts', () => {
test.skip(!IS_EE, 'Enterprise Only');

test.beforeAll(async ({ api }) => {
await setSettingValueById(api, 'Message_Read_Receipt_Enabled', true);
await setSettingValueById(api, 'Message_Read_Receipt_Store_Users', true);

targetChannel = await createTargetChannel(api);
});

Expand All @@ -26,26 +23,47 @@ test.describe.serial('read-receipts', () => {
await page.goto('/home');
});

test('should show read receipts message sent status in the sent message', async ({ browser }) => {
const { page } = await createAuxContext(browser, Users.user1);
const auxContext = { page, poHomeChannel: new HomeChannel(page) };
await auxContext.poHomeChannel.sidenav.openChat(targetChannel);
await auxContext.poHomeChannel.content.sendMessage('hello admin');

await expect(auxContext.poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message sent' })).toBeVisible();
await auxContext.page.close();
test.describe('read receipt settings disabled', async () => {
test('should not show read receipts item menu', async ({ page }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.sendMessage('hello world');
await poHomeChannel.content.openLastMessageMenu();
expect(page.locator('role=menuitem[name="Read receipts"]')).not.toBeVisible;
});
});

test('should show read receipts message viewed status in the sent message', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await expect(poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message viewed' })).toBeVisible();
});
test.describe('read receipts enabled', async () => {
test.beforeAll(async ({ api }) => {
await setSettingValueById(api, 'Message_Read_Receipt_Enabled', true);
await setSettingValueById(api, 'Message_Read_Receipt_Store_Users', true);
});

test('should show the reads receipt modal with the users who read the message', async ({ page }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.openLastMessageMenu();
await page.locator('role=menuitem[name="Read receipts"]').click();
test.afterAll(async ({ api }) => {
await setSettingValueById(api, 'Message_Read_Receipt_Enabled', false);
await setSettingValueById(api, 'Message_Read_Receipt_Store_Users', false);
});

await expect(page.getByRole('dialog').getByRole('listitem')).toHaveCount(2);
test('should show read receipts message sent status in the sent message', async ({ browser }) => {
const { page } = await createAuxContext(browser, Users.user1);
const auxContext = { page, poHomeChannel: new HomeChannel(page) };
await auxContext.poHomeChannel.sidenav.openChat(targetChannel);
await auxContext.poHomeChannel.content.sendMessage('hello admin');

await expect(auxContext.poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message sent' })).toBeVisible();
await auxContext.page.close();
});

test('should show read receipts message viewed status in the sent message', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await expect(poHomeChannel.content.lastUserMessage.getByRole('status', { name: 'Message viewed' })).toBeVisible();
});

test('should show the reads receipt modal with the users who read the message', async ({ page }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.content.openLastMessageMenu();
await page.locator('role=menuitem[name="Read receipts"]').click();

await expect(page.getByRole('dialog').getByRole('listitem')).toHaveCount(2);
});
});
});

0 comments on commit 3650e27

Please sign in to comment.