Implement Phase 7 features and enhance dashboard schemas
- Updated PHASE-TRACKING.md to reflect the completion of Batch A features, including the implementation of dashboard pages and API routes for various modules. - Added new Prisma models and migration for owner features, including CommandOverride and GlobalUserBlacklist. - Expanded dashboard schemas in dashboard.ts to include Ticket, Giveaway, Self Role, Tag, and Starboard configurations, along with their respective validation tests in dashboard.test.ts. - Enhanced localization files with new i18n keys for the added modules and features. - Verified successful builds and tests across multiple packages, ensuring stability and functionality of new features.
This commit is contained in:
@@ -4,9 +4,18 @@ import {
|
||||
CaseListQuerySchema,
|
||||
EconomyConfigDashboardPatchSchema,
|
||||
FunConfigDashboardSchema,
|
||||
GiveawayCreateDashboardSchema,
|
||||
LoggingConfigDashboardPatchSchema,
|
||||
ModerationDashboardPatchSchema,
|
||||
OptionalSnowflakeSchema,
|
||||
ScheduledMessageDashboardCreateSchema,
|
||||
SelfRolePanelDashboardCreateSchema,
|
||||
SocialFeedDashboardCreateSchema,
|
||||
StarboardConfigDashboardPatchSchema,
|
||||
SuggestionActionSchema,
|
||||
TagDashboardCreateSchema,
|
||||
TicketCategoryDashboardCreateSchema,
|
||||
TicketConfigDashboardPatchSchema,
|
||||
WelcomeConfigDashboardPatchSchema
|
||||
} from './dashboard.js';
|
||||
|
||||
@@ -74,4 +83,98 @@ describe('dashboard schemas', () => {
|
||||
const parsed = CaseListQuerySchema.parse({});
|
||||
expect(parsed.limit).toBe(25);
|
||||
});
|
||||
|
||||
it('validates ticket config patches', () => {
|
||||
const parsed = TicketConfigDashboardPatchSchema.parse({ mode: 'THREAD', inactivityHours: 24 });
|
||||
expect(parsed.mode).toBe('THREAD');
|
||||
});
|
||||
|
||||
it('validates ticket category creation', () => {
|
||||
const parsed = TicketCategoryDashboardCreateSchema.parse({
|
||||
name: 'Support',
|
||||
description: null,
|
||||
emoji: '🎫',
|
||||
supportRoleIds: ['123456789012345678']
|
||||
});
|
||||
expect(parsed.supportRoleIds).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('validates giveaway creation input', () => {
|
||||
const parsed = GiveawayCreateDashboardSchema.parse({
|
||||
channelId: '123456789012345678',
|
||||
prize: 'Nitro',
|
||||
winnerCount: 1,
|
||||
endsAt: new Date(Date.now() + 60_000).toISOString()
|
||||
});
|
||||
expect(parsed.prize).toBe('Nitro');
|
||||
});
|
||||
|
||||
it('rejects giveaway creation with invalid date', () => {
|
||||
expect(() =>
|
||||
GiveawayCreateDashboardSchema.parse({
|
||||
channelId: '123456789012345678',
|
||||
prize: 'Nitro',
|
||||
winnerCount: 1,
|
||||
endsAt: 'not-a-date'
|
||||
})
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it('validates self role panel creation', () => {
|
||||
const parsed = SelfRolePanelDashboardCreateSchema.parse({
|
||||
channelId: '123456789012345678',
|
||||
title: 'Colors',
|
||||
mode: 'BUTTONS',
|
||||
behavior: 'NORMAL',
|
||||
roles: [{ roleId: '123456789012345678', label: 'Red' }]
|
||||
});
|
||||
expect(parsed.roles).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('validates tag creation', () => {
|
||||
const parsed = TagDashboardCreateSchema.parse({
|
||||
name: 'rules',
|
||||
content: 'Please read the rules',
|
||||
responseType: 'TEXT',
|
||||
allowedRoleIds: [],
|
||||
allowedChannelIds: []
|
||||
});
|
||||
expect(parsed.name).toBe('rules');
|
||||
});
|
||||
|
||||
it('validates starboard patches', () => {
|
||||
const parsed = StarboardConfigDashboardPatchSchema.parse({ threshold: 5 });
|
||||
expect(parsed.threshold).toBe(5);
|
||||
});
|
||||
|
||||
it('validates suggestion staff actions', () => {
|
||||
const parsed = SuggestionActionSchema.parse({ status: 'APPROVED', staffReason: 'Great idea' });
|
||||
expect(parsed.status).toBe('APPROVED');
|
||||
});
|
||||
|
||||
it('validates social feed creation', () => {
|
||||
const parsed = SocialFeedDashboardCreateSchema.parse({
|
||||
type: 'TWITCH',
|
||||
sourceId: 'somechannel',
|
||||
channelId: '123456789012345678',
|
||||
enabled: true
|
||||
});
|
||||
expect(parsed.type).toBe('TWITCH');
|
||||
});
|
||||
|
||||
it('validates scheduled message creation requires cron or runAt', () => {
|
||||
expect(() =>
|
||||
ScheduledMessageDashboardCreateSchema.parse({
|
||||
channelId: '123456789012345678',
|
||||
content: 'Hello'
|
||||
})
|
||||
).toThrow();
|
||||
|
||||
const parsed = ScheduledMessageDashboardCreateSchema.parse({
|
||||
channelId: '123456789012345678',
|
||||
content: 'Hello',
|
||||
runAt: new Date(Date.now() + 60_000).toISOString()
|
||||
});
|
||||
expect(parsed.content).toBe('Hello');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user