Skip to content

Commit

Permalink
added another test demonstrating a related issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Dec 3, 2024
1 parent b454891 commit afa7e1d
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/integration/api/offline-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -1771,5 +1771,52 @@ describe('Offline Entities', () => {
body[0].details.errorMessage.should.equal('Query returns an unexpected result.');
});
}));

it.only('should handle update from sub and update from API followed by delayed create', testOfflineEntities(async (service, container) => {

Check failure on line 1775 in test/integration/api/offline-entities.js

View workflow job for this annotation

GitHub Actions / standard-tests

it.only not permitted
// Issue c#808
const asAlice = await service.login('alice');
const branchId = uuid();

// Send first update
await asAlice.post('/v1/projects/1/forms/offlineEntity/submissions')
.send(testData.instances.offlineEntity.two
.replace('create="1"', 'update="1"')
.replace('branchId=""', `branchId="${branchId}"`)
.replace('two', 'two-update1')
.replace('baseVersion=""', 'baseVersion="1"')
.replace('<status>new</status>', '<status>checked in</status>')
)
.set('Content-Type', 'application/xml')
.expect(200);

await exhaust(container);

// Check backlog
const backlogCount = await container.oneFirst(sql`select count(*) from entity_submission_backlog`);
backlogCount.should.equal(1);

await container.Entities.processBacklog(true);

// Update entity via API
await asAlice.patch('/v1/projects/1/datasets/people/entities/12345678-1234-4123-8234-123456789ddd?baseVersion=1')
.send({ data: { age: '24' } })
.expect(200);

// Send registration
await asAlice.post('/v1/projects/1/forms/offlineEntity/submissions')
.send(testData.instances.offlineEntity.two)
.set('Content-Type', 'application/xml')
.expect(200);

await exhaust(container);

// Check submission audit log
await asAlice.get('/v1/projects/1/forms/offlineEntity/submissions/two/audits')
.expect(200)
.then(({ body }) => {
// TODO it should update the entity, not have this creation error
body[0].details.errorMessage.should.equal('Query returns an unexpected result.');
});
}));
});
});

0 comments on commit afa7e1d

Please sign in to comment.