From 90c6b69f7d0dea194bd066ab8e7e8b539005ae56 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Tue, 3 Jun 2025 22:33:04 +0200 Subject: [PATCH 1/3] fix --- integration/test/IdempotencyTest.js | 6 ++---- integration/test/ParseCloudTest.js | 4 +--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/integration/test/IdempotencyTest.js b/integration/test/IdempotencyTest.js index d8c546133..72e17bbdc 100644 --- a/integration/test/IdempotencyTest.js +++ b/integration/test/IdempotencyTest.js @@ -34,9 +34,8 @@ describe('Idempotency', () => { it('handle duplicate job request', async () => { DuplicateRequestId('1234'); - const params = { startedBy: 'Monty Python' }; - const jobStatusId = await Parse.Cloud.startJob('CloudJob1', params); - await expectAsync(Parse.Cloud.startJob('CloudJob1', params)).toBeRejectedWithError( + const jobStatusId = await Parse.Cloud.startJob('CloudJob1', {}); + await expectAsync(Parse.Cloud.startJob('CloudJob1', {})).toBeRejectedWithError( 'Duplicate request' ); @@ -49,7 +48,6 @@ describe('Idempotency', () => { } const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId); expect(jobStatus.get('status')).toBe('succeeded'); - expect(jobStatus.get('params').startedBy).toBe('Monty Python'); }); it('handle duplicate POST / PUT request', async () => { diff --git a/integration/test/ParseCloudTest.js b/integration/test/ParseCloudTest.js index c4704d00c..f117c61b1 100644 --- a/integration/test/ParseCloudTest.js +++ b/integration/test/ParseCloudTest.js @@ -94,14 +94,12 @@ describe('Parse Cloud', () => { }); it('run job', async () => { - const params = { startedBy: 'Monty Python' }; - const jobStatusId = await Parse.Cloud.startJob('CloudJob1', params); + const jobStatusId = await Parse.Cloud.startJob('CloudJob1', {}); expect(jobStatusId).toBeDefined(); await waitForJobStatus(jobStatusId, 'succeeded'); const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId); assert.equal(jobStatus.get('status'), 'succeeded'); - assert.equal(jobStatus.get('params').startedBy, 'Monty Python'); }); it('run long job', async () => { From 4e061ff880ac42b808c09e71abea50e0cff9bd2e Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Tue, 3 Jun 2025 23:43:34 +0200 Subject: [PATCH 2/3] check params in job message --- integration/test/IdempotencyTest.js | 6 ++++-- integration/test/ParseCloudTest.js | 6 ++++-- integration/test/cloud/main.js | 4 ++++ integration/test/helper.js | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/integration/test/IdempotencyTest.js b/integration/test/IdempotencyTest.js index 72e17bbdc..cb834bd4d 100644 --- a/integration/test/IdempotencyTest.js +++ b/integration/test/IdempotencyTest.js @@ -34,8 +34,9 @@ describe('Idempotency', () => { it('handle duplicate job request', async () => { DuplicateRequestId('1234'); - const jobStatusId = await Parse.Cloud.startJob('CloudJob1', {}); - await expectAsync(Parse.Cloud.startJob('CloudJob1', {})).toBeRejectedWithError( + const params = { startedBy: 'Monty Python' }; + const jobStatusId = await Parse.Cloud.startJob('CloudJobParamsInMessage', params); + await expectAsync(Parse.Cloud.startJob('CloudJobParamsInMessage', params)).toBeRejectedWithError( 'Duplicate request' ); @@ -48,6 +49,7 @@ describe('Idempotency', () => { } const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId); expect(jobStatus.get('status')).toBe('succeeded'); + expect(JSON.parse(jobStatus.get('message'))).toEqual(params); }); it('handle duplicate POST / PUT request', async () => { diff --git a/integration/test/ParseCloudTest.js b/integration/test/ParseCloudTest.js index f117c61b1..fdcbe58b5 100644 --- a/integration/test/ParseCloudTest.js +++ b/integration/test/ParseCloudTest.js @@ -94,12 +94,14 @@ describe('Parse Cloud', () => { }); it('run job', async () => { - const jobStatusId = await Parse.Cloud.startJob('CloudJob1', {}); + const params = { startedBy: 'Monty Python' }; + const jobStatusId = await Parse.Cloud.startJob('CloudJobParamsInMessage', params); expect(jobStatusId).toBeDefined(); await waitForJobStatus(jobStatusId, 'succeeded'); const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId); - assert.equal(jobStatus.get('status'), 'succeeded'); + expect(jobStatus.get('status')).toBe('succeeded'); + expect(JSON.parse(jobStatus.get('message'))).toEqual(params); }); it('run long job', async () => { diff --git a/integration/test/cloud/main.js b/integration/test/cloud/main.js index 920948d83..8641dda41 100644 --- a/integration/test/cloud/main.js +++ b/integration/test/cloud/main.js @@ -45,6 +45,10 @@ Parse.Cloud.job('CloudJob2', function () { }); }); +Parse.Cloud.job('CloudJobParamsInMessage', request => { + request.message(JSON.stringify(request.params)); +}); + Parse.Cloud.job('CloudJobFailing', function () { throw 'cloud job failed'; }); diff --git a/integration/test/helper.js b/integration/test/helper.js index 0bd7fb10a..46a257372 100644 --- a/integration/test/helper.js +++ b/integration/test/helper.js @@ -74,7 +74,7 @@ const defaultConfiguration = { }, }, idempotencyOptions: { - paths: ['functions/CloudFunctionIdempotency', 'jobs/CloudJob1', 'classes/IdempotentTest'], + paths: ['functions/CloudFunctionIdempotency', 'jobs/CloudJob1', 'jobs/CloudJobParamsInMessage', 'classes/IdempotentTest'], ttl: 120, }, fileUpload: { From 5b21a8cdffbe7f92d8bfc481b5ab3a625c65a784 Mon Sep 17 00:00:00 2001 From: Manuel Trezza <5673677+mtrezza@users.noreply.github.com> Date: Tue, 3 Jun 2025 23:49:13 +0200 Subject: [PATCH 3/3] fix jobs data test --- integration/test/ParseCloudTest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/test/ParseCloudTest.js b/integration/test/ParseCloudTest.js index fdcbe58b5..57d7db96d 100644 --- a/integration/test/ParseCloudTest.js +++ b/integration/test/ParseCloudTest.js @@ -137,7 +137,7 @@ describe('Parse Cloud', () => { it('get jobs data', done => { Parse.Cloud.getJobsData().then(result => { assert.equal(result.in_use.length, 0); - assert.equal(result.jobs.length, 3); + assert.equal(result.jobs.length, 4); done(); }); });