Skip to content

Commit

Permalink
Respond to PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Oct 31, 2023
1 parent b4def7e commit 5ac66d9
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions test/integration/api/datasets.js
Original file line number Diff line number Diff line change
Expand Up @@ -2703,23 +2703,42 @@ describe('datasets and entities', () => {
});
}));

it('should create dataset if it does not exist and and log it', testService(async (service, { Audits }) => {
it('should create dataset if it does not exist and and log it', testService(async (service) => {
const asAlice = await service.login('alice');
await asAlice.post('/v1/projects/1/forms?publish=true')
await asAlice.post('/v1/projects/1/forms')
.send(testData.forms.updateEntity)
.set('Content-Type', 'text/xml')
.expect(200);

await asAlice.get('/v1/projects/1/forms/updateEntity/draft/dataset-diff')
.expect(200)
.then(({ body }) => {
body.should.be.eql([
{
name: 'people',
isNew: true, // Dataset is new
properties: [
{ name: 'first_name', isNew: true, inForm: true },
{ name: 'age', isNew: true, inForm: true }
]
}
]);
});

await asAlice.post('/v1/projects/1/forms/updateEntity/draft/publish');

await asAlice.get('/v1/projects/1/datasets/people')
.expect(200)
.then(({ body }) => {
body.name.should.be.eql('people');
body.properties.map(p => p.name).should.eql([ 'first_name', 'age' ]);
});

await Audits.getLatestByAction('dataset.create')
.then(o => o.get())
.then(audit => audit.details.should.eql({ properties: ['first_name', 'age'] }));
await asAlice.get('/v1/audits?action=dataset.create')
.expect(200)
.then(({ body: audits }) => {
audits[0].details.should.eql({ properties: ['first_name', 'age'] });
});
}));
});
});
Expand Down

0 comments on commit 5ac66d9

Please sign in to comment.