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 tests

Steven Teyb7ae88b60ba1
diff --git a/apps/web/tests/analytics/index.test.ts b/apps/web/tests/analytics/index.test.ts
index bd41c2100b..d6ec309fce 100644
--- a/apps/web/tests/analytics/index.test.ts
+++ b/apps/web/tests/analytics/index.test.ts
@@ -5,11 +5,6 @@ import { describe, expect, test } from "vitest";
import { env } from "../utils/env";
import { IntegrationHarness } from "../utils/integration";
-const filter = {
- domain: "dub.sh",
- key: "checkly-check",
- interval: "30d",
-};
describe.runIf(env.CI).sequential("GET /analytics", async () => {
const h = new IntegrationHarness();
const { workspace, http } = await h.init();
@@ -19,7 +14,18 @@ describe.runIf(env.CI).sequential("GET /analytics", async () => {
test(`by ${groupBy}`, async () => {
const { status, data } = await http.get<any[]>({
path: `/analytics`,
- query: { event: "composite", groupBy, workspaceId, ...filter },
+ query: {
+ event: "composite",
+ groupBy,
+ workspaceId,
+ interval: "30d",
+ ...(groupBy !== "partnerId"
+ ? {
+ domain: "dub.sh",
+ key: "checkly-check",
+ }
+ : {}),
+ },
});
const responseSchema =
diff --git a/apps/web/tests/redirects/index.test.ts b/apps/web/tests/redirects/index.test.ts
index 0f528e3314..7161956a7e 100644
--- a/apps/web/tests/redirects/index.test.ts
+++ b/apps/web/tests/redirects/index.test.ts
@@ -8,7 +8,7 @@ const fetchOptions: RequestInit = {
cache: "no-store",
redirect: "manual",
headers: {
- "dub-no-track": "1",
+ "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
},
};
@@ -25,10 +25,7 @@ describe.runIf(env.CI)("Link Redirects", async () => {
});
test("regular", async () => {
- const response = await fetch(`${h.baseUrl}/checkly-check`, {
- ...fetchOptions,
- headers: {},
- });
+ const response = await fetch(`${h.baseUrl}/checkly-check`, fetchOptions);
expect(response.headers.get("location")).toBe("https://www.checklyhq.com/");
expect(response.headers.get("x-powered-by")).toBe(poweredBy);
@@ -44,10 +41,10 @@ describe.runIf(env.CI)("Link Redirects", async () => {
});
test("with dub_id", async () => {
- const response = await fetch(`${h.baseUrl}/conversion-tracking`, {
- ...fetchOptions,
- headers: {},
- });
+ const response = await fetch(
+ `${h.baseUrl}/conversion-tracking`,
+ fetchOptions,
+ );
// the location should contain `?dub_id=` query param
expect(response.headers.get("location")).toMatch(/dub_id=[a-zA-Z0-9]+/);
@@ -56,10 +53,7 @@ describe.runIf(env.CI)("Link Redirects", async () => {
});
test("with dub_id and via", async () => {
- const response = await fetch(`${h.baseUrl}/track-test`, {
- ...fetchOptions,
- headers: {},
- });
+ const response = await fetch(`${h.baseUrl}/track-test`, fetchOptions);
// the location should contain `?dub_id=` query param
expect(response.headers.get("location")).toMatch(/dub_id=[a-zA-Z0-9]+/);
@@ -70,10 +64,10 @@ describe.runIf(env.CI)("Link Redirects", async () => {
});
test("with dub_client_reference_id", async () => {
- const response = await fetch(`${h.baseUrl}/client_reference_id`, {
- ...fetchOptions,
- headers: {},
- });
+ const response = await fetch(
+ `${h.baseUrl}/client_reference_id`,
+ fetchOptions,
+ );
// the location should contain `?client_reference_id=dub_id_` query param
expect(response.headers.get("location")).toMatch(
@@ -158,10 +152,7 @@ describe.runIf(env.CI)("Link Redirects", async () => {
});
test("unsupported key", async () => {
- const response = await fetch(`${h.baseUrl}/wp-admin.php`, {
- ...fetchOptions,
- headers: {},
- });
+ const response = await fetch(`${h.baseUrl}/wp-admin.php`, fetchOptions);
expect(response.headers.get("location")).toBe("/?dub-no-track=1");
expect(response.headers.get("x-powered-by")).toBe(poweredBy);
@@ -171,10 +162,7 @@ describe.runIf(env.CI)("Link Redirects", async () => {
test("redirection url", async () => {
const response = await fetch(
`${h.baseUrl}/redir-url-test?${REDIRECTION_QUERY_PARAM}=https://dub.co/blog`,
- {
- ...fetchOptions,
- headers: {},
- },
+ fetchOptions,
);
expect(response.headers.get("location")).toBe("https://dub.co/blog");