From bae035b130cd7e02fb91eb07b5f9c6db022650c6 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Wed, 9 Oct 2024 17:28:26 -0400 Subject: [PATCH] move webhooksTestPort out of global scope --- test/server/lib/DocApi.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/server/lib/DocApi.ts b/test/server/lib/DocApi.ts index 24ed9ec3..94ffb31a 100644 --- a/test/server/lib/DocApi.ts +++ b/test/server/lib/DocApi.ts @@ -76,6 +76,8 @@ function makeConfig(username: string): AxiosRequestConfig { } describe('DocApi', function () { + const webhooksTestPort = Number(process.env.WEBHOOK_TEST_PORT || 34365); + this.timeout(30000); testUtils.setTmpLogLevel('error'); let oldEnv: testUtils.EnvironmentSnapshot; @@ -121,7 +123,7 @@ describe('DocApi', function () { homeUrl = serverUrl = home.serverUrl; hasHomeApi = true; }); - testDocApi(); + testDocApi({webhooksTestPort}); }); describe('With GRIST_ANON_PLAYGROUND disabled', async () => { @@ -157,7 +159,7 @@ describe('DocApi', function () { homeUrl = serverUrl = home.serverUrl; hasHomeApi = true; }); - testDocApi(); + testDocApi({webhooksTestPort}); }); describe('behind a reverse-proxy', function () { @@ -206,7 +208,7 @@ describe('DocApi', function () { after(() => tearDown(proxy, [home, docs])); - testDocApi(); + testDocApi({webhooksTestPort}); }); async function testCompareDocs(proxy: TestServerReverseProxy, home: TestServer) { @@ -261,7 +263,7 @@ describe('DocApi', function () { serverUrl = docs.serverUrl; hasHomeApi = false; }); - testDocApi(); + testDocApi({webhooksTestPort}); }); } @@ -323,7 +325,10 @@ describe('DocApi', function () { }); // Contains the tests. This is where you want to add more test. -function testDocApi() { +function testDocApi(settings: { + webhooksTestPort: number, +}) { + const { webhooksTestPort } = settings; let chimpy: AxiosRequestConfig, kiwi: AxiosRequestConfig, charon: AxiosRequestConfig, nobody: AxiosRequestConfig, support: AxiosRequestConfig; @@ -5385,8 +5390,6 @@ async function getWorkspaceId(api: UserAPIImpl, name: string) { return workspaces.find((w) => w.name === name)!.id; } -const webhooksTestPort = Number(process.env.WEBHOOK_TEST_PORT || 34365); - async function setupDataDir(dir: string) { // we'll be serving Hello.grist content for various document ids, so let's make copies of it in // tmpDir