feat(dashboard): close legacy parity gaps

This commit is contained in:
jjbrunton committed 2026-08-08 15:41:34 +01:00
1 parent 92287c0a9a
commit 4b3f00729f
21 files changed
+397 -28

No files matched your search

+15
View File
@@ -18,6 +18,20 @@ export const SentMessageSchema = z.strictObject({
});
export const MessagesResponseSchema = z.array(SentMessageSchema);
export const ProcessedPostSchema = z.strictObject({
id: z.string(),
subreddit: z.string(),
author: z.string(),
title: z.string(),
imageUrl: z.string().nullable(),
imageAnalysis: z.string().nullable(),
generatedMessage: z.string().nullable(),
processedAt: z.number(),
messageSent: z.boolean(),
error: z.string().nullable(),
});
export const ProcessedPostsResponseSchema = z.array(ProcessedPostSchema);
export const SuccessfulExampleSchema = z.strictObject({
id: z.number(),
sentMessageId: z.number().nullable(),
@@ -31,4 +45,5 @@ export const SuccessfulExampleSchema = z.strictObject({
export const SuccessfulExamplesResponseSchema = z.array(SuccessfulExampleSchema);
export type SentMessage = z.infer<typeof SentMessageSchema>;
export type ProcessedPost = z.infer<typeof ProcessedPostSchema>;
export type SuccessfulExample = z.infer<typeof SuccessfulExampleSchema>;
@@ -17,6 +17,7 @@ import {
MediaResponseSchema,
MediaSyncStatusSchema,
MessagesResponseSchema,
ProcessedPostsResponseSchema,
StatsResponseSchema,
StrategyPerformanceResponseSchema,
SubredditPerformanceResponseSchema,
@@ -103,6 +104,13 @@ describe('dashboard endpoint contracts', () => {
expect(TimersResponseSchema.safeParse({ hourlyResetAt: 'later' }).success).toBe(false);
expect(ActivityResponseSchema.safeParse([{ ...activity, type: 'bogus' }]).success).toBe(false);
expect(MessagesResponseSchema.safeParse([{ id: '1' }]).success).toBe(false);
const processedPost = {
id: 'post-1', subreddit: 'example', author: 'alice', title: 'Example',
imageUrl: null, imageAnalysis: null, generatedMessage: 'Hello',
processedAt: 1_700_000_000_000, messageSent: true, error: null,
};
expect(ProcessedPostsResponseSchema.safeParse([processedPost]).success).toBe(true);
expect(ProcessedPostsResponseSchema.safeParse([{ ...processedPost, messageSent: 'yes' }]).success).toBe(false);
});
it('validates each analytics response shape', () => {