Fix ticket category saving and synchronization error handling

- Updated the ticket category saving logic to handle empty description and emoji fields, ensuring they are set to null if trimmed.
- Enhanced error handling in the `maybeSyncTicketPanel` function to prevent UI errors when synchronization fails, allowing category CRUD operations to succeed.
- Updated the response handling to include support role IDs in the UI after saving, improving data consistency.
- Added validation for support role IDs in the dashboard schemas to ensure correct data types are used.
This commit is contained in:
TheOnlyMace
2026-07-25 16:24:18 +02:00
parent 5c11b68fc0
commit b5bf214d7f
5 changed files with 51 additions and 5 deletions

View File

@@ -15,6 +15,7 @@ import {
SuggestionActionSchema,
TagDashboardCreateSchema,
TicketCategoryDashboardCreateSchema,
TicketCategoryDashboardUpdateSchema,
TicketConfigDashboardPatchSchema,
WelcomeConfigDashboardPatchSchema
} from './dashboard.js';
@@ -99,6 +100,22 @@ describe('dashboard schemas', () => {
expect(parsed.supportRoleIds).toHaveLength(1);
});
it('validates ticket category update with support roles', () => {
const parsed = TicketCategoryDashboardUpdateSchema.parse({
supportRoleIds: ['123456789012345678', '234567890123456789']
});
expect(parsed.supportRoleIds).toEqual(['123456789012345678', '234567890123456789']);
});
it('rejects invalid support role ids on ticket category create', () => {
expect(() =>
TicketCategoryDashboardCreateSchema.parse({
name: 'Support',
supportRoleIds: ['not-a-snowflake']
})
).toThrow();
});
it('validates giveaway creation input', () => {
const parsed = GiveawayCreateDashboardSchema.parse({
channelId: '123456789012345678',