The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update URLs in create-link, retrieve-link, and bulk-create-link tests
Kiran Kf2094410fefd
diff --git a/apps/web/tests/links/bulk-create-link.test.ts b/apps/web/tests/links/bulk-create-link.test.tsindex f643045113..0cc6180ec1 100644--- a/apps/web/tests/links/bulk-create-link.test.ts+++ b/apps/web/tests/links/bulk-create-link.test.ts@@ -1,6 +1,6 @@-import { nanoid } from "@dub/utils";import { Link } from "@prisma/client";import { expect, test } from "vitest";+import { randomId } from "../utils/helpers";import { IntegrationHarness } from "../utils/integration";test("POST /links/bulk", async (ctx) => {@@ -9,7 +9,7 @@ test("POST /links/bulk", async (ctx) => {const { workspaceId } = workspace;const bulkLinks = Array.from({ length: 2 }, () => ({- url: `https://example.com/${nanoid()}`,+ url: `https://example.com/${randomId()}`,}));const { status, data: links } = await http.post<Link>({diff --git a/apps/web/tests/links/create-link.test.ts b/apps/web/tests/links/create-link.test.tsindex a8b8531127..983b2dcf19 100644--- a/apps/web/tests/links/create-link.test.ts+++ b/apps/web/tests/links/create-link.test.ts@@ -1,6 +1,6 @@-import { nanoid } from "@dub/utils";import { Link, Tag } from "@prisma/client";import { describe, expect, test } from "vitest";+import { randomId } from "../utils/helpers";import { IntegrationHarness } from "../utils/integration";import { link } from "../utils/resource";import { expectedLink } from "../utils/schema";@@ -22,6 +22,7 @@ describe("POST /links", async () => {publicStats: true,comments: "This is a test",rewrite: true,+ domain,},});@@ -44,7 +45,7 @@ describe("POST /links", async () => {});test("user defined key", async () => {- const key = nanoid(6);+ const key = randomId();const { status, data: link } = await http.post<Link>({path: "/links",@@ -52,6 +53,7 @@ describe("POST /links", async () => {body: {url,key,+ domain,},});@@ -122,6 +124,7 @@ describe("POST /links", async () => {query: { workspaceId },body: {url: longUrl.href,+ domain,},});@@ -149,6 +152,7 @@ describe("POST /links", async () => {query: { workspaceId },body: {url,+ domain,password,},});@@ -178,6 +182,7 @@ describe("POST /links", async () => {query: { workspaceId },body: {url,+ domain,expiresAt,expiredUrl,},@@ -187,7 +192,7 @@ describe("POST /links", async () => {expect(link).toStrictEqual({...expectedLink,url,- expiresAt: "2030-04-16T11:30:00.000Z",+ expiresAt: "2030-04-16T17:00:00.000Z",expiredUrl,userId: user.id,projectId,@@ -210,6 +215,7 @@ describe("POST /links", async () => {query: { workspaceId },body: {url,+ domain,ios,android,},@@ -244,6 +250,7 @@ describe("POST /links", async () => {query: { workspaceId },body: {url,+ domain,geo,},});@@ -266,8 +273,8 @@ describe("POST /links", async () => {test("tags", async () => {const tagsToCreate = [- { tag: nanoid(6), color: "red" },- { tag: nanoid(6), color: "green" },+ { tag: randomId(), color: "red" },+ { tag: randomId(), color: "green" },];const response = await Promise.all(@@ -294,6 +301,7 @@ describe("POST /links", async () => {query: { workspaceId },body: {url,+ domain,tagIds,},});@@ -327,6 +335,7 @@ describe("POST /links", async () => {query: { workspaceId },body: {url,+ domain,title,description,},diff --git a/apps/web/tests/links/list-links.test.ts b/apps/web/tests/links/list-links.test.tsindex 443fcb1c17..20c0d3294f 100644--- a/apps/web/tests/links/list-links.test.ts+++ b/apps/web/tests/links/list-links.test.ts@@ -41,7 +41,7 @@ test("GET /links", async (ctx) => {emailVerified: null,source: null,subscribed: true,- image: expect.any(String),+ image: null,name: expect.any(String),createdAt: expect.any(String),email: expect.any(String),diff --git a/apps/web/tests/links/retrieve-link.test.ts b/apps/web/tests/links/retrieve-link.test.tsindex 00f46816c0..13901be728 100644--- a/apps/web/tests/links/retrieve-link.test.ts+++ b/apps/web/tests/links/retrieve-link.test.ts@@ -1,7 +1,7 @@-import { nanoid } from "@dub/utils";import { Link } from "@prisma/client";import { expectedLink } from "tests/utils/schema";import { expect, test } from "vitest";+import { randomId } from "../utils/helpers";import { IntegrationHarness } from "../utils/integration";import { link } from "../utils/resource";@@ -16,7 +16,7 @@ test("GET /links/info", async (ctx) => {const newLink: Partial<Link> = {url,domain,- key: nanoid(6),+ key: randomId(),archived: true,publicStats: true,comments: "This is a test",diff --git a/apps/web/tests/links/update-link.test.ts b/apps/web/tests/links/update-link.test.tsindex 2895e58c06..e6d0b0dccf 100644--- a/apps/web/tests/links/update-link.test.ts+++ b/apps/web/tests/links/update-link.test.ts@@ -1,6 +1,6 @@-import { nanoid } from "@dub/utils";import { Link } from "@prisma/client";import { describe, expect, test } from "vitest";+import { randomId } from "../utils/helpers";import { IntegrationHarness } from "../utils/integration";import { link } from "../utils/resource";import { expectedLink } from "../utils/schema";@@ -25,7 +25,7 @@ describe("PUT /links/{linkId}", async () => {});const newLink: Partial<Link> = {- key: nanoid(),+ key: randomId(),url: "https://github.com/dubinc/dub",title: "Dub Inc",description: "Open-source link management infrastructure.",diff --git a/apps/web/tests/utils/helpers.ts b/apps/web/tests/utils/helpers.tsindex e573a55771..6e782f940f 100644--- a/apps/web/tests/utils/helpers.ts+++ b/apps/web/tests/utils/helpers.ts@@ -1 +1 @@-export const randomId = () => Math.random().toString(36).substr(2, 9);\ No newline at end of file+export const randomId = () => Math.random().toString(36).substr(2, 9);