The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add test setup
Kiran Ke4a8f930cb50
diff --git a/apps/web/package.json b/apps/web/package.jsonindex 9950e5c314..01c8d5e486 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -8,7 +8,8 @@"format": "prettier --write \"**/*.{ts,tsx,md}\"","lint": "next lint","start": "next start",- "script": "tsx ./scripts/run.ts"+ "script": "tsx ./scripts/run.ts",+ "test": "vitest"},"dependencies": {"@boxyhq/saml-jackson": "^1.14.2",diff --git a/apps/web/tests/links.test.ts b/apps/web/tests/links.test.tsnew file mode 100644index 0000000000..4046f29449--- /dev/null+++ b/apps/web/tests/links.test.ts@@ -0,0 +1,32 @@+import { beforeAll, describe, expect, test } from "vitest";+import { HttpClient } from "./utils/http";+import { Link } from "@prisma/client";++const workspaceId = "ws_cltx2raaz0000pju4z0v33sy2";++describe("links", () => {+ test("creates new link", async () => {+ const http = new HttpClient({+ baseUrl: "http://localhost:8888/api",+ headers: {+ Authorization: "Bearer cJHO9vZR8B4eaY3mJoI0b6JZ",+ },+ });++ const res = await http.post<Link>({+ path: "/links",+ query: { workspaceId },+ body: { url: "https://google.com" },+ });++ expect(res.status).toEqual(200);+ expect(res.data).toMatchObject({+ url: "https://google.com",+ domain: "kiran.localhost",+ shortLink: `https://kiran.localhost/${res.data.key}`,+ archived: false,+ workspaceId,+ projectId: workspaceId.replace("ws_", ""),+ });+ });+});diff --git a/apps/web/tests/setup.ts b/apps/web/tests/setup.tsindex a7d9440473..b90464f294 100644--- a/apps/web/tests/setup.ts+++ b/apps/web/tests/setup.ts@@ -5,13 +5,13 @@ import { afterAll, beforeAll } from "vitest";beforeAll(async () => {console.log("Running beforeAll")- // await prisma.user.create({- // data: {- // name: "Kiran",- // email: "[email protected]",- // emailVerified: new Date(),- // },- // });+ await prisma.user.create({+ data: {+ name: "Kiran",+ email: "[email protected]",+ emailVerified: new Date(),+ },+ });// Create a user// Create a workspacediff --git a/apps/web/tests/utils/integration.ts b/apps/web/tests/utils/integration.tsnew file mode 100644index 0000000000..e69de29bb2