The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
update tests
Steven Tey1996a8d5ca6a
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/people/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/people/page-client.tsxindex 969d052329..80d3b157cf 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/people/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/people/page-client.tsx@@ -7,12 +7,17 @@ import { useEditRoleModal } from "@/ui/modals/edit-role-modal";import { useInviteCodeModal } from "@/ui/modals/invite-code-modal";import { useInviteTeammateModal } from "@/ui/modals/invite-teammate-modal";import { useRemoveTeammateModal } from "@/ui/modals/remove-teammate-modal";-import { Link as LinkIcon, ThreeDots } from "@/ui/shared/icons";-import { Avatar, Badge, Button, IconMenu, Popover } from "@dub/ui";+import {+ CheckCircleFill,+ Link as LinkIcon,+ ThreeDots,+} from "@/ui/shared/icons";+import { Avatar, Badge, Button, Copy, IconMenu, Popover } from "@dub/ui";import { cn, timeAgo } from "@dub/utils";import { UserMinus } from "lucide-react";import { useSession } from "next-auth/react";import { useState } from "react";+import { toast } from "sonner";const tabs: Array<"Members" | "Invitations"> = ["Members", "Invitations"];@@ -139,6 +144,15 @@ const UserCard = ({createdAt &&Date.now() - new Date(createdAt).getTime() > 14 * 24 * 60 * 60 * 1000;+ const [copiedUserId, setCopiedUserId] = useState(false);++ const copyUserId = () => {+ navigator.clipboard.writeText(id);+ setCopiedUserId(true);+ toast.success("User ID copied!");+ setTimeout(() => setCopiedUserId(false), 3000);+ };+return (<><EditRoleModal />@@ -193,6 +207,19 @@ const UserCard = ({<Popovercontent={<div className="grid w-full gap-1 p-2 sm:w-48">+ <Button+ text="Copy User ID"+ variant="outline"+ onClick={() => copyUserId()}+ icon={+ copiedUserId ? (+ <CheckCircleFill className="h-4 w-4" />+ ) : (+ <Copy className="h-4 w-4" />+ )+ }+ className="h-9 justify-start px-2 font-medium"+ /><buttononClick={() => {setOpenPopover(false);diff --git a/apps/web/tests/domains/index.test.ts b/apps/web/tests/domains/index.test.tsindex 3143a9721e..8da269b2d7 100644--- a/apps/web/tests/domains/index.test.ts+++ b/apps/web/tests/domains/index.test.ts@@ -42,26 +42,6 @@ describe.sequential("/domains/**", async () => {expect(domain).toStrictEqual(expectedDomain);});- test("GET /domains/{slug}/exists", async () => {- // A domain exists (We just created it, so it should exist)- const { status, data } = await http.get({- path: `/domains/${domainRecord.slug}/exists`,- query: { workspaceId: workspace.id },- });-- expect(status).toEqual(200);- expect(data).toEqual(1);-- // A domain does not exist- const { status: status2, data: data2 } = await http.get({- path: `/domains/random.com/exists`,- query: { workspaceId: workspace.id },- });-- expect(status2).toEqual(200);- expect(data2).toEqual(0);- });-test("GET /domains/{slug}", async () => {const { status, data: domain } = await http.get<Domain>({path: `/domains/${domainRecord.slug}`,diff --git a/apps/web/tests/links/bulk-create-link.test.ts b/apps/web/tests/links/bulk-create-link.test.tsindex 5ed995448c..afd93c3555 100644--- a/apps/web/tests/links/bulk-create-link.test.ts+++ b/apps/web/tests/links/bulk-create-link.test.ts@@ -12,7 +12,7 @@ const { domain } = link;test("POST /links/bulk", async (ctx) => {const h = new IntegrationHarness(ctx);const { workspace, http, user } = await h.init();- const { workspaceId } = workspace;+ const workspaceId = workspace.id;const projectId = workspaceId.replace("ws_", "");const bulkLinks = Array.from({ length: 2 }, () => ({@@ -22,7 +22,6 @@ test("POST /links/bulk", async (ctx) => {const { status, data: links } = await http.post<Link[]>({path: "/links/bulk",- query: { workspaceId },body: bulkLinks,});diff --git a/apps/web/tests/links/count-links.test.ts b/apps/web/tests/links/count-links.test.tsindex 067e5871d9..3d0a3be01c 100644--- a/apps/web/tests/links/count-links.test.ts+++ b/apps/web/tests/links/count-links.test.ts@@ -7,20 +7,17 @@ const { domain, url } = link;test("GET /links/count", async (ctx) => {const h = new IntegrationHarness(ctx);- const { workspace, http } = await h.init();- const { workspaceId } = workspace;+ const { http } = await h.init();const [{ data: firstLink }] = await Promise.all([http.post<Link>({path: "/links",- query: { workspaceId },body: { url, domain },}),]);const { status, data: count } = await http.get<Link[]>({path: "/links/count",- query: { workspaceId },});expect(status).toEqual(200);diff --git a/apps/web/tests/links/create-link-error.test.ts b/apps/web/tests/links/create-link-error.test.tsindex 321af4df8b..7bc9b9c5e4 100644--- a/apps/web/tests/links/create-link-error.test.ts+++ b/apps/web/tests/links/create-link-error.test.ts@@ -65,12 +65,10 @@ const cases = [cases.forEach(({ name, body, expected }) => {test(name, async (ctx) => {const h = new IntegrationHarness(ctx);- const { workspace, http } = await h.init();- const { workspaceId } = workspace;+ const { http } = await h.init();const response = await http.post<Link>({path: "/links",- query: { workspaceId },body,});diff --git a/apps/web/tests/links/create-link.test.ts b/apps/web/tests/links/create-link.test.tsindex 3539a4f241..fae0594df8 100644--- a/apps/web/tests/links/create-link.test.ts+++ b/apps/web/tests/links/create-link.test.ts@@ -1,5 +1,6 @@import { LinkSchema } from "@/lib/zod/schemas/links";import { Link, Tag } from "@prisma/client";+import { IntegrationHarnessOld } from "tests/utils/integration-old";import { describe, expect, test } from "vitest";import { randomId } from "../utils/helpers";import { IntegrationHarness } from "../utils/integration";@@ -11,7 +12,7 @@ const { domain, url } = link;describe.sequential("POST /links", async () => {const h = new IntegrationHarness();const { workspace, user, http } = await h.init();- const { workspaceId } = workspace;+ const workspaceId = workspace.id;const projectId = workspaceId.replace("ws_", "");test("public link", async () => {@@ -47,7 +48,6 @@ describe.sequential("POST /links", async () => {const { status, data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,publicStats: true,@@ -83,7 +83,6 @@ describe.sequential("POST /links", async () => {const { status, data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,key,@@ -115,7 +114,6 @@ describe.sequential("POST /links", async () => {Link & { shortLink: string }>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -157,7 +155,6 @@ describe.sequential("POST /links", async () => {const { status, data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url: longUrl.href,domain,@@ -186,7 +183,6 @@ describe.sequential("POST /links", async () => {const { status, data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -217,7 +213,6 @@ describe.sequential("POST /links", async () => {const { status, data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -251,7 +246,6 @@ describe.sequential("POST /links", async () => {const { status, data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -287,7 +281,6 @@ describe.sequential("POST /links", async () => {const { status, data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -322,7 +315,6 @@ describe.sequential("POST /links", async () => {tagsToCreate.map(({ tag, color }) =>http.post<Tag>({path: "/tags",- query: { workspaceId },body: { tag, color },}),),@@ -339,7 +331,6 @@ describe.sequential("POST /links", async () => {const { status, data: link } = await http.post<Link & { tags: [] }>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -374,7 +365,6 @@ describe.sequential("POST /links", async () => {const { status, data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -401,3 +391,35 @@ describe.sequential("POST /links", async () => {await h.deleteLink(link.id);});});++describe.sequential("POST /links?workspaceId=xxx", async () => {+ const h = new IntegrationHarnessOld();+ const { workspace, user, http } = await h.init();+ const workspaceId = workspace.id;+ const projectId = workspaceId.replace("ws_", "");++ test("create link with old personal API keys approach", async () => {+ const { status, data: link } = await http.post<Link>({+ path: "/links",+ body: {+ url,+ domain,+ },+ });++ expect(status).toEqual(200);+ expect(link).toStrictEqual({+ ...expectedLink,+ url,+ userId: user.id,+ projectId,+ workspaceId,+ shortLink: `https://${domain}/${link.key}`,+ qrCode: `https://api.dub.co/qr?url=https://${domain}/${link.key}?qr=1`,+ tags: [],+ });+ expect(LinkSchema.strict().parse(link)).toBeTruthy();++ await h.deleteLink(link.id);+ });+});diff --git a/apps/web/tests/links/delete-link.test.ts b/apps/web/tests/links/delete-link.test.tsindex f8d045bc20..a25b32c29e 100644--- a/apps/web/tests/links/delete-link.test.ts+++ b/apps/web/tests/links/delete-link.test.ts@@ -7,12 +7,10 @@ const { domain, url } = link;test("DELETE /links/{linkId}", async (ctx) => {const h = new IntegrationHarness(ctx);- const { workspace, http } = await h.init();- const { workspaceId } = workspace;+ const { http } = await h.init();const { data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -21,7 +19,6 @@ test("DELETE /links/{linkId}", async (ctx) => {const { status, data } = await http.delete({path: `/links/${link.id}`,- query: { workspaceId },});expect(status).toBe(200);@@ -32,7 +29,6 @@ test("DELETE /links/{linkId}", async (ctx) => {// Re-fetch the linkconst { status: status2 } = await http.get({path: `/links/${link.id}`,- query: { workspaceId },});expect(status2).toBe(404);diff --git a/apps/web/tests/links/list-links.test.ts b/apps/web/tests/links/list-links.test.tsindex 6f3e9defe6..79e2871e23 100644--- a/apps/web/tests/links/list-links.test.ts+++ b/apps/web/tests/links/list-links.test.ts@@ -8,18 +8,16 @@ const { domain, url } = link;test("GET /links", async (ctx) => {const h = new IntegrationHarness(ctx);const { workspace, http, user } = await h.init();- const { workspaceId } = workspace;+ const workspaceId = workspace.id;const projectId = workspaceId.replace("ws_", "");const { data: firstLink } = await http.post<Link>({path: "/links",- query: { workspaceId },body: { url, domain },});const { data: links, status } = await http.get<Link[]>({path: "/links",- query: { workspaceId },});const linkFound = links.find((l) => l.id === firstLink.id);diff --git a/apps/web/tests/links/retrieve-link.test.ts b/apps/web/tests/links/retrieve-link.test.tsindex 02ea970273..a1aa4d4128 100644--- a/apps/web/tests/links/retrieve-link.test.ts+++ b/apps/web/tests/links/retrieve-link.test.ts@@ -10,14 +10,13 @@ const { domain, url } = link;describe.sequential("GET /links/{linkId}", async () => {const h = new IntegrationHarness();const { workspace, http, user } = await h.init();- const { workspaceId } = workspace;+ const workspaceId = workspace.id;const projectId = workspaceId.replace("ws_", "");const externalId = randomId();const key = randomId();const { data: newLink } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -33,7 +32,6 @@ describe.sequential("GET /links/{linkId}", async () => {test("by linkId", async () => {const { status, data: link } = await http.get<Link>({path: `/links/${newLink.id}`,- query: { workspaceId },});expect(status).toEqual(200);@@ -49,7 +47,6 @@ describe.sequential("GET /links/{linkId}", async () => {test("by externalId", async () => {const { status, data: link } = await http.get<Link>({path: `/links/ext_${externalId}`,- query: { workspaceId },});expect(status).toEqual(200);@@ -66,14 +63,13 @@ describe.sequential("GET /links/{linkId}", async () => {describe.sequential("GET /links/info", async () => {const h = new IntegrationHarness();const { workspace, http, user } = await h.init();- const { workspaceId } = workspace;+ const workspaceId = workspace.id;const projectId = workspaceId.replace("ws_", "");const externalId = randomId();const key = randomId();const { data: newLink } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,diff --git a/apps/web/tests/links/update-link.test.ts b/apps/web/tests/links/update-link.test.tsindex 7d90507876..b85c967cd1 100644--- a/apps/web/tests/links/update-link.test.ts+++ b/apps/web/tests/links/update-link.test.ts@@ -10,12 +10,12 @@ const { domain, url } = link;describe.sequential("PATCH /links/{linkId}", async () => {const h = new IntegrationHarness();const { workspace, http, user } = await h.init();- const { workspaceId } = workspace;+ const workspaceId = workspace.id;+ const projectId = workspaceId.replace("ws_", "");const externalId = randomId();const { data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -48,7 +48,6 @@ describe.sequential("PATCH /links/{linkId}", async () => {test("update link using linkId", async () => {const { data: updatedLink } = await http.patch<Link>({path: `/links/${link.id}`,- query: { workspaceId },body: { ...toUpdate },});@@ -60,7 +59,7 @@ describe.sequential("PATCH /links/{linkId}", async () => {externalId,userId: user.id,expiresAt: "2030-04-16T17:00:00.000Z",- projectId: workspaceId.replace("ws_", ""),+ projectId,shortLink: `https://${domain}/${toUpdate.key}`,qrCode: `https://api.dub.co/qr?url=https://${domain}/${toUpdate.key}?qr=1`,tags: [],@@ -69,7 +68,6 @@ describe.sequential("PATCH /links/{linkId}", async () => {// Fetch the linkconst { data: fetchedLink } = await http.get<Link>({path: `/links/${link.id}`,- query: { workspaceId },});expect(fetchedLink).toStrictEqual({@@ -80,7 +78,7 @@ describe.sequential("PATCH /links/{linkId}", async () => {externalId,userId: user.id,expiresAt: "2030-04-16T17:00:00.000Z",- projectId: workspaceId.replace("ws_", ""),+ projectId,shortLink: `https://${domain}/${toUpdate.key}`,qrCode: `https://api.dub.co/qr?url=https://${domain}/${toUpdate.key}?qr=1`,tags: [],@@ -91,7 +89,6 @@ describe.sequential("PATCH /links/{linkId}", async () => {test("archive link", async () => {const { status, data: updatedLink } = await http.patch<Link>({path: `/links/${link.id}`,- query: { workspaceId },body: {archived: true,},@@ -107,7 +104,7 @@ describe.sequential("PATCH /links/{linkId}", async () => {archived: true,userId: user.id,expiresAt: "2030-04-16T17:00:00.000Z",- projectId: workspaceId.replace("ws_", ""),+ projectId,shortLink: `https://${domain}/${toUpdate.key}`,qrCode: `https://api.dub.co/qr?url=https://${domain}/${toUpdate.key}?qr=1`,tags: [],@@ -116,7 +113,6 @@ describe.sequential("PATCH /links/{linkId}", async () => {// Fetch the linkconst { data: archivedLink } = await http.get<Link>({path: `/links/${link.id}`,- query: { workspaceId },});expect(archivedLink.archived).toEqual(true);@@ -126,7 +122,6 @@ describe.sequential("PATCH /links/{linkId}", async () => {test("unarchive link", async () => {const { status, data: updatedLink } = await http.patch<Link>({path: `/links/${link.id}`,- query: { workspaceId },body: {archived: false,},@@ -142,7 +137,7 @@ describe.sequential("PATCH /links/{linkId}", async () => {archived: false,userId: user.id,expiresAt: "2030-04-16T17:00:00.000Z",- projectId: workspaceId.replace("ws_", ""),+ projectId,shortLink: `https://${domain}/${toUpdate.key}`,qrCode: `https://api.dub.co/qr?url=https://${domain}/${toUpdate.key}?qr=1`,tags: [],@@ -151,7 +146,6 @@ describe.sequential("PATCH /links/{linkId}", async () => {// Fetch the linkconst { data: unarchivedLink } = await http.get<Link>({path: `/links/${link.id}`,- query: { workspaceId },});expect(unarchivedLink.archived).toEqual(false);@@ -161,7 +155,6 @@ describe.sequential("PATCH /links/{linkId}", async () => {test("update link using externalId", async () => {const { status, data: updatedLink } = await http.patch<Link>({path: `/links/ext_${externalId}`,- query: { workspaceId },body: {url: "https://github.com/dubinc",},@@ -178,7 +171,7 @@ describe.sequential("PATCH /links/{linkId}", async () => {userId: user.id,url: "https://github.com/dubinc",expiresAt: "2030-04-16T17:00:00.000Z",- projectId: workspaceId.replace("ws_", ""),+ projectId,shortLink: `https://${domain}/${toUpdate.key}`,qrCode: `https://api.dub.co/qr?url=https://${domain}/${toUpdate.key}?qr=1`,tags: [],@@ -187,7 +180,6 @@ describe.sequential("PATCH /links/{linkId}", async () => {// Fetch the linkconst { data: linkUpdated } = await http.get<Link>({path: `/links/ext_${externalId}`,- query: { workspaceId },});expect(linkUpdated.url).toEqual("https://github.com/dubinc");@@ -199,12 +191,12 @@ describe.sequential(async () => {const h = new IntegrationHarness();const { workspace, http, user } = await h.init();- const { workspaceId } = workspace;+ const workspaceId = workspace.id;+ const projectId = workspaceId.replace("ws_", "");const externalId = randomId();const { data: link } = await http.post<Link>({path: "/links",- query: { workspaceId },body: {url,domain,@@ -237,7 +229,6 @@ describe.sequential(test("update link using PUT", async () => {const { data: updatedLink } = await http.put<Link>({path: `/links/${link.id}`,- query: { workspaceId },body: { ...toUpdate },});@@ -249,7 +240,7 @@ describe.sequential(externalId,userId: user.id,expiresAt: "2030-04-16T17:00:00.000Z",- projectId: workspaceId.replace("ws_", ""),+ projectId,shortLink: `https://${domain}/${toUpdate.key}`,qrCode: `https://api.dub.co/qr?url=https://${domain}/${toUpdate.key}?qr=1`,tags: [],@@ -258,7 +249,6 @@ describe.sequential(// Fetch the linkconst { data: fetchedLink } = await http.get<Link>({path: `/links/${link.id}`,- query: { workspaceId },});expect(fetchedLink).toStrictEqual({@@ -269,7 +259,7 @@ describe.sequential(externalId,userId: user.id,expiresAt: "2030-04-16T17:00:00.000Z",- projectId: workspaceId.replace("ws_", ""),+ projectId,shortLink: `https://${domain}/${toUpdate.key}`,qrCode: `https://api.dub.co/qr?url=https://${domain}/${toUpdate.key}?qr=1`,tags: [],diff --git a/apps/web/tests/links/upsert-link.test.ts b/apps/web/tests/links/upsert-link.test.tsindex 99512da437..48c233b71f 100644--- a/apps/web/tests/links/upsert-link.test.ts+++ b/apps/web/tests/links/upsert-link.test.ts@@ -11,9 +11,8 @@ const url = `https://example.com/${randomId()}`;describe.sequential("PUT /links/upsert", async () => {const h = new IntegrationHarness();const { workspace, user, http } = await h.init();- const { workspaceId } = workspace;+ const workspaceId = workspace.id;const projectId = workspaceId.replace("ws_", "");-let createdLink: Link;afterAll(async () => {@@ -23,7 +22,6 @@ describe.sequential("PUT /links/upsert", async () => {test("New link", async () => {const { data } = await http.put<Link>({path: "/links/upsert",- query: { workspaceId },body: { domain, url },});@@ -45,7 +43,6 @@ describe.sequential("PUT /links/upsert", async () => {test("Existing link", async () => {const { data: updatedLink } = await http.put<Link>({path: "/links/upsert",- query: { workspaceId },body: { domain, url, comments: "Updated comment" },});diff --git a/apps/web/tests/tags/create-tag-error.test.ts b/apps/web/tests/tags/create-tag-error.test.tsindex aef6fab604..dbe9cd1333 100644--- a/apps/web/tests/tags/create-tag-error.test.ts+++ b/apps/web/tests/tags/create-tag-error.test.ts@@ -44,12 +44,10 @@ const cases = [cases.forEach(({ name, body, expected }) => {test(name, async (ctx) => {const h = new IntegrationHarness(ctx);- const { workspace, http } = await h.init();- const { workspaceId } = workspace;+ const { http } = await h.init();const response = await http.post<Tag>({path: "/tags",- query: { workspaceId },body,});@@ -59,12 +57,10 @@ cases.forEach(({ name, body, expected }) => {test("create tag with existing name", async (ctx) => {const h = new IntegrationHarness(ctx);- const { workspace, http } = await h.init();- const { workspaceId } = workspace;+ const { http } = await h.init();await http.post({path: "/tags",- query: { workspaceId },body: {tag: "news",color: "red",@@ -74,7 +70,6 @@ test("create tag with existing name", async (ctx) => {// Create the same tag againconst { status, data: error } = await http.post<Tag>({path: "/tags",- query: { workspaceId },body: {tag: "news",color: "red",diff --git a/apps/web/tests/tags/create-tag.test.ts b/apps/web/tests/tags/create-tag.test.tsindex b0c6850195..b85f0e2f7d 100644--- a/apps/web/tests/tags/create-tag.test.ts+++ b/apps/web/tests/tags/create-tag.test.ts@@ -6,11 +6,11 @@ import { expectedTag } from "../utils/schema";test("POST /tags", async (ctx) => {const h = new IntegrationHarness(ctx);const { workspace, http } = await h.init();- const { workspaceId } = workspace;+ const workspaceId = workspace.id;+ const projectId = workspaceId.replace("ws_", "");const { status, data: tag } = await http.post<Tag>({path: "/tags",- query: { workspaceId },body: {tag: "social",color: "red",@@ -22,7 +22,7 @@ test("POST /tags", async (ctx) => {...expectedTag,name: "social",color: "red",- projectId: workspaceId.replace("ws_", ""),+ projectId,});await h.deleteTag(tag.id);diff --git a/apps/web/tests/tags/list-tags.test.ts b/apps/web/tests/tags/list-tags.test.tsindex be8a4ba6ac..5302b32c95 100644--- a/apps/web/tests/tags/list-tags.test.ts+++ b/apps/web/tests/tags/list-tags.test.ts@@ -5,8 +5,7 @@ import { IntegrationHarness } from "../utils/integration";test("GET /tags", async (ctx) => {const h = new IntegrationHarness(ctx);- const { workspace, http } = await h.init();- const { workspaceId } = workspace;+ const { http } = await h.init();const newTag = {tag: randomId(),@@ -15,13 +14,11 @@ test("GET /tags", async (ctx) => {const { data: tagCreated } = await http.post<Tag>({path: "/tags",- query: { workspaceId },body: newTag,});const { status, data: tags } = await http.get<Tag[]>({path: "/tags",- query: { workspaceId },});expect(status).toEqual(200);diff --git a/apps/web/tests/tracks/create-customer.test.ts b/apps/web/tests/tracks/create-customer.test.tsindex e1efcf900d..77480c87a1 100644--- a/apps/web/tests/tracks/create-customer.test.ts+++ b/apps/web/tests/tracks/create-customer.test.ts@@ -6,8 +6,7 @@ import { IntegrationHarness } from "../utils/integration";describe.skip("POST /track/customer", async () => {const h = new IntegrationHarness();- const { workspace, http } = await h.init();- const { workspaceId } = workspace;+ const { http } = await h.init();test("with required params", async () => {const customer = {@@ -16,7 +15,6 @@ describe.skip("POST /track/customer", async () => {const response = await http.post<Tag>({path: "/track/customer",- query: { workspaceId },body: {customerId: customer.customerId,},@@ -44,7 +42,6 @@ describe.skip("POST /track/customer", async () => {const response = await http.post<Tag>({path: "/track/customer",- query: { workspaceId },body: customer,});diff --git a/apps/web/tests/tracks/create-lead.test.ts b/apps/web/tests/tracks/create-lead.test.tsindex b9faed8e43..c7772eced6 100644--- a/apps/web/tests/tracks/create-lead.test.ts+++ b/apps/web/tests/tracks/create-lead.test.ts@@ -13,14 +13,12 @@ const customer = {describe.skip("POST /track/lead", async () => {const h = new IntegrationHarness();- const { workspace, http } = await h.init();- const { workspaceId } = workspace;+ const { http } = await h.init();const clickId = "uxdcuMfBa5Nqnbwk";test("with required params", async () => {const response = await http.post<Tag>({path: "/track/lead",- query: { workspaceId },body: {clickId,eventName: "Signup",@@ -46,7 +44,6 @@ describe.skip("POST /track/lead", async () => {test("with all params", async () => {const response = await http.post<Tag>({path: "/track/lead",- query: { workspaceId },body: {clickId,eventName: "Signup",diff --git a/apps/web/tests/utils/env.ts b/apps/web/tests/utils/env.tsindex 5f4029aa67..77e516bfed 100644--- a/apps/web/tests/utils/env.ts+++ b/apps/web/tests/utils/env.ts@@ -3,7 +3,9 @@ import { z } from "zod";export const integrationTestEnv = z.object({E2E_BASE_URL: z.string().url().min(1),E2E_TOKEN: z.string().min(1),+ E2E_TOKEN_OLD: z.string().min(1),E2E_USER_ID: z.string().min(1),+ E2E_USER_ID_OLD: z.string().min(1),E2E_WORKSPACE_ID: z.string().min(1),E2E_WORKSPACE_SLUG: z.string().min(1),E2E_WORKSPACE_NAME: z.string().min(1),diff --git a/apps/web/tests/utils/integration-old.ts b/apps/web/tests/utils/integration-old.tsnew file mode 100644index 0000000000..213778a2a7--- /dev/null+++ b/apps/web/tests/utils/integration-old.ts@@ -0,0 +1,68 @@+import { Project, User } from "@prisma/client";+import { type TaskContext } from "vitest";+import { z } from "zod";+import { env, integrationTestEnv } from "./env";+import { HttpClient } from "./http";++interface Resources {+ user: Pick<User, "id">;+ workspace: Pick<Project, "id" | "slug" | "name"> & { workspaceId: string };+ apiKey: { token: string };+}++export class IntegrationHarnessOld {+ private readonly ctx?: TaskContext;+ private env: z.infer<typeof integrationTestEnv>;+ public resources: Resources;+ public baseUrl: string;+ public http: HttpClient;++ constructor(ctx?: TaskContext) {+ this.env = env;+ this.ctx = ctx;+ this.baseUrl = this.env.E2E_BASE_URL;+ this.http = new HttpClient({+ baseUrl: `${this.baseUrl}/api`,+ headers: {+ Authorization: `Bearer ${this.env.E2E_TOKEN}`,+ },+ });+ }++ async init() {+ const user = {+ id: this.env.E2E_USER_ID,+ };++ const apiKey = {+ token: this.env.E2E_TOKEN_OLD,+ };++ const workspace = {+ id: this.env.E2E_WORKSPACE_ID,+ slug: this.env.E2E_WORKSPACE_SLUG,+ name: this.env.E2E_WORKSPACE_NAME,+ };++ this.resources = {+ user,+ apiKey,+ workspace: {+ ...workspace,+ workspaceId: workspace.id,+ },+ };++ return { ...this.resources, http: this.http };+ }++ // Delete link+ public async deleteLink(id: string) {+ const { workspaceId } = this.resources.workspace;++ await this.http.delete({+ path: `/links/${id}`,+ query: { workspaceId },+ });+ }+}diff --git a/apps/web/tests/utils/integration.ts b/apps/web/tests/utils/integration.tsindex 83e3e48594..89f92e4a29 100644--- a/apps/web/tests/utils/integration.ts+++ b/apps/web/tests/utils/integration.ts@@ -6,7 +6,7 @@ import { env, integrationTestEnv } from "./env";interface Resources {user: Pick<User, "id">;- workspace: Pick<Project, "id" | "slug" | "name"> & { workspaceId: string };+ workspace: Pick<Project, "id" | "slug" | "name">;apiKey: { token: string };}@@ -47,10 +47,7 @@ export class IntegrationHarness {this.resources = {user,apiKey,- workspace: {- ...workspace,- workspaceId: workspace.id,- },+ workspace,};return { ...this.resources, http: this.http };@@ -58,31 +55,22 @@ export class IntegrationHarness {// Delete linkpublic async deleteLink(id: string) {- const { workspaceId } = this.resources.workspace;-await this.http.delete({path: `/links/${id}`,- query: { workspaceId },});}// Delete tagpublic async deleteTag(id: string) {- const { workspaceId } = this.resources.workspace;-await this.http.delete({path: `/tags/${id}`,- query: { workspaceId },});}// Delete domainpublic async deleteDomain(slug: string) {- const { workspaceId } = this.resources.workspace;-await this.http.delete({path: `/domains/${slug}`,- query: { workspaceId },});}}diff --git a/apps/web/tests/workspaces/create-workspace-error.test.ts b/apps/web/tests/workspaces/create-workspace-error.test.tsdeleted file mode 100644index be46d4d3c6..0000000000--- a/apps/web/tests/workspaces/create-workspace-error.test.ts+++ /dev/null@@ -1,26 +0,0 @@-import { Project } from "@prisma/client";-import { expect, test } from "vitest";-import { IntegrationHarness } from "../utils/integration";--test("should not create workspace with slug in use", async (ctx) => {- const h = new IntegrationHarness(ctx);- const { workspace, http } = await h.init();-- // Create another workspace with the same slug- const { status, data: error } = await http.post<Project>({- path: "/workspaces",- body: {- name: "Dub Workspace",- slug: workspace.slug,- },- });-- expect(status).toEqual(409);- expect(error).toStrictEqual({- error: {- code: "conflict",- message: "Slug is already in use.",- doc_url: "https://dub.co/docs/api-reference/errors#conflict",- },- });-});diff --git a/apps/web/tests/workspaces/create-workspace.test.ts b/apps/web/tests/workspaces/create-workspace.test.tsdeleted file mode 100644index 22679e8d85..0000000000--- a/apps/web/tests/workspaces/create-workspace.test.ts+++ /dev/null@@ -1,32 +0,0 @@-import { Project } from "@prisma/client";-import slugify from "@sindresorhus/slugify";-import { expect, test } from "vitest";-import { randomId } from "../utils/helpers";-import { IntegrationHarness } from "../utils/integration";-import { expectedWorkspace } from "../utils/schema";--// Not running this test now-test.skip("POST /workspaces", async (ctx) => {- const h = new IntegrationHarness(ctx);- const { http } = await h.init();-- const name = "Dub Workspace";- const slug = slugify(`dub-${randomId()}`);-- const { status, data: workspace } = await http.post<Project>({- path: "/workspaces",- body: {- name,- slug,- },- });-- expect(status).toEqual(200);- expect(workspace).toStrictEqual({- ...expectedWorkspace,- name,- slug,- domains: [],- users: [{ role: "owner" }],- });-});diff --git a/apps/web/tests/workspaces/list-workspaces.test.ts b/apps/web/tests/workspaces/list-workspaces.test.tsdeleted file mode 100644index 39006f84b0..0000000000--- a/apps/web/tests/workspaces/list-workspaces.test.ts+++ /dev/null@@ -1,34 +0,0 @@-import z from "@/lib/zod";-import { WorkspaceSchema } from "@/lib/zod/schemas/workspaces";-import { Project } from "@prisma/client";-import { expect, test } from "vitest";-import { IntegrationHarness } from "../utils/integration";--test("GET /workspaces", async (ctx) => {- const h = new IntegrationHarness(ctx);- const { workspace, http } = await h.init();-- const { status, data: workspaces } = await http.get<Project[]>({- path: "/workspaces",- });-- const workspacesFetched = workspaces.map((w) => {- return {- id: w.id,- name: w.name,- slug: w.slug,- };- });-- expect(status).toEqual(200);- expect(workspaces.length).toBeGreaterThanOrEqual(1);- expect(workspacesFetched).toContainEqual({- id: workspace.id,- name: workspace.name,- slug: workspace.slug,- });-- z.array(WorkspaceSchema.extend({ createdAt: z.string() }).strict()).parse(- workspaces,- );-});diff --git a/apps/web/tests/workspaces/retrieve-workspace.test.ts b/apps/web/tests/workspaces/retrieve-workspace.test.tsindex 3522af8c2e..c73b6845d3 100644--- a/apps/web/tests/workspaces/retrieve-workspace.test.ts+++ b/apps/web/tests/workspaces/retrieve-workspace.test.ts@@ -10,7 +10,7 @@ describe("GET /workspaces/{idOrSlug}", async () => {test("by id", async () => {const { status, data: workspaceFetched } = await http.get<Project>({- path: `/workspaces/${workspace.workspaceId}`,+ path: `/workspaces/${workspace.id}`,});const { id, name, slug } = workspaceFetched;