- Added new models for DashboardAccessRule and DashboardAuditLog to the Prisma schema, improving access control and logging capabilities. - Updated GuildSettings model to include timezone support. - Revised PHASE-TRACKING.md to reflect the completion of Phase 5 and outline upcoming Phase 6 features, including dashboard layout and settings framework. - Exported new phase 6 features in shared index for better modularity.
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
GuildGeneralSettingsPatchSchema,
|
|
ModulesUpdateSchema,
|
|
hasManageGuildPermission,
|
|
DashboardAccessRulesUpdateSchema
|
|
} from './phase6.js';
|
|
|
|
describe('phase6 schemas', () => {
|
|
it('accepts general settings patches', () => {
|
|
const parsed = GuildGeneralSettingsPatchSchema.parse({
|
|
locale: 'en',
|
|
timezone: 'UTC'
|
|
});
|
|
expect(parsed.locale).toBe('en');
|
|
expect(parsed.timezone).toBe('UTC');
|
|
});
|
|
|
|
it('rejects empty general settings patches', () => {
|
|
expect(() => GuildGeneralSettingsPatchSchema.parse({})).toThrow();
|
|
});
|
|
|
|
it('validates module updates', () => {
|
|
const parsed = ModulesUpdateSchema.parse({
|
|
modules: { moderation: true, automod: false }
|
|
});
|
|
expect(parsed.modules.moderation).toBe(true);
|
|
expect(parsed.modules.automod).toBe(false);
|
|
});
|
|
|
|
it('detects manage guild permission', () => {
|
|
expect(hasManageGuildPermission('32')).toBe(true);
|
|
expect(hasManageGuildPermission('0')).toBe(false);
|
|
expect(hasManageGuildPermission(String(32n | 8n))).toBe(true);
|
|
});
|
|
|
|
it('validates access rules', () => {
|
|
const parsed = DashboardAccessRulesUpdateSchema.parse({
|
|
rules: [{ roleId: '123456789012345678', modules: 'all' }]
|
|
});
|
|
expect(parsed.rules).toHaveLength(1);
|
|
});
|
|
});
|