fix: set objects in afterFind triggers (#7311)

This commit is contained in:
dblythy
2021-10-09 11:34:09 +11:00
committed by GitHub
parent 197fcbda00
commit 68a3a87501
5 changed files with 115 additions and 15 deletions

View File

@@ -358,6 +358,44 @@ describe('ParseLiveQuery', function () {
await object.save();
});
it('can handle afterEvent set pointers', async done => {
await reconfigureServer({
liveQuery: {
classNames: ['TestObject'],
},
startLiveQueryServer: true,
verbose: false,
silent: true,
});
const object = new TestObject();
await object.save();
const secondObject = new Parse.Object('Test2');
secondObject.set('foo', 'bar');
await secondObject.save();
Parse.Cloud.afterLiveQueryEvent('TestObject', async ({ object }) => {
const query = new Parse.Query('Test2');
const obj = await query.first();
object.set('obj', obj);
});
const query = new Parse.Query(TestObject);
query.equalTo('objectId', object.id);
const subscription = await query.subscribe();
subscription.on('update', object => {
expect(object.get('obj')).toBeDefined();
expect(object.get('obj').get('foo')).toBe('bar');
done();
});
subscription.on('error', () => {
fail('error should not have been called.');
});
object.set({ foo: 'bar' });
await object.save();
});
it('can handle async afterEvent modification', async done => {
await reconfigureServer({
liveQuery: {