Enhance environment configuration and expand Prisma schema for bot management
- Added OWNER_USER_IDS to .env.example for specifying global bot owners. - Introduced new models in the Prisma schema: CommandOverride, OwnerTeamMember, GlobalUserBlacklist, GuildBlacklist, FeatureFlag, BotPresenceConfig, ChangelogEntry, and OwnerAuditLog to support advanced bot management features. - Updated env.ts to preprocess OWNER_USER_IDS for better handling of global bot owner IDs. - Modified ModulePlaceholderPage to ensure proper routing for remaining dashboard modules.
This commit is contained in:
77
packages/shared/src/dashboard.test.ts
Normal file
77
packages/shared/src/dashboard.test.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
AutomodConfigDashboardPatchSchema,
|
||||
CaseListQuerySchema,
|
||||
EconomyConfigDashboardPatchSchema,
|
||||
FunConfigDashboardSchema,
|
||||
LoggingConfigDashboardPatchSchema,
|
||||
ModerationDashboardPatchSchema,
|
||||
OptionalSnowflakeSchema,
|
||||
WelcomeConfigDashboardPatchSchema
|
||||
} from './dashboard.js';
|
||||
|
||||
describe('dashboard schemas', () => {
|
||||
it('accepts moderation patches with escalations', () => {
|
||||
const parsed = ModerationDashboardPatchSchema.parse({
|
||||
moderationEnabled: true,
|
||||
escalations: [{ warnCount: 3, action: 'TIMEOUT', durationMs: 60_000, enabled: true }]
|
||||
});
|
||||
expect(parsed.escalations?.[0]?.action).toBe('TIMEOUT');
|
||||
});
|
||||
|
||||
it('rejects empty moderation patches', () => {
|
||||
expect(() => ModerationDashboardPatchSchema.parse({})).toThrow();
|
||||
});
|
||||
|
||||
it('validates automod patches', () => {
|
||||
const parsed = AutomodConfigDashboardPatchSchema.parse({
|
||||
antiRaidEnabled: true,
|
||||
antiRaidJoinThreshold: 15
|
||||
});
|
||||
expect(parsed.antiRaidJoinThreshold).toBe(15);
|
||||
});
|
||||
|
||||
it('validates logging patches with channel mappings', () => {
|
||||
const parsed = LoggingConfigDashboardPatchSchema.parse({
|
||||
logChannels: [{ eventType: 'MEMBER_JOIN', channelId: '123456789012345678' }]
|
||||
});
|
||||
expect(parsed.logChannels?.[0]?.eventType).toBe('MEMBER_JOIN');
|
||||
});
|
||||
|
||||
it('rejects invalid log channel ids', () => {
|
||||
expect(() =>
|
||||
LoggingConfigDashboardPatchSchema.parse({
|
||||
logChannels: [{ eventType: 'MEMBER_JOIN', channelId: 'not-a-snowflake' }]
|
||||
})
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it('accepts empty string or a valid snowflake as optional id', () => {
|
||||
expect(OptionalSnowflakeSchema.parse('')).toBe('');
|
||||
expect(OptionalSnowflakeSchema.parse('123456789012345678')).toBe('123456789012345678');
|
||||
expect(() => OptionalSnowflakeSchema.parse('abc')).toThrow();
|
||||
});
|
||||
|
||||
it('validates welcome patches', () => {
|
||||
const parsed = WelcomeConfigDashboardPatchSchema.parse({
|
||||
welcomeEnabled: true,
|
||||
welcomeChannelId: '123456789012345678'
|
||||
});
|
||||
expect(parsed.welcomeEnabled).toBe(true);
|
||||
});
|
||||
|
||||
it('validates economy patches', () => {
|
||||
const parsed = EconomyConfigDashboardPatchSchema.parse({ currencyName: 'Gems', dailyAmount: 100 });
|
||||
expect(parsed.currencyName).toBe('Gems');
|
||||
});
|
||||
|
||||
it('validates fun config', () => {
|
||||
const parsed = FunConfigDashboardSchema.parse({ enabled: true, mediaEnabled: false });
|
||||
expect(parsed.mediaEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it('applies default limit for case list queries', () => {
|
||||
const parsed = CaseListQuerySchema.parse({});
|
||||
expect(parsed.limit).toBe(25);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user