- Introduced global command channel whitelist and blacklist in the GuildSettings model for improved command access control. - Implemented command gate logic in the command routing to handle channel and role restrictions, providing user feedback for denied commands. - Enhanced the CommandsManager component to support global rules and channel/role selection, improving the user interface for managing command permissions. - Updated localization files to include new keys for global command rules and related messages, ensuring clarity in user interactions.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { isChannelAllowed, isRoleAllowed } from './command-gate-rules.js';
|
|
|
|
describe('command-gates channel rules', () => {
|
|
it('allows any channel when allow and deny are empty', () => {
|
|
expect(isChannelAllowed('1', [], [])).toBeNull();
|
|
});
|
|
|
|
it('blocks denied channels even when allow is empty', () => {
|
|
expect(isChannelAllowed('1', [], ['1'])).toBe('channel_denied');
|
|
});
|
|
|
|
it('requires membership when allow list is set', () => {
|
|
expect(isChannelAllowed('1', ['2'], [])).toBe('channel_not_allowed');
|
|
expect(isChannelAllowed('2', ['2'], [])).toBeNull();
|
|
});
|
|
|
|
it('prefers deny over allow', () => {
|
|
expect(isChannelAllowed('1', ['1'], ['1'])).toBe('channel_denied');
|
|
});
|
|
});
|
|
|
|
describe('command-gates role rules', () => {
|
|
it('blocks when any denied role is present', () => {
|
|
expect(isRoleAllowed(['a', 'b'], [], ['b'])).toBe('role_denied');
|
|
});
|
|
|
|
it('requires an allowed role when allow list is set', () => {
|
|
expect(isRoleAllowed(['a'], ['b'], [])).toBe('role_not_allowed');
|
|
expect(isRoleAllowed(['a', 'b'], ['b'], [])).toBeNull();
|
|
});
|
|
});
|