From 544522ca801a4b5964fbff9763d0bab542817bfc Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sun, 7 Jul 2024 16:10:17 -0500 Subject: [PATCH] test: Turn off randomizer --- spec/helper.js | 28 +++++++++++++++++++--------- spec/support/jasmine.json | 2 +- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/spec/helper.js b/spec/helper.js index 6b9db05cf2..80cbf9310d 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -113,6 +113,10 @@ const defaultConfiguration = { directAccess: true, silent, logLevel, + liveQuery: { + classNames: ['TestObject'], + }, + startLiveQueryServer: true, fileUpload: { enableForPublic: true, enableForAnonymousUser: true, @@ -162,15 +166,16 @@ const destroyAliveConnections = function () { } }; // Set up a default API server for testing with default configuration. -let server; - +let parseServer; let didChangeConfiguration = false; // Allows testing specific configurations of Parse Server const reconfigureServer = async (changedConfiguration = {}) => { - if (server) { - await new Promise(resolve => server.close(resolve)); - server = undefined; + if (parseServer) { + destroyAliveConnections(); + await parseServer.handleShutdown(); + await new Promise(resolve => parseServer.server.close(resolve)); + parseServer = undefined; return reconfigureServer(changedConfiguration); } didChangeConfiguration = Object.keys(changedConfiguration).length !== 0; @@ -179,14 +184,20 @@ const reconfigureServer = async (changedConfiguration = {}) => { port, }); cache.clear(); - const parseServer = await ParseServer.startApp(newConfiguration); - server = parseServer.server; + parseServer = await ParseServer.startApp(newConfiguration); Parse.CoreManager.setRESTController(RESTController); parseServer.expressApp.use('/1', err => { console.error(err); fail('should not call next'); }); - server.on('connection', connection => { + parseServer.liveQueryServer?.server?.on('connection', connection => { + const key = `${connection.remoteAddress}:${connection.remotePort}`; + openConnections[key] = connection; + connection.on('close', () => { + delete openConnections[key]; + }); + }); + parseServer.server.on('connection', connection => { const key = `${connection.remoteAddress}:${connection.remotePort}`; openConnections[key] = connection; connection.on('close', () => { @@ -223,7 +234,6 @@ afterEach(function (done) { if (Object.keys(openConnections).length > 0) { console.warn('There were open connections to the server left after the test finished'); } - destroyAliveConnections(); await TestUtils.destroyAllDataPermanently(true); SchemaCache.clear(); if (didChangeConfiguration) { diff --git a/spec/support/jasmine.json b/spec/support/jasmine.json index 84d7629c1b..1fbe0c31bf 100644 --- a/spec/support/jasmine.json +++ b/spec/support/jasmine.json @@ -2,5 +2,5 @@ "spec_dir": "spec", "spec_files": ["*spec.js"], "helpers": ["helper.js"], - "random": true + "random": false }