- Updated package dependencies to include `@sentry/node` for error tracking. - Refactored command routing to incorporate user and guild blacklisting checks, improving command execution safety. - Enhanced health server metrics to include queue waiting times, providing better insights into system performance. - Introduced confirmation handling for guild backup commands, streamlining user interactions. - Improved moderation commands with better error handling and case management, ensuring robust moderation capabilities. - Added new duration parsing functions to handle timeout durations effectively, enhancing moderation features. - Updated localization files to reflect new command structures and user guidance improvements.
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
import { createHash } from 'node:crypto';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { moduleForCommand } from './module-gates.js';
|
|
|
|
describe('moduleForCommand', () => {
|
|
it('maps moderation commands', () => {
|
|
expect(moduleForCommand('ban')).toBe('moderation');
|
|
expect(moduleForCommand('warn')).toBe('moderation');
|
|
expect(moduleForCommand('case')).toBe('moderation');
|
|
});
|
|
|
|
it('maps redis-only and prisma modules', () => {
|
|
expect(moduleForCommand('giveaway')).toBe('giveaways');
|
|
expect(moduleForCommand('tag')).toBe('tags');
|
|
expect(moduleForCommand('backup')).toBe('guildbackup');
|
|
expect(moduleForCommand('economy' as string)).toBeNull();
|
|
expect(moduleForCommand('balance')).toBe('economy');
|
|
});
|
|
|
|
it('leaves core commands unmapped', () => {
|
|
expect(moduleForCommand('help')).toBeNull();
|
|
expect(moduleForCommand('info')).toBeNull();
|
|
expect(moduleForCommand('gdpr')).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe('feature flag rollout hashing', () => {
|
|
it('is stable for the same guild/key pair', () => {
|
|
const a = createHash('sha256').update('moderation:guild-1').digest().readUInt32BE(0) % 100;
|
|
const b = createHash('sha256').update('moderation:guild-1').digest().readUInt32BE(0) % 100;
|
|
expect(a).toBe(b);
|
|
});
|
|
});
|