diff --git a/test/docs-e2e/nginx-proxy/index.test.ts b/test/docs-e2e/nginx-proxy/index.test.ts index d75216ab1e..995cf93e78 100644 --- a/test/docs-e2e/nginx-proxy/index.test.ts +++ b/test/docs-e2e/nginx-proxy/index.test.ts @@ -3,11 +3,9 @@ import express from "express"; import { createProxyMiddleware } from "http-proxy-middleware"; import { chromium } from "playwright"; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { getDeploymentOrigin } from "../../utils/deployment-url"; -let origin = process.env.DEPLOYMENT_URL ?? "https://app-staging.buildwithfern.com"; -if (!origin.startsWith("http")) { - origin = `https://${origin}`; -} +const origin = getDeploymentOrigin(); const target = "https://test-nginx-proxy.docs.buildwithfern.com/subpath"; const proxy = "http://localhost:5050/subpath"; diff --git a/test/docs-e2e/skew-protection/index.test.ts b/test/docs-e2e/skew-protection/index.test.ts index e5ea9cfa37..9408f765f8 100644 --- a/test/docs-e2e/skew-protection/index.test.ts +++ b/test/docs-e2e/skew-protection/index.test.ts @@ -1,8 +1,8 @@ import { chromium, Request } from "playwright"; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; +import { getDeploymentOrigin } from "../../utils/deployment-url"; -const origin = process.env.DEPLOYMENT_URL ?? "app-staging.buildwithfern.com"; -const protocol = origin.startsWith("localhost") ? "http" : "https"; +const origin = getDeploymentOrigin(); describe("skew-protection", () => { let browser: Awaited>; @@ -38,7 +38,7 @@ describe("skew-protection", () => { requests.push(request); }); - await page.goto(`${protocol}://${origin}/learn/home`); + await page.goto(`${origin}/learn/home`); const scripts = await page.locator("script").all(); expect(scripts.length).toBeGreaterThan(0); diff --git a/test/utils/deployment-url.ts b/test/utils/deployment-url.ts new file mode 100644 index 0000000000..475fcdbcde --- /dev/null +++ b/test/utils/deployment-url.ts @@ -0,0 +1,7 @@ +export function getDeploymentOrigin(): string { + let origin = process.env.DEPLOYMENT_URL ?? "https://app-staging.buildwithfern.com"; + if (!origin.startsWith("http")) { + origin = `${origin.includes("localhost") ? "http" : "https"}://${origin}`; + } + return origin; +}