From f5ea2ff99e42d66c5757a38f70bf3a0f22fa543a Mon Sep 17 00:00:00 2001 From: Hugo Costa Date: Wed, 24 Jul 2024 09:01:17 -0300 Subject: [PATCH] fix: e2ee "copy link" action enabled in starred and pinned message list (#32803) --- .changeset/red-numbers-happen.md | 5 +++++ .../startup/actionButtons/permalinkPinned.ts | 4 ++++ .../startup/actionButtons/permalinkStar.ts | 4 ++++ apps/meteor/tests/e2e/e2e-encryption.spec.ts | 19 +++++++++++++------ 4 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 .changeset/red-numbers-happen.md diff --git a/.changeset/red-numbers-happen.md b/.changeset/red-numbers-happen.md new file mode 100644 index 000000000000..61cb0d2b7586 --- /dev/null +++ b/.changeset/red-numbers-happen.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Fixed "Copy link" message action enabled in Starred and Pinned list for End to End Encrypted channels, this action is disabled now diff --git a/apps/meteor/client/startup/actionButtons/permalinkPinned.ts b/apps/meteor/client/startup/actionButtons/permalinkPinned.ts index bfbdf49da2eb..ddd9237c3eb8 100644 --- a/apps/meteor/client/startup/actionButtons/permalinkPinned.ts +++ b/apps/meteor/client/startup/actionButtons/permalinkPinned.ts @@ -1,3 +1,4 @@ +import { isE2EEMessage } from '@rocket.chat/core-typings'; import { Meteor } from 'meteor/meteor'; import { MessageAction } from '../../../app/ui-utils/client'; @@ -27,5 +28,8 @@ Meteor.startup(() => { }, order: 5, group: 'menu', + disabled({ message }) { + return isE2EEMessage(message); + }, }); }); diff --git a/apps/meteor/client/startup/actionButtons/permalinkStar.ts b/apps/meteor/client/startup/actionButtons/permalinkStar.ts index bf6deede9b10..a1ee8d79fc44 100644 --- a/apps/meteor/client/startup/actionButtons/permalinkStar.ts +++ b/apps/meteor/client/startup/actionButtons/permalinkStar.ts @@ -1,3 +1,4 @@ +import { isE2EEMessage } from '@rocket.chat/core-typings'; import { Meteor } from 'meteor/meteor'; import { MessageAction } from '../../../app/ui-utils/client'; @@ -32,5 +33,8 @@ Meteor.startup(() => { }, order: 10, group: 'menu', + disabled({ message }) { + return isE2EEMessage(message); + }, }); }); diff --git a/apps/meteor/tests/e2e/e2e-encryption.spec.ts b/apps/meteor/tests/e2e/e2e-encryption.spec.ts index 6f73fb6b5961..ad73006886bf 100644 --- a/apps/meteor/tests/e2e/e2e-encryption.spec.ts +++ b/apps/meteor/tests/e2e/e2e-encryption.spec.ts @@ -524,19 +524,26 @@ test.describe.serial('e2e-encryption', () => { await poHomeChannel.tabs.btnPinnedMessagesList.click(); await expect(page.getByRole('dialog', { name: 'Pinned Messages' })).toBeVisible(); - await expect(page.getByRole('dialog', { name: 'Pinned Messages' }).locator('[data-qa-type="message"]').last()).toContainText( - 'This message should be pinned and stared.', - ); + + const lastPinnedMessage = page.getByRole('dialog', { name: 'Pinned Messages' }).locator('[data-qa-type="message"]').last(); + await expect(lastPinnedMessage).toContainText('This message should be pinned and stared.'); + await lastPinnedMessage.hover(); + await lastPinnedMessage.locator('role=button[name="More"]').waitFor(); + await lastPinnedMessage.locator('role=button[name="More"]').click(); + await expect(page.locator('role=menuitem[name="Copy link"]')).toHaveClass(/disabled/); await poHomeChannel.btnContextualbarClose.click(); await poHomeChannel.tabs.kebab.click(); await poHomeChannel.tabs.btnStarredMessageList.click(); + const lastStarredMessage = page.getByRole('dialog', { name: 'Starred Messages' }).locator('[data-qa-type="message"]').last(); await expect(page.getByRole('dialog', { name: 'Starred Messages' })).toBeVisible(); - await expect(page.getByRole('dialog', { name: 'Starred Messages' }).locator('[data-qa-type="message"]').last()).toContainText( - 'This message should be pinned and stared.', - ); + await expect(lastStarredMessage).toContainText('This message should be pinned and stared.'); + await lastStarredMessage.hover(); + await lastStarredMessage.locator('role=button[name="More"]').waitFor(); + await lastStarredMessage.locator('role=button[name="More"]').click(); + await expect(page.locator('role=menuitem[name="Copy link"]')).toHaveClass(/disabled/); }); test.describe('reset keys', () => {