Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/alpha' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza committed Jul 8, 2024
2 parents 70f63f7 + 3353998 commit 1d86f63
Show file tree
Hide file tree
Showing 13 changed files with 346 additions and 291 deletions.
7 changes: 7 additions & 0 deletions changelogs/CHANGELOG_alpha.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [7.1.0-alpha.16](https://github.com/parse-community/parse-server/compare/7.1.0-alpha.15...7.1.0-alpha.16) (2024-07-08)


### Features

* Add support for dot notation on array fields of Parse Object ([#9115](https://github.com/parse-community/parse-server/issues/9115)) ([cf4c880](https://github.com/parse-community/parse-server/commit/cf4c8807b9da87a0a5f9c94e5bdfcf17cda80cf4))

# [7.1.0-alpha.15](https://github.com/parse-community/parse-server/compare/7.1.0-alpha.14...7.1.0-alpha.15) (2024-07-08)


Expand Down
410 changes: 211 additions & 199 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "parse-server",
"version": "7.1.0-alpha.15",
"version": "7.1.0-alpha.16",
"description": "An express module providing a Parse-compatible API server",
"main": "lib/index.js",
"repository": {
Expand All @@ -25,7 +25,7 @@
"@graphql-tools/schema": "10.0.3",
"@graphql-tools/utils": "8.12.0",
"@parse/fs-files-adapter": "3.0.0",
"@parse/push-adapter": "6.4.0",
"@parse/push-adapter": "6.4.1",
"bcryptjs": "2.4.3",
"body-parser": "1.20.2",
"commander": "12.0.0",
Expand Down Expand Up @@ -144,7 +144,7 @@
"parse-server": "bin/parse-server"
},
"optionalDependencies": {
"@node-rs/bcrypt": "1.10.1"
"@node-rs/bcrypt": "1.10.4"
},
"collective": {
"type": "opencollective",
Expand Down
1 change: 0 additions & 1 deletion spec/CLI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ describe('execution', () => {
);
childProcess.stdout.on('data', data => {
data = data.toString();
console.log(data);
if (data.includes('parse-server running on')) {
done();
}
Expand Down
1 change: 0 additions & 1 deletion spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9709,7 +9709,6 @@ describe('ParseGraphQLServer', () => {
});
expect(res.status).toEqual(200);
const result = await res.json();
console.log(result);
expect(result.data.createSomeClass.someClass.someFileField.name).toEqual(
jasmine.stringMatching(/_someFileField.txt$/)
);
Expand Down
95 changes: 14 additions & 81 deletions spec/ParseLiveQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const UserController = require('../lib/Controllers/UserController').UserControll
const Config = require('../lib/Config');
const ParseServer = require('../lib/index').ParseServer;
const triggers = require('../lib/triggers');
const { resolvingPromise, sleep } = require('./support/testUtils');
const validatorFail = () => {
throw 'you are not authorized';
};
Expand All @@ -14,19 +15,9 @@ describe('ParseLiveQuery', function () {
});
afterEach(async () => {
const client = await Parse.CoreManager.getLiveQueryController().getDefaultLiveQueryClient();
client.close();
// Wait for live query client to disconnect
await new Promise(resolve => setTimeout(resolve, 1000));
await client.close();
});
it('access user on onLiveQueryEvent disconnect', async done => {
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});
const requestedUser = new Parse.User();
requestedUser.setUsername('username');
requestedUser.setPassword('password');
Expand All @@ -43,18 +34,10 @@ describe('ParseLiveQuery', function () {
const query = new Parse.Query(TestObject);
await query.subscribe();
const client = await Parse.CoreManager.getLiveQueryController().getDefaultLiveQueryClient();
client.close();
await client.close();
});

it('can subscribe to query', async done => {
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});
const object = new TestObject();
await object.save();

Expand Down Expand Up @@ -120,14 +103,6 @@ describe('ParseLiveQuery', function () {
});

it('expect afterEvent payload', async done => {
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});
const object = new TestObject();
await object.save();

Expand All @@ -147,14 +122,6 @@ describe('ParseLiveQuery', function () {
});

it('expect afterEvent enter', async done => {
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('enter');
expect(req.user).toBeUndefined();
Expand All @@ -178,14 +145,6 @@ describe('ParseLiveQuery', function () {
});

it('expect afterEvent leave', async done => {
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('leave');
expect(req.user).toBeUndefined();
Expand All @@ -210,14 +169,6 @@ describe('ParseLiveQuery', function () {
});

it('expect afterEvent delete', async done => {
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
expect(req.event).toBe('delete');
expect(req.user).toBeUndefined();
Expand Down Expand Up @@ -365,30 +316,18 @@ describe('ParseLiveQuery', function () {
);
});

it('can handle afterEvent sendEvent to false', async done => {
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});

it('can handle afterEvent sendEvent to false', async () => {
const object = new TestObject();
await object.save();

const promise = resolvingPromise();
Parse.Cloud.afterLiveQueryEvent('TestObject', req => {
const current = req.object;
const original = req.original;

setTimeout(() => {
done();
}, 2000);

if (current.get('foo') != original.get('foo')) {
req.sendEvent = false;
}
promise.resolve();
});

const query = new Parse.Query(TestObject);
Expand All @@ -402,9 +341,10 @@ describe('ParseLiveQuery', function () {
});
object.set({ foo: 'bar' });
await object.save();
await promise;
});

xit('can handle live query with fields - enable upon JS SDK support', async () => {
it('can handle live query with fields', async () => {
await reconfigureServer({
liveQuery: {
classNames: ['Test'],
Expand Down Expand Up @@ -442,7 +382,7 @@ describe('ParseLiveQuery', function () {
await obj2.save();
obj2.set('foo', 'bart');
await obj2.save();
await new Promise(resolve => setTimeout(resolve, 2000));
await sleep(2000);
expect(createSpy).toHaveBeenCalledTimes(1);
expect(updateSpy).toHaveBeenCalledTimes(1);
});
Expand Down Expand Up @@ -771,14 +711,6 @@ describe('ParseLiveQuery', function () {
});

it('can handle select beforeSubscribe query', async done => {
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});
Parse.Cloud.beforeSubscribe(TestObject, request => {
const query = request.query;
query.select('yolo');
Expand Down Expand Up @@ -857,7 +789,7 @@ describe('ParseLiveQuery', function () {
object.set({ foo: 'bar' });
await object.save();
await object.destroy();
await new Promise(resolve => setTimeout(resolve, 200));
await sleep(200);
for (const key in calls) {
expect(calls[key]).toHaveBeenCalled();
}
Expand Down Expand Up @@ -891,9 +823,9 @@ describe('ParseLiveQuery', function () {
object.set({ foo: 'bar' });
await object.save(null, { useMasterKey: true });
role.getUsers().add(user);
await new Promise(resolve => setTimeout(resolve, 1000));
await sleep(1000);
await role.save();
await new Promise(resolve => setTimeout(resolve, 1000));
await sleep(1000);
object.set('foo', 'yolo');
await Promise.all([
new Promise(resolve => {
Expand Down Expand Up @@ -924,7 +856,6 @@ describe('ParseLiveQuery', function () {
const subscription = await query.subscribe();

subscription.on('create', async obj => {
await new Promise(resolve => setTimeout(resolve, 200));
expect(obj.get('user').id).toBe(user.id);
expect(obj.get('createdWith')).toEqual({ action: 'login', authProvider: 'password' });
expect(obj.get('expiresAt')).toBeInstanceOf(Date);
Expand Down Expand Up @@ -1227,6 +1158,8 @@ describe('ParseLiveQuery', function () {
classNames: ['Yolo'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
};
if (process.env.PARSE_SERVER_TEST_DB === 'postgres') {
config.databaseAdapter = new databaseAdapter.constructor({
Expand Down
64 changes: 64 additions & 0 deletions spec/ParseObject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,70 @@ describe('Parse.Object testing', () => {
);
});

it_only_db('mongo')('can increment array nested fields', async () => {
const obj = new TestObject();
obj.set('items', [ { value: 'a', count: 5 }, { value: 'b', count: 1 } ]);
await obj.save();
obj.increment('items.0.count', 15);
obj.increment('items.1.count', 4);
await obj.save();
expect(obj.toJSON().items[0].value).toBe('a');
expect(obj.toJSON().items[1].value).toBe('b');
expect(obj.toJSON().items[0].count).toBe(20);
expect(obj.toJSON().items[1].count).toBe(5);
const query = new Parse.Query(TestObject);
const result = await query.get(obj.id);
expect(result.get('items')[0].value).toBe('a');
expect(result.get('items')[1].value).toBe('b');
expect(result.get('items')[0].count).toBe(20);
expect(result.get('items')[1].count).toBe(5);
expect(result.get('items')).toEqual(obj.get('items'));
});

it_only_db('mongo')('can increment array nested fields missing index', async () => {
const obj = new TestObject();
obj.set('items', []);
await obj.save();
obj.increment('items.1.count', 15);
await obj.save();
expect(obj.toJSON().items[0]).toBe(null);
expect(obj.toJSON().items[1].count).toBe(15);
const query = new Parse.Query(TestObject);
const result = await query.get(obj.id);
expect(result.get('items')[0]).toBe(null);
expect(result.get('items')[1].count).toBe(15);
expect(result.get('items')).toEqual(obj.get('items'));
});

it('can query array nested fields', async () => {
const objects = [];
for (let i = 0; i < 10; i++) {
const obj = new TestObject();
obj.set('items', [i, { value: i }]);
objects.push(obj);
}
await Parse.Object.saveAll(objects);
let query = new Parse.Query(TestObject);
query.greaterThan('items.1.value', 5);
let result = await query.find();
expect(result.length).toBe(4);

query = new Parse.Query(TestObject);
query.lessThan('items.0', 3);
result = await query.find();
expect(result.length).toBe(3);

query = new Parse.Query(TestObject);
query.equalTo('items.0', 5);
result = await query.find();
expect(result.length).toBe(1);

query = new Parse.Query(TestObject);
query.notEqualTo('items.0', 5);
result = await query.find();
expect(result.length).toBe(9);
});

it('addUnique with object', function (done) {
const x1 = new Parse.Object('X');
x1.set('stuff', [1, { hello: 'world' }, { foo: 'bar' }]);
Expand Down
4 changes: 2 additions & 2 deletions spec/ParseQuery.Comment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ describe_only_db('mongo')('Parse.Query with comment testing', () => {
database = client.db('parseServerMongoAdapterTestDatabase');
let profiler = await database.command({ profile: 0 });
expect(profiler.was).toEqual(0);
console.log(`Disabling profiler : ${profiler.was}`);
// console.log(`Disabling profiler : ${profiler.was}`);
profiler = await database.command({ profile: profileLevel });
profiler = await database.command({ profile: -1 });
console.log(`Enabling profiler : ${profiler.was}`);
// console.log(`Enabling profiler : ${profiler.was}`);
profiler = await database.command({ profile: -1 });
expect(profiler.was).toEqual(profileLevel);
});
Expand Down
1 change: 1 addition & 0 deletions spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const defaultConfiguration = {
fileKey: 'test',
directAccess: true,
silent,
verbose: !silent,
logLevel,
liveQuery: {
classNames: ['TestObject'],
Expand Down
18 changes: 18 additions & 0 deletions spec/support/testUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Create Deferred Promise
function resolvingPromise() {
let res;
let rej;
const promise = new Promise((resolve, reject) => {
res = resolve;
rej = reject;
});
promise.resolve = res;
promise.reject = rej;
return promise;
}

function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

module.exports = { resolvingPromise, sleep };
Loading

0 comments on commit 1d86f63

Please sign in to comment.