From af40af51f30cdf60c5d5285f255a3afea3616589 Mon Sep 17 00:00:00 2001 From: Diamond Lewis Date: Sun, 6 Apr 2025 21:01:36 -0500 Subject: [PATCH] ci: Fix flaky LiveQuery tests (#9694) --- spec/ParseLiveQuery.spec.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/spec/ParseLiveQuery.spec.js b/spec/ParseLiveQuery.spec.js index 807a9264..98d7e6a6 100644 --- a/spec/ParseLiveQuery.spec.js +++ b/spec/ParseLiveQuery.spec.js @@ -1173,14 +1173,18 @@ describe('ParseLiveQuery', function () { const client = await Parse.CoreManager.getLiveQueryController().getDefaultLiveQueryClient(); client.serverURL = 'ws://localhost:1345/1'; const query = await new Parse.Query('Yolo').subscribe(); + let liveQueryConnectionCount = await getConnectionsCount(server.liveQueryServer.server); + expect(liveQueryConnectionCount > 0).toBe(true); await Promise.all([ server.handleShutdown(), new Promise(resolve => query.on('close', resolve)), ]); - await new Promise(resolve => setTimeout(resolve, 100)); + await sleep(100); expect(server.liveQueryServer.server.address()).toBeNull(); expect(server.liveQueryServer.subscriber.isOpen).toBeFalse(); - await new Promise(resolve => server.server.close(resolve)); + + liveQueryConnectionCount = await getConnectionsCount(server.liveQueryServer.server); + expect(liveQueryConnectionCount).toBe(0); }); it_id('45655b74-716f-4fa1-a058-67eb21f3c3db')(it)('does shutdown separate liveQuery server', async () => { @@ -1245,7 +1249,7 @@ describe('ParseLiveQuery', function () { new Promise(resolve => query.on('close', resolve)), ]); expect(close).toBe(true); - await new Promise(resolve => setTimeout(resolve, 100)); + await sleep(100); expect(parseServer.liveQueryServer.server.address()).toBeNull(); expect(parseServer.liveQueryServer.subscriber.isOpen).toBeFalse();