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.

Fix the tests

Kiran K327b40bddbc2
diff --git a/apps/web/tests/links/create-link.test.ts b/apps/web/tests/links/create-link.test.ts
index bd6b0f13ea..ef750e55b6 100644
--- a/apps/web/tests/links/create-link.test.ts
+++ b/apps/web/tests/links/create-link.test.ts
@@ -5,7 +5,7 @@ import { IntegrationHarness } from "../utils/integration";
test("creates new link", async (ctx) => {
const h = new IntegrationHarness(ctx);
- const { workspace, apiKey, user, defaultDomains } = await h.init();
+ const { workspace, apiKey, user } = await h.init();
const http = new HttpClient({
baseUrl: h.baseUrl,
@@ -13,21 +13,25 @@ test("creates new link", async (ctx) => {
Authorization: `Bearer ${apiKey.token}`,
},
});
-
- const domain = defaultDomains[0];
+
+ const domain = "dub.sh";
+ const url = "https://github.com/dubinc";
const { status, data: link } = await http.post<Link>({
path: "/links",
query: { workspaceId: workspace.workspaceId },
- body: { url: "https://google.com", domain },
+ body: {
+ url,
+ domain,
+ },
});
expect(status).toEqual(200);
expect(link).toMatchObject({
id: expect.any(String),
domain,
+ url,
key: expect.any(String),
- url: "https://google.com",
userId: user.id,
projectId: workspace.id,
workspaceId: workspace.workspaceId,
@@ -56,7 +60,7 @@ test("creates new link", async (ctx) => {
tags: [],
createdAt: expect.any(String),
updatedAt: expect.any(String),
- shortLink: `${domain}/${link.key}`,
- qrCode: `https://api.dub.co/qr?url=${domain}/${link.key}`,
+ shortLink: `https://${domain}/${link.key}`,
+ qrCode: `https://api.dub.co/qr?url=https://${domain}/${link.key}`,
});
});
diff --git a/apps/web/tests/utils/integration.ts b/apps/web/tests/utils/integration.ts
index 3d70f7c45a..11056c429c 100644
--- a/apps/web/tests/utils/integration.ts
+++ b/apps/web/tests/utils/integration.ts
@@ -4,13 +4,11 @@ import { nanoid } from "@dub/utils";
import { Project, Token, User } from "@prisma/client";
import type { TaskContext } from "vitest";
import { integrationTestEnv } from "./env";
-import { DUB_DOMAINS_ARRAY } from "@dub/utils";
interface Resources {
user: User;
workspace: Project & { workspaceId: string };
apiKey: Token & { token: string };
- defaultDomains: string[];
}
export class IntegrationHarness {
@@ -81,34 +79,10 @@ export class IntegrationHarness {
},
});
- // Default domains for the workspace
- const defaultDomains = await prisma.defaultDomains.findUniqueOrThrow({
- where: {
- projectId: workspace.id,
- },
- select: {
- dubsh: true,
- chatgpt: true,
- sptifi: true,
- gitnew: true,
- amznid: true,
- loooooooong: true,
- },
- });
-
- const defaultDomainsArray = Object.keys(defaultDomains)
- .filter((key) => defaultDomains[key])
- .map((domain) =>
- DUB_DOMAINS_ARRAY.find((d) => d.replace(".", "") === domain),
- ) as string[];
-
- console.log(DUB_DOMAINS_ARRAY);
-
const resource = {
user,
workspace: { ...workspace, workspaceId: `ws_${workspace.id}` },
apiKey: { ...apiKey, token },
- defaultDomains: defaultDomainsArray,
} as const;
return resource;
diff --git a/apps/web/vitest.config.ts b/apps/web/vitest.config.ts
index 0d82a4a8d8..6658517360 100644
--- a/apps/web/vitest.config.ts
+++ b/apps/web/vitest.config.ts
@@ -9,8 +9,5 @@ export default defineConfig({
globals: true,
setupFiles: ["./tests/setup.ts"],
testTimeout: 10000,
- env: {
- NEXT_PUBLIC_IS_DUB: "true",
- },
},
});