Fix behing-proxy tests aren't running

The cause was that setup() first argument takes the name of the socket
used by home and doc servers to listen.
pull/915/head
fflorent 1 month ago
parent a7bae9a6ba
commit ac2857cd85

@ -79,12 +79,7 @@ describe('DocApi', function () {
before(async function () { before(async function () {
oldEnv = new testUtils.EnvironmentSnapshot(); oldEnv = new testUtils.EnvironmentSnapshot();
// Clear redis test database if redis is in use. await flushAllRedis();
if (process.env.TEST_REDIS_URL) {
const cli = createClient(process.env.TEST_REDIS_URL);
await cli.flushdbAsync();
await cli.quitAsync();
}
// Create the tmp dir removing any previous one // Create the tmp dir removing any previous one
await prepareFilesystemDirectoryForTests(tmpDir); await prepareFilesystemDirectoryForTests(tmpDir);
@ -173,7 +168,7 @@ describe('DocApi', function () {
} }
} }
} }
setup('separated', async () => { setup('behind-proxy', async () => {
proxy = new TestServerProxy(); proxy = new TestServerProxy();
const additionalEnvConfiguration = { const additionalEnvConfiguration = {
ALLOWED_WEBHOOK_DOMAINS: `example.com,localhost:${webhooksTestPort}`, ALLOWED_WEBHOOK_DOMAINS: `example.com,localhost:${webhooksTestPort}`,
@ -195,11 +190,12 @@ describe('DocApi', function () {
hasHomeApi = true; hasHomeApi = true;
}); });
after(() => { after(async () => {
proxy.stop(); proxy.stop();
iterateOverAccountHeaders((account) => { iterateOverAccountHeaders((account) => {
return originalHeaders.get(account)!; return originalHeaders.get(account)!;
}); });
await flushAllRedis();
}); });
testDocApi(); testDocApi();
@ -5284,6 +5280,7 @@ function setup(name: string, cb: () => Promise<void>) {
before(async function () { before(async function () {
suitename = name; suitename = name;
dataDir = path.join(tmpDir, `${suitename}-data`); dataDir = path.join(tmpDir, `${suitename}-data`);
await flushAllRedis();
await fse.mkdirs(dataDir); await fse.mkdirs(dataDir);
await setupDataDir(dataDir); await setupDataDir(dataDir);
await cb(); await cb();
@ -5330,3 +5327,12 @@ async function flushAuth() {
await home.testingHooks.flushAuthorizerCache(); await home.testingHooks.flushAuthorizerCache();
await docs.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();
}
}

@ -199,7 +199,7 @@ export class TestServer {
// FIXME: found that TestProxyServer exist, what should I do? :'( // FIXME: found that TestProxyServer exist, what should I do? :'(
export class TestServerProxy { 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 _stopped: boolean = false;
private _app = express(); private _app = express();

Loading…
Cancel
Save