diff --git a/test/server/lib/DocApi.ts b/test/server/lib/DocApi.ts index e59797d7..60ef23f1 100644 --- a/test/server/lib/DocApi.ts +++ b/test/server/lib/DocApi.ts @@ -79,12 +79,7 @@ describe('DocApi', function () { before(async function () { oldEnv = new testUtils.EnvironmentSnapshot(); - // Clear redis test database if redis is in use. - if (process.env.TEST_REDIS_URL) { - const cli = createClient(process.env.TEST_REDIS_URL); - await cli.flushdbAsync(); - await cli.quitAsync(); - } + await flushAllRedis(); // Create the tmp dir removing any previous one await prepareFilesystemDirectoryForTests(tmpDir); @@ -173,7 +168,7 @@ describe('DocApi', function () { } } } - setup('separated', async () => { + setup('behind-proxy', async () => { proxy = new TestServerProxy(); const additionalEnvConfiguration = { ALLOWED_WEBHOOK_DOMAINS: `example.com,localhost:${webhooksTestPort}`, @@ -195,11 +190,12 @@ describe('DocApi', function () { hasHomeApi = true; }); - after(() => { + after(async () => { proxy.stop(); iterateOverAccountHeaders((account) => { return originalHeaders.get(account)!; }); + await flushAllRedis(); }); testDocApi(); @@ -5284,6 +5280,7 @@ function setup(name: string, cb: () => Promise) { before(async function () { suitename = name; dataDir = path.join(tmpDir, `${suitename}-data`); + await flushAllRedis(); await fse.mkdirs(dataDir); await setupDataDir(dataDir); await cb(); @@ -5330,3 +5327,12 @@ async function flushAuth() { await home.testingHooks.flushAuthorizerCache(); await docs.testingHooks.flushAuthorizerCache(); } + +async function flushAllRedis() { + // Clear redis test database if redis is in use. + if (process.env.TEST_REDIS_URL) { + const cli = createClient(process.env.TEST_REDIS_URL); + await cli.flushdbAsync(); + await cli.quitAsync(); + } +} diff --git a/test/server/lib/helpers/TestServer.ts b/test/server/lib/helpers/TestServer.ts index ae4af2e4..e0a65d86 100644 --- a/test/server/lib/helpers/TestServer.ts +++ b/test/server/lib/helpers/TestServer.ts @@ -199,7 +199,7 @@ export class TestServer { // FIXME: found that TestProxyServer exist, what should I do? :'( export class TestServerProxy { - public static readonly HOSTNAME: string = 'grist-test-proxy.127.0.0.1.nip.io'; + public static readonly HOSTNAME: string = 'grist-test-proxy.localhost'; private _stopped: boolean = false; private _app = express();