snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
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 1s
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 1s
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
import type { ISetting } from '@rocket.chat/core-typings';
|
||||
import { mockAppRoot } from '@rocket.chat/mock-providers';
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { axe } from 'jest-axe';
|
||||
|
||||
import AbacEnabledToggle from './AbacEnabledToggle';
|
||||
import EditableSettingsProvider from '../../settings/EditableSettingsProvider';
|
||||
|
||||
const settingStructure = {
|
||||
packageValue: false,
|
||||
blocked: false,
|
||||
public: true,
|
||||
type: 'boolean',
|
||||
i18nLabel: 'ABAC_Enabled',
|
||||
i18nDescription: 'ABAC_Enabled_Description',
|
||||
} as Partial<ISetting>;
|
||||
|
||||
const baseAppRoot = mockAppRoot()
|
||||
.wrap((children) => <EditableSettingsProvider>{children}</EditableSettingsProvider>)
|
||||
.withTranslations('en', 'core', {
|
||||
ABAC_Enabled: 'Enable ABAC',
|
||||
ABAC_Enabled_Description: 'Enable Attribute-Based Access Control',
|
||||
ABAC_Warning_Modal_Title: 'Disable ABAC',
|
||||
ABAC_Warning_Modal_Confirm_Text: 'Disable',
|
||||
Cancel: 'Cancel',
|
||||
});
|
||||
|
||||
describe('AbacEnabledToggle', () => {
|
||||
it('should render the setting toggle when setting exists', () => {
|
||||
const { baseElement } = render(<AbacEnabledToggle hasABAC={true} />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', true, settingStructure).build(),
|
||||
});
|
||||
expect(baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should show warning modal when disabling ABAC', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<AbacEnabledToggle hasABAC={true} />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', true, settingStructure).build(),
|
||||
});
|
||||
|
||||
const toggle = screen.getByRole('checkbox');
|
||||
await waitFor(() => {
|
||||
expect(toggle).not.toBeDisabled();
|
||||
});
|
||||
await user.click(toggle);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Disable ABAC')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// TODO: discover how to automatically unmount all modals after each test
|
||||
const cancelButton = screen.getByRole('button', { name: /cancel/i });
|
||||
await user.click(cancelButton);
|
||||
});
|
||||
|
||||
it('should not show warning modal when enabling ABAC', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<AbacEnabledToggle hasABAC={true} />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', false, settingStructure).build(),
|
||||
});
|
||||
|
||||
const toggle = screen.getByRole('checkbox');
|
||||
await user.click(toggle);
|
||||
|
||||
// The modal should not appear when enabling ABAC
|
||||
expect(screen.queryByText('Disable ABAC')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should show warning modal when resetting setting', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<AbacEnabledToggle hasABAC={true} />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', true, settingStructure).build(),
|
||||
});
|
||||
|
||||
const resetButton = screen.getByRole('button', { name: /reset/i });
|
||||
await user.click(resetButton);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Disable ABAC')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// TODO: discover how to automatically unmount all modals after each test
|
||||
const cancelButton = screen.getByRole('button', { name: /cancel/i });
|
||||
await user.click(cancelButton);
|
||||
});
|
||||
|
||||
it('should have no accessibility violations', async () => {
|
||||
const { container } = render(<AbacEnabledToggle hasABAC={true} />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', true, settingStructure).build(),
|
||||
});
|
||||
const results = await axe(container);
|
||||
expect(results).toHaveNoViolations();
|
||||
});
|
||||
|
||||
it('should handle setting change correctly', async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<AbacEnabledToggle hasABAC={true} />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', false, settingStructure).build(),
|
||||
});
|
||||
|
||||
const toggle = await screen.findByRole('checkbox', { busy: false });
|
||||
expect(toggle).not.toBeChecked();
|
||||
|
||||
await user.click(toggle);
|
||||
expect(toggle).toBeChecked();
|
||||
});
|
||||
|
||||
it('should be disabled when abac license is not installed', () => {
|
||||
const { baseElement } = render(<AbacEnabledToggle hasABAC={false} />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', true, settingStructure).build(),
|
||||
});
|
||||
|
||||
const toggle = screen.getByRole('checkbox');
|
||||
expect(toggle).toBeDisabled();
|
||||
expect(baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should show skeleton when loading', () => {
|
||||
const { baseElement } = render(<AbacEnabledToggle hasABAC='loading' />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', true, settingStructure).build(),
|
||||
});
|
||||
expect(baseElement).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should show reset button when value differs from package value', () => {
|
||||
render(<AbacEnabledToggle hasABAC={true} />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', true, settingStructure).build(),
|
||||
});
|
||||
|
||||
expect(screen.getByRole('button', { name: /reset/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should not show reset button when value matches package value', () => {
|
||||
render(<AbacEnabledToggle hasABAC={true} />, {
|
||||
wrapper: baseAppRoot.withSetting('ABAC_Enabled', false, settingStructure).build(),
|
||||
});
|
||||
|
||||
expect(screen.queryByRole('button', { name: /reset/i })).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user