The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Discounts tests
Kiran K93225d1c72bd
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.tsindex 3d43a70686..de482cd4c4 100644--- a/apps/web/lib/types.ts+++ b/apps/web/lib/types.ts@@ -27,6 +27,7 @@ import { clickEventResponseSchema } from "./zod/schemas/clicks";import {customerActivityResponseSchema,customerActivitySchema,+ CustomerEnrichedSchema,CustomerSchema,} from "./zod/schemas/customers";import { dashboardSchema } from "./zod/schemas/dashboard";@@ -353,6 +354,8 @@ export type TrackSaleResponse = z.infer<typeof trackSaleResponseSchema>;export type Customer = z.infer<typeof CustomerSchema>;+export type CustomerEnriched = z.infer<typeof CustomerEnrichedSchema>;+export type UsageResponse = z.infer<typeof usageResponse>;export type PartnersCount = Record<ProgramEnrollmentStatus | "all", number>;diff --git a/apps/web/tests/discounts/index.test.ts b/apps/web/tests/discounts/index.test.tsnew file mode 100644index 0000000000..bbb236c822--- /dev/null+++ b/apps/web/tests/discounts/index.test.ts@@ -0,0 +1,38 @@+import { CustomerEnriched } from "@/lib/types";+import {+ E2E_CUSTOMER_EXTERNAL_ID,+ E2E_CUSTOMER_ID,+ E2E_DISCOUNT,+} from "tests/utils/resource";+import { describe, expect, test } from "vitest";+import { IntegrationHarness } from "../utils/integration";++describe("Discounts", () => {+ test("/customers?externalId=", async () => {+ const h = new IntegrationHarness();+ const { http } = await h.init();++ const { status, data: customers } = await http.get<CustomerEnriched[]>({+ path: `/customers?externalId=${E2E_CUSTOMER_EXTERNAL_ID}&includeExpandedFields=true`,+ });++ expect(status).toEqual(200);+ expect(customers[0].discount).toStrictEqual({+ ...E2E_DISCOUNT,+ duration: null,+ interval: null,+ });+ });++ test("/customers/:id", async () => {+ const h = new IntegrationHarness();+ const { http } = await h.init();++ const { status, data: customer } = await http.get<CustomerEnriched>({+ path: `/customers/${E2E_CUSTOMER_ID}?includeExpandedFields=true`,+ });++ expect(status).toEqual(200);+ expect(customer.discount).toStrictEqual(E2E_DISCOUNT);+ });+});diff --git a/apps/web/tests/utils/resource.ts b/apps/web/tests/utils/resource.tsindex b8376834d5..75bb865f8d 100644--- a/apps/web/tests/utils/resource.ts+++ b/apps/web/tests/utils/resource.ts@@ -27,6 +27,14 @@ export const E2E_WEBHOOK_ID = "wh_MHR7sZXXtZ7keBaNYZ30rQ0v";export const E2E_WRITE_ACCESS_FOLDER_ID = "fold_stp7lRJOs7RLKlaVcTVPS74P"; // Folder with write accessexport const E2E_READ_ONLY_FOLDER_ID = "fold_0lo6YZoVBvAyFg62SKTgDXTT"; // Folder with read-only accessexport const E2E_NO_ACCESS_FOLDER_ID = "fold_zRbQG7RSPEWZS71MxJNCIF2m"; // Folder with no access-export const E2E_READ_ONLY_FOLDER_LINK_ID = "link_SbITAiOfL7toD2NpI7IoP0m6"; // A link in read-only folderexport const E2E_NO_ACCESS_FOLDER_LINK_ID = "link_SeHtHzjuiOOAPCDLAvTNEKXm"; // A link in no access folder++export const E2E_DISCOUNT = {+ id: "disc_1JNSF8QPX3N964DB7JSCFR4K6",+ amount: 20,+ type: "percentage",+ maxDuration: 3,+ couponId: "XZuejd0Q",+ couponTestId: "2NMXz81x",+};