diff --git a/lib/formats/odata.js b/lib/formats/odata.js index f71011a85..04a519f56 100644 --- a/lib/formats/odata.js +++ b/lib/formats/odata.js @@ -232,6 +232,8 @@ const edmxTemplaterForEntities = template(` + + diff --git a/test/integration/api/odata-entities.js b/test/integration/api/odata-entities.js index 70f816531..52e31ae5c 100644 --- a/test/integration/api/odata-entities.js +++ b/test/integration/api/odata-entities.js @@ -82,6 +82,46 @@ describe('api: /datasets/:name.svc', () => { }); })); + it('should return entity data that matches spec', testService(async (service, container) => { + const asAlice = await service.login('alice'); + + await asAlice.post('/v1/projects/1/forms?publish=true') + .set('Content-Type', 'application/xml') + .send(testData.forms.simpleEntity) + .expect(200); + + await createSubmissions(asAlice, container, 1); + + await createConflict(asAlice, container); + + await asAlice.get('/v1/projects/1/datasets/people.svc/Entities') + .expect(200) + .then(({ body }) => { + const entity = body.value[0]; + + // properties + entity.first_name.should.equal('Alicia'); + entity.age.should.equal('85'); + + // label + entity.label.should.equal('Alicia (85)'); + + // id + entity.__id.should.equal('12345678-1234-4123-8234-123456789abc'); + + // metadata/__system data + // if any of these change, they should also be updated in the emdx template + entity.should.have.property('__system'); + entity.__system.creatorId.should.equal('5'); + entity.__system.creatorName.should.equal('Alice'); + entity.__system.createdAt.should.be.a.recentIsoDate(); + entity.__system.updatedAt.should.be.a.recentIsoDate(); + entity.__system.updates.should.equal(2); + entity.__system.version.should.equal(3); + entity.__system.conflict.should.equal('hard'); + }); + })); + it('should return count of entities', testService(async (service, container) => { const asAlice = await service.login('alice'); @@ -465,6 +505,8 @@ describe('api: /datasets/:name.svc', () => { + +