diff --git a/.changeset/sixty-ladybugs-heal.md b/.changeset/sixty-ladybugs-heal.md new file mode 100644 index 0000000000000..1e4e5ca0602e9 --- /dev/null +++ b/.changeset/sixty-ladybugs-heal.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixes an issue where the start call button is available in archived rooms diff --git a/apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx b/apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx index c5501f527f594..484d8f7b9801c 100644 --- a/apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx +++ b/apps/meteor/client/hooks/roomActions/useVideoCallRoomAction.tsx @@ -50,7 +50,7 @@ export const useVideoCallRoomAction = () => { const visible = groups.length > 0; const allowed = visible && permittedToCallManagement && (!user?.username || !room.muted?.includes(user.username)) && !ownUser; - const disabled = federated || (!!room.ro && !permittedToPostReadonly); + const disabled = federated || (!!room.ro && !permittedToPostReadonly) || room.archived; const tooltip = disabled ? t('core.Video_Call_unavailable_for_this_type_of_room') : ''; const handleOpenVideoConf = useEffectEvent(async () => { diff --git a/apps/meteor/tests/e2e/utils/create-target-channel.ts b/apps/meteor/tests/e2e/utils/create-target-channel.ts index 7d72f6da8f2d2..ae906bd1d167b 100644 --- a/apps/meteor/tests/e2e/utils/create-target-channel.ts +++ b/apps/meteor/tests/e2e/utils/create-target-channel.ts @@ -100,3 +100,19 @@ export async function createChannelWithTeam(api: BaseTest['api']): Promise { + const { channel } = await createTargetChannelAndReturnFullRoom(api); + + try { + await api.post('/channels.archive', { roomId: channel._id }); + } catch (error) { + throw new Error(`Error archiving the channel: ${error}`); + } + + if (!channel.name) { + throw new Error('Invalid channel was created'); + } + + return channel.name; +} diff --git a/apps/meteor/tests/e2e/video-conference.spec.ts b/apps/meteor/tests/e2e/video-conference.spec.ts index 861bd2b2f56a1..7447c60ae6a97 100644 --- a/apps/meteor/tests/e2e/video-conference.spec.ts +++ b/apps/meteor/tests/e2e/video-conference.spec.ts @@ -1,7 +1,15 @@ import { IS_EE } from './config/constants'; import { Users } from './fixtures/userStates'; import { HomeChannel } from './page-objects'; -import { createTargetChannel, setUserPreferences, createTargetTeam, createDirectMessage } from './utils'; +import { + createArchivedChannel, + createTargetChannel, + setUserPreferences, + createTargetTeam, + createDirectMessage, + deleteChannel, + deleteTeam, +} from './utils'; import { expect, test } from './utils/test'; test.use({ storageState: Users.user1.state }); @@ -11,15 +19,26 @@ test.describe('video conference', () => { let poHomeChannel: HomeChannel; let targetChannel: string; let targetReadOnlyChannel: string; + let targetArchivedChannel: string; let targetTeam: string; test.beforeAll(async ({ api }) => { targetChannel = await createTargetChannel(api); targetReadOnlyChannel = await createTargetChannel(api, { readOnly: true }); + targetArchivedChannel = await createArchivedChannel(api); targetTeam = await createTargetTeam(api); await createDirectMessage(api); }); + test.afterAll(async ({ api }) => { + await Promise.all([ + deleteChannel(api, targetChannel), + deleteChannel(api, targetArchivedChannel), + deleteChannel(api, targetReadOnlyChannel), + deleteTeam(api, targetTeam), + ]); + }); + test.beforeEach(async ({ page }) => { poHomeChannel = new HomeChannel(page); @@ -47,7 +66,7 @@ test.describe('video conference', () => { await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible(); }); - test.describe('test video conference message block', async () => { + test.describe('video conference message block', async () => { test.use({ storageState: Users.admin.state }); test.beforeAll(async ({ api }) => { @@ -58,22 +77,22 @@ test.describe('video conference', () => { await setUserPreferences(api, { displayAvatars: true }); }); - test('should not render avatars in video conference message block', async () => { + test('should NOT render avatars in video conference message block', async () => { await poHomeChannel.sidenav.openChat(targetChannel); await expect(poHomeChannel.content.videoConfMessageBlock.last().getByRole('figure')).toHaveCount(0); }); }); - test.describe('test received in a "target channel"', async () => { + test.describe('verify if user2 received a invite call in targetChannel', async () => { test.use({ storageState: Users.user2.state }); - test('verify if user received a invite call from "targetChannel"', async () => { + test('should display a message block in a targetChannel', async () => { await poHomeChannel.sidenav.openChat(targetChannel); await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible(); }); }); - test('expect create video conference in a direct', async () => { + test('should create video conference in a direct room', async () => { await poHomeChannel.sidenav.openChat('user2'); await poHomeChannel.content.btnVideoCall.click(); @@ -89,7 +108,7 @@ test.describe('video conference', () => { }); }); - test('expect create video conference in a "targetTeam"', async () => { + test('should create video conference in targetTeam', async () => { await poHomeChannel.sidenav.openChat(targetTeam); await poHomeChannel.content.btnVideoCall.click(); @@ -97,15 +116,15 @@ test.describe('video conference', () => { await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible(); }); - test.describe('verify if received from a "targetTeam"', async () => { + test.describe('verify if user2 received from a targetTeam', async () => { test.use({ storageState: Users.user2.state }); - test('verify if user received from a "targetTeam"', async () => { + test('should display a message block in a targetTeam', async () => { await poHomeChannel.sidenav.openChat(targetTeam); await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible(); }); }); - test('expect create video conference in a direct multiple', async () => { + test('should create video conference in a direct multiple', async () => { await poHomeChannel.sidenav.openChat('rocketchat.internal.admin.test, user2'); await poHomeChannel.content.btnVideoCall.click(); @@ -115,15 +134,21 @@ test.describe('video conference', () => { test.describe('received in a direct multiple', async () => { test.use({ storageState: Users.user2.state }); - test('verify if user received from a multiple', async () => { + test('should display a message block in a direct multiple', async () => { await poHomeChannel.sidenav.openChat('rocketchat.internal.admin.test, user1'); await expect(poHomeChannel.content.videoConfMessageBlock.last()).toBeVisible(); }); }); - test('expect create video conference not available in a "targetReadOnlyChannel"', async () => { + test('should NOT create video conference in a targetReadOnlyChannel', async () => { await poHomeChannel.sidenav.openChat(targetReadOnlyChannel); - await expect(poHomeChannel.content.btnVideoCall).hasAttribute('disabled'); + await expect(poHomeChannel.content.btnVideoCall).toBeDisabled(); + }); + + test('should NOT be able to create video conference in targetArchivedChannel', async () => { + await poHomeChannel.sidenav.openChat(targetArchivedChannel); + + await expect(poHomeChannel.content.btnVideoCall).toBeDisabled(); }); });