Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s
274 lines
11 KiB
TypeScript
274 lines
11 KiB
TypeScript
import { mockAppRoot } from '@rocket.chat/mock-providers';
|
|
import { render, screen } from '@testing-library/react';
|
|
import userEvent from '@testing-library/user-event';
|
|
|
|
import CreateTeamModal from './CreateTeamModal';
|
|
|
|
jest.mock('../../../lib/rooms/roomCoordinator', () => ({}));
|
|
|
|
describe('CreateTeamModal', () => {
|
|
it('should render with encryption option disabled and set to off when E2E_Enable=false and E2E_Enabled_Default_PrivateRooms=false', async () => {
|
|
render(<CreateTeamModal 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('Teams_New_Encrypted_Label') 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(<CreateTeamModal 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('Teams_New_Encrypted_Label') 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(<CreateTeamModal 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('Teams_New_Encrypted_Label') 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(<CreateTeamModal 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('Teams_New_Encrypted_Label') 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(<CreateTeamModal 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('Teams_New_Encrypted_Label') as HTMLInputElement;
|
|
const priv = screen.getByLabelText('Teams_New_Private_Label') 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(<CreateTeamModal 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('Teams_New_Encrypted_Label') as HTMLInputElement;
|
|
const priv = screen.getByLabelText('Teams_New_Private_Label') 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 team: toggling Broadcast on/off does not change or disable Encrypted', async () => {
|
|
render(<CreateTeamModal 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('Teams_New_Encrypted_Label') as HTMLInputElement;
|
|
const broadcast = screen.getByLabelText('Teams_New_Broadcast_Label') as HTMLInputElement;
|
|
const priv = screen.getByLabelText('Teams_New_Private_Label') 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 team: Encrypted remains OFF and disabled regardless of Broadcast state', async () => {
|
|
render(<CreateTeamModal 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('Teams_New_Encrypted_Label') as HTMLInputElement;
|
|
const broadcast = screen.getByLabelText('Teams_New_Broadcast_Label') as HTMLInputElement;
|
|
const priv = screen.getByLabelText('Teams_New_Private_Label') 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();
|
|
});
|
|
|
|
it('should render a private team with encryption checked and disabled for changes when private room encryption is forced', async () => {
|
|
render(<CreateTeamModal onClose={() => null} />, {
|
|
wrapper: mockAppRoot().withSetting('E2E_Enable', true).withSetting('E2E_Force_Encryption_For_Private_Rooms', true).build(),
|
|
});
|
|
|
|
await userEvent.click(screen.getByText('Advanced_settings'));
|
|
|
|
const encrypted = screen.getByLabelText('Teams_New_Encrypted_Label') as HTMLInputElement;
|
|
const priv = screen.getByLabelText('Teams_New_Private_Label') as HTMLInputElement;
|
|
|
|
// private by default: encrypted is forced ON and cannot be changed
|
|
expect(priv).toBeChecked();
|
|
expect(encrypted).toBeChecked();
|
|
expect(encrypted).toBeDisabled();
|
|
|
|
// Private ON -> OFF: encrypted turns OFF and stays disabled (public teams cannot be encrypted)
|
|
await userEvent.click(priv);
|
|
expect(priv).not.toBeChecked();
|
|
expect(encrypted).not.toBeChecked();
|
|
expect(encrypted).toBeDisabled();
|
|
|
|
// Private OFF -> ON: encryption is forced back ON and remains disabled
|
|
await userEvent.click(priv);
|
|
expect(priv).toBeChecked();
|
|
expect(encrypted).toBeChecked();
|
|
expect(encrypted).toBeDisabled();
|
|
});
|
|
|
|
it('should disable and turn on ReadOnly toggle when Broadcast is ON and no set-readonly permission', async () => {
|
|
render(<CreateTeamModal onClose={() => null} />, {
|
|
wrapper: mockAppRoot().build(),
|
|
});
|
|
|
|
await userEvent.click(screen.getByText('Advanced_settings'));
|
|
|
|
const broadcast = screen.getByLabelText('Teams_New_Broadcast_Label') as HTMLInputElement;
|
|
const readOnly = screen.getByLabelText('Teams_New_Read_only_Label') as HTMLInputElement;
|
|
|
|
expect(readOnly).not.toBeChecked();
|
|
|
|
// Broadcast: OFF -> ON (ReadOnly stays ON + disabled)
|
|
await userEvent.click(broadcast);
|
|
expect(broadcast).toBeChecked();
|
|
expect(readOnly).toBeChecked();
|
|
expect(readOnly).toBeDisabled();
|
|
});
|
|
|
|
it('should disable and turn on ReadOnly toggle when Broadcast is ON with set-readonly permission', async () => {
|
|
render(<CreateTeamModal onClose={() => null} />, {
|
|
wrapper: mockAppRoot().withPermission('set-readonly').build(),
|
|
});
|
|
|
|
await userEvent.click(screen.getByText('Advanced_settings'));
|
|
|
|
const broadcast = screen.getByLabelText('Teams_New_Broadcast_Label') as HTMLInputElement;
|
|
const readOnly = screen.getByLabelText('Teams_New_Read_only_Label') as HTMLInputElement;
|
|
|
|
expect(readOnly).not.toBeChecked();
|
|
|
|
// Broadcast: OFF -> ON (ReadOnly stays ON + disabled)
|
|
await userEvent.click(broadcast);
|
|
expect(broadcast).toBeChecked();
|
|
expect(readOnly).toBeChecked();
|
|
expect(readOnly).toBeDisabled();
|
|
});
|
|
|
|
it('should disable and turn off ReadOnly toggle when Broadcast is OFF with no set-readonly permission', async () => {
|
|
render(<CreateTeamModal onClose={() => null} />, {
|
|
wrapper: mockAppRoot().build(),
|
|
});
|
|
|
|
await userEvent.click(screen.getByText('Advanced_settings'));
|
|
|
|
const broadcast = screen.getByLabelText('Teams_New_Broadcast_Label') as HTMLInputElement;
|
|
const readOnly = screen.getByLabelText('Teams_New_Read_only_Label') as HTMLInputElement;
|
|
|
|
expect(broadcast).not.toBeChecked();
|
|
expect(readOnly).not.toBeChecked();
|
|
expect(readOnly).toBeDisabled();
|
|
});
|
|
|
|
it('should enable ReadOnly toggle when Broadcast is OFF with set-readonly permission', async () => {
|
|
render(<CreateTeamModal onClose={() => null} />, {
|
|
wrapper: mockAppRoot().withPermission('set-readonly').build(),
|
|
});
|
|
|
|
await userEvent.click(screen.getByText('Advanced_settings'));
|
|
|
|
const broadcast = screen.getByLabelText('Teams_New_Broadcast_Label') as HTMLInputElement;
|
|
const readOnly = screen.getByLabelText('Teams_New_Read_only_Label') as HTMLInputElement;
|
|
|
|
expect(broadcast).not.toBeChecked();
|
|
expect(readOnly).not.toBeChecked();
|
|
expect(readOnly).toBeEnabled();
|
|
});
|
|
});
|