From 9087dd7af61f7a2402b734d76094da79482235f2 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 18 Dec 2024 11:40:40 +0100 Subject: [PATCH] address feedback --- tests/config/proxy.ts | 6 +++--- tests/playwright-test/ui-mode-trace.spec.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/config/proxy.ts b/tests/config/proxy.ts index cb7663e65f..7efe389b12 100644 --- a/tests/config/proxy.ts +++ b/tests/config/proxy.ts @@ -59,11 +59,11 @@ export class TestProxy { await new Promise(x => this._server.close(x)); } - forwardTo(port: number, options?: { allowConnectRequests?: boolean, prefix?: string, dontTouchHost?: boolean }) { + forwardTo(port: number, options?: { allowConnectRequests?: boolean, prefix?: string, preserveHostname?: boolean }) { this._prependHandler('request', (req: IncomingMessage) => { this.requestUrls.push(req.url); const url = new URL(req.url, `http://${req.headers.host}`); - if (options?.dontTouchHost) + if (options?.preserveHostname) url.port = '' + port; else url.host = `127.0.0.1:${port}`; @@ -82,7 +82,7 @@ export class TestProxy { this._prependHandler('upgrade', (req: IncomingMessage) => { this.wsUrls.push(req.url); const url = new URL(req.url, `http://${req.headers.host}`); - if (options?.dontTouchHost) + if (options?.preserveHostname) url.port = '' + port; else url.host = `127.0.0.1:${port}`; diff --git a/tests/playwright-test/ui-mode-trace.spec.ts b/tests/playwright-test/ui-mode-trace.spec.ts index b354f66b50..b5b584da77 100644 --- a/tests/playwright-test/ui-mode-trace.spec.ts +++ b/tests/playwright-test/ui-mode-trace.spec.ts @@ -340,7 +340,7 @@ test('should show request source context id', async ({ runUITest, server }) => { await expect(page.getByText('api#1')).toBeVisible(); }); -test('should work behind proxy', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33705' } }, async ({ runUITest, proxyServer }, testInfo) => { +test('should work behind reverse proxy', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33705' } }, async ({ runUITest, proxyServer: reverseProxy }) => { const { page } = await runUITest({ 'a.test.ts': ` import { test, expect } from '@playwright/test'; @@ -352,9 +352,9 @@ test('should work behind proxy', { annotation: { type: 'issue', description: 'ht `, }); - const origin = new URL(page.url()); - proxyServer.forwardTo(+origin.port, { prefix: '/subdir', dontTouchHost: true }); - await page.goto(`${proxyServer.URL}/subdir${origin.pathname}?${origin.searchParams}`); + const uiModeUrl = new URL(page.url()); + reverseProxy.forwardTo(+uiModeUrl.port, { prefix: '/subdir', preserveHostname: true }); + await page.goto(`${reverseProxy.URL}/subdir${uiModeUrl.pathname}?${uiModeUrl.searchParams}`); await page.getByText('trace test').dblclick();