Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add tests for `/analytics?event=composite`

Kiran Ka4e5be8a5d59
diff --git a/apps/web/tests/analytics/composite.test.ts b/apps/web/tests/analytics/composite.test.ts
new file mode 100644
index 0000000000..bfcc4c8dc5
--- /dev/null
+++ b/apps/web/tests/analytics/composite.test.ts
@@ -0,0 +1,31 @@
+import { VALID_ANALYTICS_ENDPOINTS } from "@/lib/analytics/constants";
+import z from "@/lib/zod";
+import { compositeAnalyticsResponse } from "@/lib/zod/schemas/composite-analytics";
+import { describe, expect, test } from "vitest";
+import { IntegrationHarness } from "../utils/integration";
+import { filter } from "./utils";
+
+describe.sequential("GET /analytics?event=composite", async () => {
+ const h = new IntegrationHarness();
+ const { workspace, http } = await h.init();
+ const { workspaceId } = workspace;
+
+ VALID_ANALYTICS_ENDPOINTS.map((groupBy) => {
+ test(`by ${groupBy}`, async () => {
+ const { status, data } = await http.get<any[]>({
+ path: `/analytics`,
+ query: { event: "composite", groupBy, workspaceId, ...filter },
+ });
+
+ const responseSchema =
+ groupBy === "count"
+ ? compositeAnalyticsResponse[groupBy].strict()
+ : z.array(compositeAnalyticsResponse[groupBy].strict());
+
+ const parsed = responseSchema.safeParse(data);
+
+ expect(status).toEqual(200);
+ expect(parsed.success).toBeTruthy();
+ });
+ });
+});