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

Extended submission is merged with submitter #858

Closed
matthew-white opened this issue May 5, 2023 · 0 comments · Fixed by #875
Closed

Extended submission is merged with submitter #858

matthew-white opened this issue May 5, 2023 · 0 comments · Fixed by #875
Assignees
Labels

Comments

@matthew-white
Copy link
Member

When a submission is requested with extended metadata, a submitter property is added to the response (the submission object). However, it looks like that submitter object is also merged with the submission object. The submission and the submitter share a couple of properties (createdAt and updatedAt), and as a result of the merge, it looks like the submission's properties are overwritten by the submitter's. For example, I added console.log(body) to the following test:

it('should return with extended metadata if requested', testService((service) =>
service.login('alice', (asAlice) =>
asAlice.post('/v1/projects/1/forms/simple/submissions')
.send(testData.instances.simple.one)
.set('Content-Type', 'text/xml')
.expect(200)
.then(() => asAlice.get('/v1/projects/1/forms/simple/submissions/one')
.set('X-Extended-Metadata', 'true')
.expect(200)
.then(({ body }) => {
body.should.be.an.ExtendedSubmission();
body.submitter.displayName.should.equal('Alice');
})))));

The body looked like this:

{
  instanceId: 'one',
  submitterId: 5,
  deviceId: null,
  createdAt: '2023-05-05T12:45:20.261Z',
  updatedAt: null,
  reviewState: null,
  userAgent: 'node-superagent/3.8.3',
  currentVersion: {
    submitterId: 5,
    createdAt: '2023-05-05T12:45:20.886Z',
    instanceName: null,
    instanceId: 'one',
    current: true,
    deviceId: null,
    userAgent: 'node-superagent/3.8.3',
    submitter: {
      id: 5,
      type: 'user',
      displayName: 'Alice',
      createdAt: '2023-05-05T12:45:20.261Z',
      updatedAt: null,
      deletedAt: null
    }
  },
  submitter: {
    id: 5,
    type: 'user',
    displayName: 'Alice',
    createdAt: '2023-05-05T12:45:20.261Z',
    updatedAt: null,
    deletedAt: null
  },
  id: 5,
  type: 'user',
  displayName: 'Alice',
  deletedAt: null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ done
Development

Successfully merging a pull request may close this issue.

2 participants