Skip to content

Commit

Permalink
update test utils
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Oct 12, 2024
1 parent 61d8b96 commit c7fc2ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 2 additions & 4 deletions test/docs-e2e/nginx-proxy/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 3 additions & 3 deletions test/docs-e2e/skew-protection/index.test.ts
Original file line number Diff line number Diff line change
@@ -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<ReturnType<typeof chromium.launch>>;
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions test/utils/deployment-url.ts
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit c7fc2ed

Please sign in to comment.