-
Notifications
You must be signed in to change notification settings - Fork 13k
fix: encryption toggle disabled/reset when toggling Private or Broadcast under E2E defaults #36714
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
Merged
kodiakhq
merged 5 commits into
develop
from
fix/encryption-flag-reset-toggle-private-broadcast-e2e-defaults
Aug 19, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
686b6a2
fix: encryption toggle disabled/reset when toggling Private or Broadc…
abhinavkrin 1073aca
added changeset
abhinavkrin e0b0193
typo
abhinavkrin 5f149cb
requested changes
abhinavkrin 843e56a
Merge branch 'develop' into fix/encryption-flag-reset-toggle-private-…
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Fixes an issue where the Encrypted toggle in the `Create Channel Modal` would change unexpectedly or become disabled after switching the Private or Broadcast options when E2E defaults are enabled. | ||
|
|
8 changes: 8 additions & 0 deletions
8
apps/meteor/client/NavBarV2/NavBarPagesGroup/actions/CreateChannelModal.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { testCreateChannelModal } from './testCreateChannelModal'; | ||
| import CreateChannelModalComponent from '../../../sidebar/header/CreateChannel'; | ||
|
|
||
| jest.mock('../../../lib/utils/goToRoomById', () => ({ | ||
| goToRoomById: jest.fn(), | ||
| })); | ||
|
|
||
| testCreateChannelModal(CreateChannelModalComponent); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
apps/meteor/client/NavBarV2/NavBarPagesGroup/actions/testCreateChannelModal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
|
|
||
| import type CreateChannelModal2Component from './CreateChannelModal'; | ||
| import type CreateChannelModalComponent from '../../../sidebar/header/CreateChannel'; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/naming-convention | ||
| export function testCreateChannelModal(CreateChannelModal: typeof CreateChannelModalComponent | typeof CreateChannelModal2Component) { | ||
| describe('CreateChannelModal', () => { | ||
| it('should render with encryption option disabled and set to off when E2E_Enable=false and E2E_Enabled_Default_PrivateRooms=false', async () => { | ||
| render(<CreateChannelModal onClose={() => null} />, { | ||
| wrapper: mockAppRoot().withSetting('E2E_Enable', false).withSetting('E2E_Enabled_Default_PrivateRooms', false).build(), | ||
| }); | ||
|
|
||
| await userEvent.click(screen.getByText('Advanced_settings')); | ||
|
|
||
| const encrypted = screen.getByLabelText('Encrypted') as HTMLInputElement; | ||
| expect(encrypted).toBeInTheDocument(); | ||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeDisabled(); | ||
| }); | ||
|
|
||
| it('should render with encryption option enabled and set to off when E2E_Enable=true and E2E_Enabled_Default_PrivateRooms=false', async () => { | ||
| render(<CreateChannelModal onClose={() => null} />, { | ||
| wrapper: mockAppRoot().withSetting('E2E_Enable', true).withSetting('E2E_Enabled_Default_PrivateRooms', false).build(), | ||
| }); | ||
|
|
||
| await userEvent.click(screen.getByText('Advanced_settings')); | ||
|
|
||
| const encrypted = screen.getByLabelText('Encrypted') as HTMLInputElement; | ||
| expect(encrypted).toBeInTheDocument(); | ||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeEnabled(); | ||
| }); | ||
|
|
||
| it('should render with encryption option disabled and set to off when E2E_Enable=false and E2E_Enabled_Default_PrivateRooms=true', async () => { | ||
| render(<CreateChannelModal onClose={() => null} />, { | ||
| wrapper: mockAppRoot().withSetting('E2E_Enable', false).withSetting('E2E_Enabled_Default_PrivateRooms', true).build(), | ||
| }); | ||
|
|
||
| await userEvent.click(screen.getByText('Advanced_settings')); | ||
|
|
||
| const encrypted = screen.getByLabelText('Encrypted') as HTMLInputElement; | ||
| expect(encrypted).toBeInTheDocument(); | ||
|
|
||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeDisabled(); | ||
| }); | ||
|
|
||
| it('should render with encryption option enabled and set to on when E2E_Enable=true and E2E_Enabled_Default_PrivateRooms=True', async () => { | ||
| render(<CreateChannelModal onClose={() => null} />, { | ||
| wrapper: mockAppRoot().withSetting('E2E_Enable', true).withSetting('E2E_Enabled_Default_PrivateRooms', true).build(), | ||
| }); | ||
|
|
||
| await userEvent.click(screen.getByText('Advanced_settings')); | ||
|
|
||
| const encrypted = screen.getByLabelText('Encrypted') as HTMLInputElement; | ||
| expect(encrypted).toBeChecked(); | ||
| expect(encrypted).toBeEnabled(); | ||
| }); | ||
|
|
||
| it('when Private goes ON → OFF: forces Encrypted OFF and disables it (E2E_Enable=true, E2E_Enabled_Default_PrivateRooms=true)', async () => { | ||
| render(<CreateChannelModal onClose={() => null} />, { | ||
| wrapper: mockAppRoot().withSetting('E2E_Enable', true).withSetting('E2E_Enabled_Default_PrivateRooms', true).build(), | ||
| }); | ||
|
|
||
| await userEvent.click(screen.getByText('Advanced_settings')); | ||
|
|
||
| const encrypted = screen.getByLabelText('Encrypted') as HTMLInputElement; | ||
| const priv = screen.getByLabelText('Private') as HTMLInputElement; | ||
|
|
||
| // initial: private=true, encrypted ON and enabled | ||
| expect(priv).toBeChecked(); | ||
| expect(encrypted).toBeChecked(); | ||
| expect(encrypted).toBeEnabled(); | ||
|
|
||
| // Private ON -> OFF: encrypted must become OFF and disabled | ||
| await userEvent.click(priv); | ||
| expect(priv).not.toBeChecked(); | ||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeDisabled(); | ||
| }); | ||
|
|
||
| it('when Private goes OFF → ON: keeps Encrypted OFF but re-enables it (E2E_Enable=true, E2E_Enabled_Default_PrivateRooms=true)', async () => { | ||
| render(<CreateChannelModal onClose={() => null} />, { | ||
| wrapper: mockAppRoot().withSetting('E2E_Enable', true).withSetting('E2E_Enabled_Default_PrivateRooms', true).build(), | ||
| }); | ||
|
|
||
| await userEvent.click(screen.getByText('Advanced_settings')); | ||
|
|
||
| const encrypted = screen.getByLabelText('Encrypted') as HTMLInputElement; | ||
| const priv = screen.getByLabelText('Private') as HTMLInputElement; | ||
|
|
||
| // turn private OFF to simulate user path from non-private | ||
| await userEvent.click(priv); | ||
| expect(priv).not.toBeChecked(); | ||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeDisabled(); | ||
|
|
||
| // turn private back ON -> encrypted should remain OFF but become enabled | ||
| await userEvent.click(priv); | ||
| expect(priv).toBeChecked(); | ||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeEnabled(); | ||
| }); | ||
|
|
||
| it('private room: toggling Broadcast on/off does not change or disable Encrypted', async () => { | ||
| render(<CreateChannelModal onClose={() => null} />, { | ||
| wrapper: mockAppRoot().withSetting('E2E_Enable', true).withSetting('E2E_Enabled_Default_PrivateRooms', true).build(), | ||
| }); | ||
|
|
||
| await userEvent.click(screen.getByText('Advanced_settings')); | ||
|
|
||
| const encrypted = screen.getByLabelText('Encrypted') as HTMLInputElement; | ||
| const broadcast = screen.getByLabelText('Broadcast') as HTMLInputElement; | ||
| const priv = screen.getByLabelText('Private') as HTMLInputElement; | ||
|
|
||
| expect(priv).toBeChecked(); | ||
| expect(encrypted).toBeChecked(); | ||
| expect(encrypted).toBeEnabled(); | ||
| expect(broadcast).not.toBeChecked(); | ||
|
|
||
| // Broadcast: OFF -> ON (Encrypted unchanged + enabled) | ||
| await userEvent.click(broadcast); | ||
| expect(broadcast).toBeChecked(); | ||
| expect(encrypted).toBeChecked(); | ||
| expect(encrypted).toBeEnabled(); | ||
|
|
||
| // Broadcast: ON -> OFF (Encrypted unchanged + enabled) | ||
| await userEvent.click(broadcast); | ||
| expect(broadcast).not.toBeChecked(); | ||
| expect(encrypted).toBeChecked(); | ||
| expect(encrypted).toBeEnabled(); | ||
|
|
||
| // User can still toggle Encrypted freely while Broadcast is OFF | ||
| await userEvent.click(encrypted); | ||
| expect(encrypted).not.toBeChecked(); | ||
|
|
||
| // User can still toggle Encrypted freely while Broadcast is ON | ||
| await userEvent.click(broadcast); | ||
| expect(broadcast).toBeChecked(); | ||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeEnabled(); | ||
| }); | ||
|
|
||
| it('non-private room: Encrypted remains OFF and disabled regardless of Broadcast state', async () => { | ||
| render(<CreateChannelModal onClose={() => null} />, { | ||
| wrapper: mockAppRoot().withSetting('E2E_Enable', true).withSetting('E2E_Enabled_Default_PrivateRooms', true).build(), | ||
| }); | ||
|
|
||
| await userEvent.click(screen.getByText('Advanced_settings')); | ||
|
|
||
| const encrypted = screen.getByLabelText('Encrypted') as HTMLInputElement; | ||
| const broadcast = screen.getByLabelText('Broadcast') as HTMLInputElement; | ||
| const priv = screen.getByLabelText('Private') as HTMLInputElement; | ||
|
|
||
| // Switch to non-private | ||
| await userEvent.click(priv); | ||
| expect(priv).not.toBeChecked(); | ||
|
|
||
| // Encrypted must be OFF + disabled (non-private cannot be encrypted) | ||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeDisabled(); | ||
|
|
||
| // Broadcast: OFF -> ON (Encrypted stays OFF + disabled) | ||
| await userEvent.click(broadcast); | ||
| expect(broadcast).toBeChecked(); | ||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeDisabled(); | ||
|
|
||
| // Broadcast: ON -> OFF (Encrypted still OFF + disabled) | ||
| await userEvent.click(broadcast); | ||
| expect(broadcast).not.toBeChecked(); | ||
| expect(encrypted).not.toBeChecked(); | ||
| expect(encrypted).toBeDisabled(); | ||
| }); | ||
| }); | ||
| } |
8 changes: 8 additions & 0 deletions
8
apps/meteor/client/sidebar/header/CreateChannel/CreateChannelModal.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import CreateChannelModal from './CreateChannelModal'; | ||
| import { testCreateChannelModal } from '../../../NavBarV2/NavBarPagesGroup/actions/testCreateChannelModal'; | ||
|
|
||
| jest.mock('../../../lib/utils/goToRoomById', () => ({ | ||
| goToRoomById: jest.fn(), | ||
| })); | ||
|
|
||
| testCreateChannelModal(CreateChannelModal); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.