Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: test moved to correct test group #7717

Merged
merged 7 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,25 @@ describe('beforeFind hooks', () => {
});
});

it('should have object found with nested relational data query', async () => {
const obj1 = Parse.Object.extend('TestObject');
const obj2 = Parse.Object.extend('TestObject2');
let item2 = new obj2();
item2 = await item2.save();
let item1 = new obj1();
const relation = item1.relation('rel');
relation.add(item2);
item1 = await item1.save();
Parse.Cloud.beforeFind('TestObject', req => {
const additionalQ = new Parse.Query('TestObject');
additionalQ.equalTo('rel', item2);
return Parse.Query.and(req.query, additionalQ);
});
const q = new Parse.Query('TestObject');
const res = await q.first();
expect(res.id).toEqual(item1.id);
});

it('should use the modified exclude query', async () => {
Parse.Cloud.beforeFind('MyObject', req => {
const q = req.query;
Expand Down Expand Up @@ -3516,23 +3535,4 @@ describe('sendEmail', () => {
'Failed to send email because no mail adapter is configured for Parse Server.'
);
});

it('should have object found with nested relational data query', async () => {
const obj1 = Parse.Object.extend('TestObject');
const obj2 = Parse.Object.extend('TestObject2');
let item2 = new obj2();
item2 = await item2.save();
let item1 = new obj1();
const relation = item1.relation('rel');
relation.add(item2);
item1 = await item1.save();
Parse.Cloud.beforeFind('TestObject', req => {
const additionalQ = new Parse.Query('TestObject');
additionalQ.equalTo('rel', item2);
return Parse.Query.and(req.query, additionalQ);
});
const q = new Parse.Query('TestObject');
const res = await q.first();
expect(res.id).toEqual(item1.id);
});
});
4 changes: 2 additions & 2 deletions src/Controllers/DatabaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,9 +972,9 @@ class DatabaseController {
});
}
if (query['$and']) {
const ors = query['$and'];
const ands = query['$and'];
return Promise.all(
ors.map((aQuery, index) => {
ands.map((aQuery, index) => {
return this.reduceInRelation(className, aQuery, schema).then(aQuery => {
query['$and'][index] = aQuery;
});
Expand Down