Skip to content

Commit f27d043

Browse files
authored
Merge branch 'alpha' into alpha
2 parents 42d3944 + c63e738 commit f27d043

15 files changed

+491
-220
lines changed

.github/dependabot.yml

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ updates:
1515
# Define dependencies to update
1616
allow:
1717
- dependency-name: "parse-server"
18+
# Allow both direct and indirect updates for all packages
19+
- dependency-type: "all"

changelogs/CHANGELOG_alpha.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [4.0.0-alpha.6](https://github.com/parse-community/Parse-SDK-JS/compare/4.0.0-alpha.5...4.0.0-alpha.6) (2023-01-27)
2+
3+
4+
### Bug Fixes
5+
6+
* Local datastore query with `containedIn` not working when field is an array ([#1666](https://github.com/parse-community/Parse-SDK-JS/issues/1666)) ([2391bff](https://github.com/parse-community/Parse-SDK-JS/commit/2391bff36bd8b3f5357f069916375b979cde15b2))
7+
18
# [4.0.0-alpha.5](https://github.com/parse-community/Parse-SDK-JS/compare/4.0.0-alpha.4...4.0.0-alpha.5) (2023-01-06)
29

310

integration/test/IdempotencyTest.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const Parse = require('../../node');
4+
const sleep = require('./sleep');
45

56
const Item = Parse.Object.extend('IdempotencyItem');
67
const RESTController = Parse.CoreManager.getRESTController();
@@ -47,6 +48,13 @@ describe('Idempotency', () => {
4748
'Duplicate request'
4849
);
4950

51+
const checkJobStatus = async () => {
52+
const result = await Parse.Cloud.getJobStatus(jobStatusId);
53+
return result && result.get('status') === 'succeeded';
54+
};
55+
while (!(await checkJobStatus())) {
56+
await sleep(100);
57+
}
5058
const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
5159
expect(jobStatus.get('status')).toBe('succeeded');
5260
expect(jobStatus.get('params').startedBy).toBe('Monty Python');

integration/test/ParseCloudTest.js

+25-27
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ const assert = require('assert');
44
const Parse = require('../../node');
55
const sleep = require('./sleep');
66

7+
const waitForJobStatus = async (jobStatusId, status) => {
8+
const checkJobStatus = async () => {
9+
const result = await Parse.Cloud.getJobStatus(jobStatusId);
10+
return result && result.get('status') === status;
11+
};
12+
while (!(await checkJobStatus())) {
13+
await sleep(100);
14+
}
15+
};
16+
717
describe('Parse Cloud', () => {
818
it('run function', done => {
919
const params = { key1: 'value2', key2: 'value1' };
@@ -83,32 +93,23 @@ describe('Parse Cloud', () => {
8393
});
8494
});
8595

86-
it('run job', done => {
96+
it('run job', async () => {
8797
const params = { startedBy: 'Monty Python' };
88-
Parse.Cloud.startJob('CloudJob1', params)
89-
.then(jobStatusId => {
90-
return Parse.Cloud.getJobStatus(jobStatusId);
91-
})
92-
.then(jobStatus => {
93-
assert.equal(jobStatus.get('status'), 'succeeded');
94-
assert.equal(jobStatus.get('params').startedBy, 'Monty Python');
95-
done();
96-
});
98+
const jobStatusId = await Parse.Cloud.startJob('CloudJob1', params);
99+
await waitForJobStatus(jobStatusId, 'succeeded');
100+
101+
const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
102+
assert.equal(jobStatus.get('status'), 'succeeded');
103+
assert.equal(jobStatus.get('params').startedBy, 'Monty Python');
97104
});
98105

99106
it('run long job', async () => {
100107
const jobStatusId = await Parse.Cloud.startJob('CloudJob2');
101108

102109
let jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
103110
assert.equal(jobStatus.get('status'), 'running');
111+
await waitForJobStatus(jobStatusId, 'succeeded');
104112

105-
const checkJobStatus = async () => {
106-
const result = await Parse.Cloud.getJobStatus(jobStatusId);
107-
return result && result.get('status') === 'succeeded';
108-
};
109-
while (!(await checkJobStatus())) {
110-
await sleep(100);
111-
}
112113
jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
113114
assert.equal(jobStatus.get('status'), 'succeeded');
114115
});
@@ -123,16 +124,13 @@ describe('Parse Cloud', () => {
123124
});
124125
});
125126

126-
it('run failing job', done => {
127-
Parse.Cloud.startJob('CloudJobFailing')
128-
.then(jobStatusId => {
129-
return Parse.Cloud.getJobStatus(jobStatusId);
130-
})
131-
.then(jobStatus => {
132-
assert.equal(jobStatus.get('status'), 'failed');
133-
assert.equal(jobStatus.get('message'), 'cloud job failed');
134-
done();
135-
});
127+
it('run failing job', async () => {
128+
const jobStatusId = await Parse.Cloud.startJob('CloudJobFailing');
129+
await waitForJobStatus(jobStatusId, 'failed');
130+
131+
const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
132+
assert.equal(jobStatus.get('status'), 'failed');
133+
assert.equal(jobStatus.get('message'), 'cloud job failed');
136134
});
137135

138136
it('get jobs data', done => {

integration/test/ParseDistTest.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
const puppeteer = require('puppeteer');
2+
let browser = null;
23
let page = null;
34
for (const fileName of ['parse.js', 'parse.min.js']) {
4-
beforeAll(async () => {
5-
const browser = await puppeteer.launch();
6-
page = await browser.newPage();
7-
await page.goto(`http://localhost:1337/${fileName}`);
8-
});
95
describe(`Parse Dist Test ${fileName}`, () => {
6+
beforeEach(async () => {
7+
browser = await puppeteer.launch();
8+
page = await browser.newPage();
9+
await page.goto(`http://localhost:1337/${fileName}`);
10+
});
11+
12+
afterEach(async () => {
13+
await page.close();
14+
await browser.close();
15+
});
16+
1017
it('can save an object', async () => {
1118
const response = await page.evaluate(async () => {
1219
const object = await new Parse.Object('TestObject').save();
@@ -17,6 +24,7 @@ for (const fileName of ['parse.js', 'parse.min.js']) {
1724
expect(obj).toBeDefined();
1825
expect(obj.id).toEqual(response);
1926
});
27+
2028
it('can query an object', async () => {
2129
const obj = await new Parse.Object('TestObject').save();
2230
const response = await page.evaluate(async () => {

integration/test/ParseLocalDatastoreTest.js

+60
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,66 @@ function runTest(controller) {
12271227
assert.equal(results[0].id, parent3.id);
12281228
});
12291229

1230+
it(`${controller.name} can handle containsAll query on array`, async () => {
1231+
const obj1 = new TestObject({ arrayField: [1, 2, 3, 4] });
1232+
const obj2 = new TestObject({ arrayField: [0, 2] });
1233+
const obj3 = new TestObject({ arrayField: [1, 2, 3] });
1234+
await Parse.Object.saveAll([obj1, obj2, obj3]);
1235+
await Parse.Object.pinAll([obj1, obj2, obj3]);
1236+
1237+
let query = new Parse.Query(TestObject);
1238+
query.containsAll('arrayField', [1, 2]);
1239+
query.fromPin();
1240+
let results = await query.find();
1241+
expect(results.length).toBe(2);
1242+
1243+
query = new Parse.Query(TestObject);
1244+
query.containsAll('arrayField', [5, 6]);
1245+
query.fromPin();
1246+
results = await query.find();
1247+
expect(results.length).toBe(0);
1248+
});
1249+
1250+
it(`${controller.name} can handle containedIn query on array`, async () => {
1251+
const obj1 = new TestObject({ arrayField: [1, 2, 3, 4] });
1252+
const obj2 = new TestObject({ arrayField: [0, 2] });
1253+
const obj3 = new TestObject({ arrayField: [1, 2, 3] });
1254+
await Parse.Object.saveAll([obj1, obj2, obj3]);
1255+
await Parse.Object.pinAll([obj1, obj2, obj3]);
1256+
1257+
let query = new Parse.Query(TestObject);
1258+
query.containedIn('arrayField', [3]);
1259+
query.fromPin();
1260+
let results = await query.find();
1261+
expect(results.length).toEqual(2);
1262+
1263+
query = new Parse.Query(TestObject);
1264+
query.containedIn('arrayField', [5]);
1265+
query.fromPin();
1266+
results = await query.find();
1267+
expect(results.length).toEqual(0);
1268+
});
1269+
1270+
it(`${controller.name} can handle notContainedIn query on array`, async () => {
1271+
const obj1 = new TestObject({ arrayField: [1, 2, 3, 4] });
1272+
const obj2 = new TestObject({ arrayField: [0, 2] });
1273+
const obj3 = new TestObject({ arrayField: [1, 2, 3] });
1274+
await Parse.Object.saveAll([obj1, obj2, obj3]);
1275+
await Parse.Object.pinAll([obj1, obj2, obj3]);
1276+
1277+
let query = new Parse.Query(TestObject);
1278+
query.notContainedIn('arrayField', [3]);
1279+
query.fromPin();
1280+
let results = await query.find();
1281+
expect(results.length).toEqual(1);
1282+
1283+
query = new Parse.Query(TestObject);
1284+
query.notContainedIn('arrayField', [5]);
1285+
query.fromPin();
1286+
results = await query.find();
1287+
expect(results.length).toEqual(3);
1288+
});
1289+
12301290
it(`${controller.name} can test equality with undefined`, async () => {
12311291
const query = new Parse.Query('BoxedNumber');
12321292
query.equalTo('number', undefined);

integration/test/ParseObjectTest.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,7 @@ describe('Parse Object', () => {
16741674
assert.equal(user.createdAt.getTime(), sameUser.createdAt.getTime());
16751675
assert.equal(user.updatedAt.getTime(), sameUser.updatedAt.getTime());
16761676
await Parse.User.logOut();
1677+
Parse.User.disableUnsafeCurrentUser();
16771678
});
16781679

16791680
it('can fetchAllIfNeededWithInclude', async () => {
@@ -2014,7 +2015,7 @@ describe('Parse Object', () => {
20142015
assert.equal(user.isDataAvailable(), true);
20152016

20162017
const query = new Parse.Query(Parse.User);
2017-
const fetched = await query.get(user.id);
2018+
const fetched = await query.get(user.id, { useMasterKey: true });
20182019
assert.equal(fetched.isDataAvailable(), true);
20192020
});
20202021

integration/test/ParseQueryTest.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -2365,7 +2365,15 @@ describe('Parse Query', () => {
23652365
query.hint('_id_');
23662366
query.explain();
23672367
const explain = await query.find();
2368-
assert.equal(explain.queryPlanner.winningPlan.inputStage.inputStage.indexName, '_id_');
2368+
let indexName = '';
2369+
// https://www.mongodb.com/docs/manual/reference/explain-results/#std-label-queryPlanner
2370+
const plan = explain.queryPlanner.winningPlan;
2371+
if (plan.inputStage) {
2372+
indexName = plan.inputStage.inputStage.indexName;
2373+
} else {
2374+
indexName = plan.queryPlan.inputStage.inputStage.indexName;
2375+
}
2376+
assert.equal(indexName, '_id_');
23692377
});
23702378

23712379
it('can query with select on null field', async () => {

integration/test/ParseSchemaTest.js

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ const defaultCLPS = {
2626
};
2727

2828
describe('Schema', () => {
29+
beforeEach(async () => {
30+
try {
31+
const schemas = await Parse.Schema.all();
32+
for (const result of schemas) {
33+
const schema = new Parse.Schema(result.className);
34+
await schema.purge();
35+
await schema.delete();
36+
}
37+
} catch (_) {
38+
// Schema not found
39+
}
40+
});
41+
2942
it('invalid get all no schema', done => {
3043
Parse.Schema.all()
3144
.then(() => {})

integration/test/ParseUserTest.js

+5
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ describe('Parse User', () => {
185185
});
186186

187187
it('cannot save non-authed user', done => {
188+
Parse.User.enableUnsafeCurrentUser();
188189
let user = new Parse.User();
189190
let notAuthed = null;
190191
user.set({
@@ -220,6 +221,7 @@ describe('Parse User', () => {
220221
});
221222

222223
it('cannot delete non-authed user', done => {
224+
Parse.User.enableUnsafeCurrentUser();
223225
let user = new Parse.User();
224226
let notAuthed = null;
225227
user
@@ -252,6 +254,7 @@ describe('Parse User', () => {
252254
});
253255

254256
it('cannot saveAll with non-authed user', done => {
257+
Parse.User.enableUnsafeCurrentUser();
255258
let user = new Parse.User();
256259
let notAuthed = null;
257260
user
@@ -435,6 +438,7 @@ describe('Parse User', () => {
435438
});
436439

437440
it('can query for users', done => {
441+
Parse.User.enableUnsafeCurrentUser();
438442
const user = new Parse.User();
439443
user.set('password', 'asdf');
440444
user.set('email', '[email protected]');
@@ -457,6 +461,7 @@ describe('Parse User', () => {
457461
});
458462

459463
it('preserves the session token when querying the current user', done => {
464+
Parse.User.enableUnsafeCurrentUser();
460465
const user = new Parse.User();
461466
user.set('password', 'asdf');
462467
user.set('email', '[email protected]');

integration/test/helper.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,14 @@ beforeAll(async () => {
166166

167167
afterEach(async () => {
168168
await Parse.User.logOut();
169+
// Connection close events are not immediate on node 10+... wait a bit
170+
await sleep(0);
171+
if (Object.keys(openConnections).length > 0) {
172+
console.warn('There were open connections to the server left after the test finished');
173+
}
169174
Parse.Storage._clear();
170175
await TestUtils.destroyAllDataPermanently(true);
171176
destroyAliveConnections();
172-
// Connection close events are not immediate on node 10+... wait a bit
173-
await sleep(0);
174177
if (didChangeConfiguration) {
175178
await reconfigureServer();
176179
}

0 commit comments

Comments
 (0)