Skip to content

Commit

Permalink
update out of date entity test
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Jun 7, 2024
1 parent ac1b8d4 commit 67b646b
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions test/integration/api/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,30 +616,33 @@ describe('Entities API', () => {
});
}));

it('should get version source even when there is no corresponding create/update event', testEntities(async (service, container) => {
it('should get version source with source details even when there is no corresponding submission event', testEntities(async (service) => {
const asAlice = await service.login('alice');

await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc/versions')
.expect(200)
.then(({ body: versions }) => {
versions[0].should.have.property('source');
versions[0].source.submission.instanceId.should.equal('one');
versions[0].source.submission.should.have.property('currentVersion');
versions[0].source.event.action.should.equal('submission.update');
await asAlice.post('/v1/projects/1/datasets/people/entities')
.send({
source: {
name: 'people.csv',
size: 100,
},
entities: [
{
uuid: '12345678-1234-4123-8234-111111111aaa',
label: 'Johnny Doe',
data: {
first_name: 'Johnny',
age: '22'
}
},
]
});

// this is simulating an entity version that doesnt have a corresponding create event
// e.g. made through bulk create (coming soon)
// but that can still look up source details directly from source table
await container.run(sql`delete from audits where action = 'entity.create'`);

await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789abc/versions')
await asAlice.get('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-111111111aaa/versions')
.expect(200)
.then(({ body: versions }) => {
versions[0].should.have.property('source');
versions[0].source.should.eql({ submission: { instanceId: 'one' } });
versions[0].source.should.eql({ name: 'people.csv', size: 100, count: 1, userAgent: null });
});

}));

describe('relevantToConflict', () => {
Expand Down

0 comments on commit 67b646b

Please sign in to comment.