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 Ke36ea9314fd0
diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml
index 4c1b4b4e94..ab29df0bc7 100644
--- a/.github/workflows/e2e.yaml
+++ b/.github/workflows/e2e.yaml
@@ -29,7 +29,7 @@ jobs:
- name: Run tests
working-directory: apps/web
env:
- E2E_API_BASE_URL: ${{ github.event.deployment_status.environment_url }}/api
+ E2E_BASE_URL: ${{ github.event.deployment_status.environment_url }}
E2E_TOKEN: ${{ secrets.E2E_TOKEN }}
E2E_USER_ID: ${{ secrets.E2E_USER_ID }}
E2E_WORKSPACE_ID: ${{ secrets.E2E_WORKSPACE_ID }}
diff --git a/apps/web/tests/redirects/index.test.ts b/apps/web/tests/redirects/index.test.ts
index 22abc65094..8e364d20d4 100644
--- a/apps/web/tests/redirects/index.test.ts
+++ b/apps/web/tests/redirects/index.test.ts
@@ -16,7 +16,7 @@ type LinkWithShortLink = Link & { shortLink: string };
describe.sequential("Link Redirects", async () => {
const h = new IntegrationHarness();
- const { workspace, user, http } = await h.init();
+ const { workspace, http } = await h.init();
const { workspaceId } = workspace;
test("root", async () => {
@@ -39,7 +39,10 @@ describe.sequential("Link Redirects", async () => {
},
});
- const response = await fetch(link.shortLink, fetchOptions);
+ const response = await fetch(
+ `${h.env.E2E_BASE_URL}/${link.key}`,
+ fetchOptions,
+ );
expect(response.headers.get("location")).toBe(url);
expect(response.headers.get("x-powered-by")).toBe(poweredBy);
@@ -61,7 +64,10 @@ describe.sequential("Link Redirects", async () => {
},
});
- const response = await fetch(link.shortLink, fetchOptions);
+ const response = await fetch(
+ `${h.env.E2E_BASE_URL}/${link.key}`,
+ fetchOptions,
+ );
expect(response.headers.get("location")).toBe(url);
expect(response.headers.get("x-powered-by")).toBe(poweredBy);
@@ -83,7 +89,10 @@ describe.sequential("Link Redirects", async () => {
},
});
- const response = await fetch(link.shortLink, fetchOptions);
+ const response = await fetch(
+ `${h.env.E2E_BASE_URL}/${link.key}`,
+ fetchOptions,
+ );
expect(response.headers.get("location")).toBe(url);
expect(response.headers.get("x-powered-by")).toBe(poweredBy);
@@ -105,7 +114,10 @@ describe.sequential("Link Redirects", async () => {
},
});
- const response = await fetch(link.shortLink, fetchOptions);
+ const response = await fetch(
+ `${h.env.E2E_BASE_URL}/${link.key}`,
+ fetchOptions,
+ );
expect(response.headers.get("location")).toBe(url);
expect(response.headers.get("x-powered-by")).toBe(poweredBy);
@@ -127,7 +139,10 @@ describe.sequential("Link Redirects", async () => {
},
});
- const response = await fetch(`${link.shortLink}?pw=dub`, fetchOptions);
+ const response = await fetch(
+ `${h.env.E2E_BASE_URL}/${link.key}?pw=dub`,
+ fetchOptions,
+ );
expect(response.headers.get("location")).toBe(url);
expect(response.headers.get("x-powered-by")).toBe(poweredBy);
diff --git a/apps/web/tests/utils/env.ts b/apps/web/tests/utils/env.ts
index 6771714931..a309ac9b96 100644
--- a/apps/web/tests/utils/env.ts
+++ b/apps/web/tests/utils/env.ts
@@ -1,7 +1,7 @@
import { z } from "zod";
export const integrationTestEnv = z.object({
- E2E_API_BASE_URL: z.string().url().min(1),
+ E2E_BASE_URL: z.string().url().min(1),
E2E_TOKEN: z.string().min(1),
E2E_USER_ID: z.string().min(1),
E2E_WORKSPACE_ID: z.string().min(1),
diff --git a/apps/web/tests/utils/integration.ts b/apps/web/tests/utils/integration.ts
index 7a22d5f26b..94a1b9b513 100644
--- a/apps/web/tests/utils/integration.ts
+++ b/apps/web/tests/utils/integration.ts
@@ -12,7 +12,7 @@ interface Resources {
export class IntegrationHarness {
private readonly ctx?: TaskContext;
- private env: z.infer<typeof integrationTestEnv>;
+ public env: z.infer<typeof integrationTestEnv>;
public resources: Resources;
public baseUrl: string;
public http: HttpClient;
@@ -21,7 +21,7 @@ export class IntegrationHarness {
this.env = integrationTestEnv.parse(process.env);
this.ctx = ctx;
- this.baseUrl = this.env.E2E_API_BASE_URL;
+ this.baseUrl = this.env.E2E_BASE_URL + "/api";
this.http = new HttpClient({
baseUrl: this.baseUrl,
headers: {