Skip to content

Commit d2d0a58

Browse files
committed
fix: run LiveQuery query with stored where
1 parent 50bbc3d commit d2d0a58

2 files changed

Lines changed: 23 additions & 20 deletions

File tree

spec/ParseLiveQueryQuery.spec.js

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,24 @@ describe('ParseLiveQuery query operation', function () {
5757
if (parseWebSocket.sessionToken) {
5858
subscriptionInfo.sessionToken = parseWebSocket.sessionToken;
5959
}
60-
client.subscriptionInfos.set(requestId, subscriptionInfo);
60+
client.addSubscriptionInfo(requestId, subscriptionInfo);
61+
subscription.addClientSubscription(clientId, requestId);
6162

6263
return subscription;
6364
}
6465

66+
function createParseLiveQueryServer() {
67+
const { ParseLiveQueryServer } = require('../lib/LiveQuery/ParseLiveQueryServer');
68+
return new ParseLiveQueryServer(
69+
{},
70+
{
71+
appId: 'test',
72+
masterKey: 'test',
73+
serverURL: Parse.serverURL,
74+
}
75+
);
76+
}
77+
6578
it('can handle query command with existing subscription', async () => {
6679
await reconfigureServer({
6780
liveQuery: {
@@ -72,12 +85,7 @@ describe('ParseLiveQuery query operation', function () {
7285
silent: true,
7386
});
7487

75-
const { ParseLiveQueryServer } = require('../lib/LiveQuery/ParseLiveQueryServer');
76-
const parseLiveQueryServer = new ParseLiveQueryServer({
77-
appId: 'test',
78-
masterKey: 'test',
79-
serverURL: Parse.serverURL
80-
});
88+
const parseLiveQueryServer = createParseLiveQueryServer();
8189

8290
// Create test objects
8391
const TestObject = Parse.Object.extend('TestObject');
@@ -112,6 +120,8 @@ describe('ParseLiveQuery query operation', function () {
112120
await parseLiveQueryServer._handleQuery(parseWebSocket, request);
113121

114122
// Verify pushResult was called
123+
const Client = require('../lib/LiveQuery/Client').Client;
124+
expect(Client.pushError.calls.allArgs()).toEqual([]);
115125
expect(client.pushResult).toHaveBeenCalled();
116126
const results = client.pushResult.calls.mostRecent().args[1];
117127
expect(Array.isArray(results)).toBe(true);
@@ -158,12 +168,7 @@ describe('ParseLiveQuery query operation', function () {
158168
silent: true,
159169
});
160170

161-
const { ParseLiveQueryServer } = require('../lib/LiveQuery/ParseLiveQueryServer');
162-
const parseLiveQueryServer = new ParseLiveQueryServer({
163-
appId: 'test',
164-
masterKey: 'test',
165-
serverURL: Parse.serverURL
166-
});
171+
const parseLiveQueryServer = createParseLiveQueryServer();
167172

168173
// Create test object with multiple fields
169174
const TestObject = Parse.Object.extend('TestObject');
@@ -197,6 +202,8 @@ describe('ParseLiveQuery query operation', function () {
197202
await parseLiveQueryServer._handleQuery(parseWebSocket, request);
198203

199204
// Verify results
205+
const Client = require('../lib/LiveQuery/Client').Client;
206+
expect(Client.pushError.calls.allArgs()).toEqual([]);
200207
expect(client.pushResult).toHaveBeenCalled();
201208
const results = client.pushResult.calls.mostRecent().args[1];
202209
expect(results.length).toBe(1);
@@ -219,12 +226,7 @@ describe('ParseLiveQuery query operation', function () {
219226
silent: true,
220227
});
221228

222-
const { ParseLiveQueryServer } = require('../lib/LiveQuery/ParseLiveQueryServer');
223-
const parseLiveQueryServer = new ParseLiveQueryServer({
224-
appId: 'test',
225-
masterKey: 'test',
226-
serverURL: Parse.serverURL
227-
});
229+
const parseLiveQueryServer = createParseLiveQueryServer();
228230

229231
// Create test objects
230232
const TestObject = Parse.Object.extend('TestObject');
@@ -261,6 +263,8 @@ describe('ParseLiveQuery query operation', function () {
261263
await parseLiveQueryServer._handleQuery(parseWebSocket, request);
262264

263265
// Verify results
266+
const Client = require('../lib/LiveQuery/Client').Client;
267+
expect(Client.pushError.calls.allArgs()).toEqual([]);
264268
expect(client.pushResult).toHaveBeenCalled();
265269
const results = client.pushResult.calls.mostRecent().args[1];
266270
expect(results.length).toBe(1);

src/LiveQuery/ParseLiveQueryServer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,6 @@ class ParseLiveQueryServer {
14141414
const sessionToken = subscriptionInfo.sessionToken || client.sessionToken;
14151415
const parseQuery = new Parse.Query(className);
14161416
parseQuery.withJSON({
1417-
className,
14181417
where: query || {},
14191418
});
14201419

0 commit comments

Comments
 (0)