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.

update the tests

Kiran Ke848fdb659aa
diff --git a/apps/web/tests/links/create-link.test.ts b/apps/web/tests/links/create-link.test.ts
index 619c3e0bd7..2e4b898948 100644
--- a/apps/web/tests/links/create-link.test.ts
+++ b/apps/web/tests/links/create-link.test.ts
@@ -465,6 +465,44 @@ describe.sequential("POST /links", async () => {
});
expect(LinkSchema.strict().parse(link)).toBeTruthy();
});
+
+ test("ab testing", async () => {
+ const testVariants = [
+ { url: "https://example.com/variant-1", percentage: 30 },
+ { url: "https://example.com/variant-2", percentage: 30 },
+ { url: "https://example.com/variant-3", percentage: 40 },
+ ];
+
+ const testStartedAt = new Date();
+ const testCompletedAt = new Date(Date.now() + 1000 * 60 * 60 * 24); // 1 day
+
+ const { status, data: link } = await http.post<Link>({
+ path: "/links",
+ body: {
+ url,
+ domain,
+ trackConversion: true,
+ testVariants,
+ testStartedAt,
+ testCompletedAt,
+ },
+ });
+
+ expect(status).toEqual(200);
+ expect(link).toStrictEqual({
+ ...expectedLink,
+ url,
+ projectId,
+ workspaceId,
+ userId: user.id,
+ testVariants,
+ testStartedAt: testStartedAt.toISOString(),
+ testCompletedAt: testCompletedAt.toISOString(),
+ trackConversion: true,
+ shortLink: `https://${domain}/${link.key}`,
+ qrCode: `https://api.dub.co/qr?url=https://${domain}/${link.key}?qr=1`,
+ });
+ });
});
describe.sequential("POST /links?workspaceId=xxx", async () => {
diff --git a/apps/web/tests/utils/schema.ts b/apps/web/tests/utils/schema.ts
index 8efda2f8b4..2cb8546415 100644
--- a/apps/web/tests/utils/schema.ts
+++ b/apps/web/tests/utils/schema.ts
@@ -55,6 +55,9 @@ export const expectedLink: Partial<Link> & {
programId: null,
partnerId: null,
folderId: null,
+ testCompletedAt: null,
+ testStartedAt: null,
+ testVariants: null,
};
export const expectedTag: Partial<Tag> = {