From ceefd8211e4edc1edec1afdbdbde28508a61cc86 Mon Sep 17 00:00:00 2001 From: fflorent Date: Tue, 14 May 2024 14:47:58 +0200 Subject: [PATCH] Achieved to make test that test doc worker work --- test/server/lib/DocApi.ts | 13 +++++++++---- test/server/lib/helpers/TestServer.ts | 5 ++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/test/server/lib/DocApi.ts b/test/server/lib/DocApi.ts index 3d9b1f854a..2db1fc9607 100644 --- a/test/server/lib/DocApi.ts +++ b/test/server/lib/DocApi.ts @@ -172,8 +172,10 @@ describe('DocApi', function () { ...overrideEnvConf }; const home = await TestServer.startServer('home', tmpDir, suitename, additionalEnvConfiguration); - const docs = await TestServer.startServer( - 'docs', tmpDir, suitename, additionalEnvConfiguration, home.serverUrl + const docs = await TestServer.startServer('docs', tmpDir, suitename, { + ...additionalEnvConfiguration, + APP_DOC_URL: `${await proxy.getServerUrl()}/dw/dw1`, + }, home.serverUrl ); proxy.requireFromOutsideHeader(); @@ -2915,7 +2917,7 @@ function testDocApi() { }); it('POST /workspaces/{wid}/import handles empty filenames', async function () { - if (!process.env.TEST_REDIS_URL || docs.proxiedServer) { + if (!process.env.TEST_REDIS_URL) { this.skip(); } const worker1 = await userApi.getWorkerAPI('import'); @@ -5356,7 +5358,10 @@ function setup(name: string, cb: () => Promise) { await cb(); // create TestDoc as an empty doc into Private workspace - userApi = api = home.makeUserApi(ORG_NAME); + userApi = api = home.makeUserApi(ORG_NAME, 'chimpy', { + headers: makeConfig('chimpy').headers as Record, + serverUrl + }); const wid = await getWorkspaceId(api, 'Private'); docIds.TestDoc = await api.newDoc({name: 'TestDoc'}, wid); }); diff --git a/test/server/lib/helpers/TestServer.ts b/test/server/lib/helpers/TestServer.ts index 959468598f..0ba24a2d83 100644 --- a/test/server/lib/helpers/TestServer.ts +++ b/test/server/lib/helpers/TestServer.ts @@ -88,6 +88,9 @@ export class TestServer { APP_HOME_INTERNAL_URL: homeUrl, GRIST_TESTING_SOCKET: this.testingSocket, GRIST_PORT: String(port), + ...(this._serverTypes.includes('docs') ? { + APP_DOC_INTERNAL_URL: this._serverUrl, + }: {}), ...this._defaultEnv, ...customEnv }; @@ -258,7 +261,7 @@ export class TestServerReverseProxy { } public async start(homeServer: TestServer, docServer: TestServer) { - this._app.all(['/dw/dw1', '/dw/dw1/*'], (oreq, ores) => this._getRequestHandlerFor(docServer)); + this._app.all(['/dw/dw1', '/dw/dw1/*'], this._getRequestHandlerFor(docServer)); this._app.all('/*', this._getRequestHandlerFor(homeServer)); // Forbid now the use of serverUrl property, so we don't allow the tests to