fix: Parse.Cloud.startJob and Parse.Push.send not returning status ID when setting Parse Server option directAccess: true (#8766)

This commit is contained in:
Diamond Lewis
2024-04-14 14:42:20 -05:00
committed by GitHub
parent 6364948d81
commit 5b0efb22ef
2 changed files with 59 additions and 3 deletions

View File

@@ -631,4 +631,58 @@ describe('ParseServerRESTController', () => {
expect(sessions[0].get('installationId')).toBe(installationId);
expect(sessions[0].get('sessionToken')).toBe(loggedUser.sessionToken);
});
it('returns a statusId when running jobs', async () => {
Parse.Cloud.job('CloudJob', () => {
return 'Cloud job completed';
});
const res = await RESTController.request(
'POST',
'/jobs/CloudJob',
{},
{ useMasterKey: true, returnStatus: true }
);
const jobStatusId = res._headers['X-Parse-Job-Status-Id'];
expect(jobStatusId).toBeDefined();
const result = await Parse.Cloud.getJobStatus(jobStatusId);
expect(result.id).toBe(jobStatusId);
});
it('returns a statusId when running push notifications', async () => {
const payload = {
data: { alert: 'We return status!' },
where: { deviceType: 'ios' },
};
const res = await RESTController.request('POST', '/push', payload, {
useMasterKey: true,
returnStatus: true,
});
const pushStatusId = res._headers['X-Parse-Push-Status-Id'];
expect(pushStatusId).toBeDefined();
const result = await Parse.Push.getPushStatus(pushStatusId);
expect(result.id).toBe(pushStatusId);
});
it('returns a statusId when running batch push notifications', async () => {
const payload = {
data: { alert: 'We return status!' },
where: { deviceType: 'ios' },
};
const res = await RESTController.request('POST', 'batch', {
requests: [{
method: 'POST',
path: '/push',
body: payload,
}],
}, {
useMasterKey: true,
returnStatus: true,
});
const pushStatusId = res[0]._headers['X-Parse-Push-Status-Id'];
expect(pushStatusId).toBeDefined();
const result = await Parse.Push.getPushStatus(pushStatusId);
expect(result.id).toBe(pushStatusId);
});
});