From 3650e271731bcb7e50ef9ef94d282dbea70acb2e Mon Sep 17 00:00:00 2001 From: Yash Rajpal <58601732+yash-rajpal@users.noreply.github.com> Date: Thu, 16 May 2024 22:35:13 +0530 Subject: [PATCH] fix: Read receipts menu item enabled condition (#31695) Co-authored-by: csuadev <72958726+csuadev@users.noreply.github.com> Co-authored-by: Douglas Fabris <27704687+dougfabris@users.noreply.github.com> --- .changeset/breezy-geckos-sparkle.md | 5 ++ apps/meteor/ee/client/startup/readReceipt.ts | 2 +- apps/meteor/tests/e2e/read-receipts.spec.ts | 58 +++++++++++++------- 3 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 .changeset/breezy-geckos-sparkle.md diff --git a/.changeset/breezy-geckos-sparkle.md b/.changeset/breezy-geckos-sparkle.md new file mode 100644 index 000000000000..c64ffe920282 --- /dev/null +++ b/.changeset/breezy-geckos-sparkle.md @@ -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 diff --git a/apps/meteor/ee/client/startup/readReceipt.ts b/apps/meteor/ee/client/startup/readReceipt.ts index 94c2b0c65de1..eb23aa5fd883 100644 --- a/apps/meteor/ee/client/startup/readReceipt.ts +++ b/apps/meteor/ee/client/startup/readReceipt.ts @@ -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'); diff --git a/apps/meteor/tests/e2e/read-receipts.spec.ts b/apps/meteor/tests/e2e/read-receipts.spec.ts index 0fe4759472e8..524b79d4e919 100644 --- a/apps/meteor/tests/e2e/read-receipts.spec.ts +++ b/apps/meteor/tests/e2e/read-receipts.spec.ts @@ -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); }); @@ -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); + }); }); });