feat(dashboard): align contracts and production build
This commit is contained in:
1 parent
69d560d5c5
commit
d6d29badcd
9 files changed
+189
-48
No files matched your search
@@ -6,6 +6,10 @@ export const ErrorResponseSchema = z.strictObject({
|
||||
});
|
||||
|
||||
export const SuccessResponseSchema = z.strictObject({ success: z.literal(true) });
|
||||
export const ControlResponseSchema = z.strictObject({
|
||||
success: z.literal(true),
|
||||
running: z.boolean(),
|
||||
});
|
||||
export const RejectedActionResponseSchema = z.strictObject({
|
||||
success: z.literal(false),
|
||||
reason: z.string(),
|
||||
@@ -13,3 +17,4 @@ export const RejectedActionResponseSchema = z.strictObject({
|
||||
|
||||
export type ErrorResponse = z.infer<typeof ErrorResponseSchema>;
|
||||
export type SuccessResponse = z.infer<typeof SuccessResponseSchema>;
|
||||
export type ControlResponse = z.infer<typeof ControlResponseSchema>;
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
ChatSyncTriggerResponseSchema,
|
||||
ConfigResponseSchema,
|
||||
ConfigUpdateRequestSchema,
|
||||
ControlResponseSchema,
|
||||
ConversationDetailResponseSchema,
|
||||
ConversationsResponseSchema,
|
||||
DashboardEventSchema,
|
||||
@@ -62,6 +63,13 @@ describe('dashboard endpoint contracts', () => {
|
||||
expect(StatsResponseSchema.safeParse({ ...payload, isRunning: 'yes' }).success).toBe(false);
|
||||
});
|
||||
|
||||
it('validates authoritative start and stop responses', () => {
|
||||
expect(ControlResponseSchema.safeParse({ success: true, running: true }).success).toBe(true);
|
||||
expect(ControlResponseSchema.safeParse({ success: true, running: false }).success).toBe(true);
|
||||
expect(ControlResponseSchema.safeParse({ success: true }).success).toBe(false);
|
||||
expect(ControlResponseSchema.safeParse({ success: false, running: true }).success).toBe(false);
|
||||
});
|
||||
|
||||
it('validates timer, activity, message, and successful-example payloads', () => {
|
||||
expect(TimersResponseSchema.safeParse({
|
||||
nextMessageAvailableAt: null,
|
||||
|
||||
Reference in new issue
Block a user