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.

normalizedPartnerDateFields

Steven Tey6b00a4ab7402
diff --git a/apps/web/tests/partners/create-partner.test.ts b/apps/web/tests/partners/create-partner.test.ts
index 68fb442e16..ca4c33dc23 100644
--- a/apps/web/tests/partners/create-partner.test.ts
+++ b/apps/web/tests/partners/create-partner.test.ts
@@ -1,5 +1,4 @@
import { generateRandomName } from "@/lib/names";
-import z from "@/lib/zod";
import { EnrolledPartnerSchema as EnrolledPartnerSchemaDate } from "@/lib/zod/schemas/partners";
import { Link, Partner } from "@dub/prisma/client";
import { R2_URL } from "@dub/utils";
@@ -7,11 +6,11 @@ import { describe, expect, test } from "vitest";
import { randomEmail, randomId } from "../utils/helpers";
import { IntegrationHarness } from "../utils/integration";
import { E2E_PROGRAM } from "../utils/resource";
+import { normalizedPartnerDateFields } from "./resource";
-const EnrolledPartnerSchema = EnrolledPartnerSchemaDate.extend({
- payoutsEnabledAt: z.string().nullable(),
- createdAt: z.string(),
-});
+const EnrolledPartnerSchema = EnrolledPartnerSchemaDate.merge(
+ normalizedPartnerDateFields,
+);
describe.sequential("POST /partners", async () => {
const h = new IntegrationHarness();
diff --git a/apps/web/tests/partners/list-partners.test.ts b/apps/web/tests/partners/list-partners.test.ts
index f7356549db..2cdc88f3f5 100644
--- a/apps/web/tests/partners/list-partners.test.ts
+++ b/apps/web/tests/partners/list-partners.test.ts
@@ -1,5 +1,4 @@
import { EnrolledPartnerProps } from "@/lib/types";
-import z from "@/lib/zod";
import {
EnrolledPartnerBasicSchema as EnrolledPartnerBasicSchemaDate,
EnrolledPartnerSchema as EnrolledPartnerSchemaDate,
@@ -7,16 +6,15 @@ import {
import { describe, expect, test } from "vitest";
import { IntegrationHarness } from "../utils/integration";
import { E2E_PARTNER, E2E_PROGRAM } from "../utils/resource";
+import { normalizedPartnerDateFields } from "./resource";
// type coercion for date fields
-const EnrolledPartnerBasicSchema = EnrolledPartnerBasicSchemaDate.extend({
- payoutsEnabledAt: z.string().nullable(),
- createdAt: z.string(),
-});
-const EnrolledPartnerSchema = EnrolledPartnerSchemaDate.extend({
- payoutsEnabledAt: z.string().nullable(),
- createdAt: z.string(),
-});
+const EnrolledPartnerBasicSchema = EnrolledPartnerBasicSchemaDate.merge(
+ normalizedPartnerDateFields,
+);
+const EnrolledPartnerSchema = EnrolledPartnerSchemaDate.merge(
+ normalizedPartnerDateFields,
+);
describe.sequential("GET /partners", async () => {
const h = new IntegrationHarness();
diff --git a/apps/web/tests/partners/resource.ts b/apps/web/tests/partners/resource.ts
index b94822501d..5bb6926c8d 100644
--- a/apps/web/tests/partners/resource.ts
+++ b/apps/web/tests/partners/resource.ts
@@ -1,4 +1,5 @@
import { normalizeWorkspaceId } from "@/lib/api/workspace-id";
+import z from "@/lib/zod";
import { expect } from "vitest";
import {
E2E_PARTNER,
@@ -22,3 +23,14 @@ export const partnerLink = {
folderId: expect.any(String),
qrCode: expect.any(String),
};
+
+export const normalizedPartnerDateFields = z.object({
+ createdAt: z.string(),
+ payoutsEnabledAt: z.string().nullish(),
+ websiteVerifiedAt: z.string().nullish(),
+ youtubeVerifiedAt: z.string().nullish(),
+ twitterVerifiedAt: z.string().nullish(),
+ linkedinVerifiedAt: z.string().nullish(),
+ instagramVerifiedAt: z.string().nullish(),
+ tiktokVerifiedAt: z.string().nullish(),
+});