From ebe2777e6d2ea28f2def792ca38de074113e8189 Mon Sep 17 00:00:00 2001 From: zivchen Date: Sun, 22 Oct 2023 14:45:40 +0300 Subject: [PATCH 1/5] pass config object to parseObject function --- src/Routers/FunctionsRouter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Routers/FunctionsRouter.js b/src/Routers/FunctionsRouter.js index bb4b959ebe..eab76eeb1b 100644 --- a/src/Routers/FunctionsRouter.js +++ b/src/Routers/FunctionsRouter.js @@ -12,7 +12,7 @@ import { logger } from '../logger'; function parseObject(obj, config) { if (Array.isArray(obj)) { return obj.map(item => { - return parseObject(item); + return parseObject(item, config); }); } else if (obj && obj.__type == 'Date') { return Object.assign(new Date(obj.iso), obj); From 538c1097bab08ce870326dc673aa8f7e54d71d08 Mon Sep 17 00:00:00 2001 From: Colin Ulin <47982430+pocketcolin@users.noreply.github.com> Date: Mon, 11 Dec 2023 17:27:30 -0500 Subject: [PATCH 2/5] Add spec to verify parseObject missing config fix --- spec/ParseAPI.spec.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 9b1a97af87..984709408d 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -1267,6 +1267,35 @@ describe('miscellaneous', function () { }); }); + it('test cloud function query parameters with array of pointers', done => { + Parse.Cloud.define('echoParams', req => { + return req.params; + }); + const headers = { + 'Content-Type': 'application/json', + 'X-Parse-Application-Id': 'test', + 'X-Parse-Javascript-Key': 'test', + }; + request({ + method: 'POST', + headers: headers, + url: 'http://localhost:8378/1/functions/echoParams', //?option=1&other=2 + qs: { + option: 1, + other: 2, + }, + body: '{"foo":"bar", "other": 1, "arr": [{ "__type": "Pointer" }]}', + }).then(response => { + const res = response.data.result; + expect(res.option).toEqual('1'); + // Make sure query string params override body params + expect(res.other).toEqual('2'); + expect(res.foo).toEqual('bar'); + expect(res.arr.length).toEqual(1); + done(); + }); + }); + it('can handle null params in cloud functions (regression test for #1742)', done => { Parse.Cloud.define('func', request => { expect(request.params.nullParam).toEqual(null); From 4d2979e469acd365f03cc32d9eb5a6ac92916630 Mon Sep 17 00:00:00 2001 From: zivchen Date: Sun, 14 Jan 2024 14:43:01 +0200 Subject: [PATCH 3/5] Better test --- spec/ParseAPI.spec.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 984709408d..c100ca6e90 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -1267,7 +1267,7 @@ describe('miscellaneous', function () { }); }); - it('test cloud function query parameters with array of pointers', done => { + it('test cloud function query parameters with array of pointers', async done => { Parse.Cloud.define('echoParams', req => { return req.params; }); @@ -1276,24 +1276,16 @@ describe('miscellaneous', function () { 'X-Parse-Application-Id': 'test', 'X-Parse-Javascript-Key': 'test', }; - request({ + const response = await request({ method: 'POST', headers: headers, - url: 'http://localhost:8378/1/functions/echoParams', //?option=1&other=2 - qs: { - option: 1, - other: 2, - }, + url: 'http://localhost:8378/1/functions/echoParams', body: '{"foo":"bar", "other": 1, "arr": [{ "__type": "Pointer" }]}', - }).then(response => { - const res = response.data.result; - expect(res.option).toEqual('1'); - // Make sure query string params override body params - expect(res.other).toEqual('2'); - expect(res.foo).toEqual('bar'); - expect(res.arr.length).toEqual(1); - done(); }); + const res = response.data.result; + expect(res.foo).toEqual('bar'); + expect(res.arr.length).toEqual(1); + done(); }); it('can handle null params in cloud functions (regression test for #1742)', done => { From 56bf73980fc6de225a5abfec78821acc95202e3d Mon Sep 17 00:00:00 2001 From: zivchen Date: Mon, 15 Jan 2024 12:10:04 +0200 Subject: [PATCH 4/5] removed unnecessary props and add className --- spec/ParseAPI.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index c100ca6e90..885d131375 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -1280,10 +1280,9 @@ describe('miscellaneous', function () { method: 'POST', headers: headers, url: 'http://localhost:8378/1/functions/echoParams', - body: '{"foo":"bar", "other": 1, "arr": [{ "__type": "Pointer" }]}', + body: '{"arr": [{ "__type": "Pointer", "className": "PointerTest" }]}', }); const res = response.data.result; - expect(res.foo).toEqual('bar'); expect(res.arr.length).toEqual(1); done(); }); From ac33babf72bba61b884b661d130c3da2164a683a Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Mon, 15 Jan 2024 15:31:29 +0100 Subject: [PATCH 5/5] remove 'done' Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com> --- spec/ParseAPI.spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 885d131375..4f8190a4a6 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -1267,7 +1267,7 @@ describe('miscellaneous', function () { }); }); - it('test cloud function query parameters with array of pointers', async done => { + it('test cloud function query parameters with array of pointers', async () => { Parse.Cloud.define('echoParams', req => { return req.params; }); @@ -1284,7 +1284,6 @@ describe('miscellaneous', function () { }); const res = response.data.result; expect(res.arr.length).toEqual(1); - done(); }); it('can handle null params in cloud functions (regression test for #1742)', done => {