From f5450116f6221028e2ba347b23005e01e1ee40ab Mon Sep 17 00:00:00 2001 From: Matthew White Date: Mon, 23 Sep 2024 17:57:30 -0400 Subject: [PATCH 1/2] Unskip tests by preventing additional entity.error --- test/integration/api/datasets.js | 12 ++++++------ test/integration/other/analytics-queries.js | 16 ++-------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/test/integration/api/datasets.js b/test/integration/api/datasets.js index b43a4188e..c66d41225 100644 --- a/test/integration/api/datasets.js +++ b/test/integration/api/datasets.js @@ -5545,7 +5545,7 @@ describe('datasets and entities', () => { })); describe('central issue #547, reprocessing submissions that had previous entity errors', () => { - it.skip('should not reprocess submission that previously generated entity.error', testService(async (service, container) => { + it('should not reprocess submission that previously generated entity.error', testService(async (service, container) => { const asAlice = await service.login('alice'); // Upload form that creates an entity list and publish it @@ -5559,10 +5559,10 @@ describe('datasets and entities', () => { .send({ approvalRequired: true }) .expect(200); - // Create a submission that fails to create an entity (bad UUID) + // Create a submission that fails to create an entity (empty label) await asAlice.post('/v1/projects/1/forms/simpleEntity/submissions') .send(testData.instances.simpleEntity.one - .replace('id="uuid:12345678-1234-4123-8234-123456789abc"', 'id="uuid:invalid_uuid"')) + .replace('Alice (88)', '')) .set('Content-Type', 'application/xml') .expect(200); @@ -5608,7 +5608,7 @@ describe('datasets and entities', () => { }); })); - it.skip('should reprocess submission that was edited after previously generating entity.error', testService(async (service, container) => { + it('should reprocess submission that was edited after previously generating entity.error', testService(async (service, container) => { const asAlice = await service.login('alice'); // Upload form that creates an entity list and publish it @@ -5622,10 +5622,10 @@ describe('datasets and entities', () => { .send({ approvalRequired: true }) .expect(200); - // Create a submission that fails to create an entity (bad UUID) + // Create a submission that fails to create an entity (empty label) await asAlice.post('/v1/projects/1/forms/simpleEntity/submissions') .send(testData.instances.simpleEntity.one - .replace('id="uuid:12345678-1234-4123-8234-123456789abc"', 'id="uuid:invalid_uuid"')) + .replace('Alice (88)', '')) .set('Content-Type', 'application/xml') .expect(200); diff --git a/test/integration/other/analytics-queries.js b/test/integration/other/analytics-queries.js index 924e6bf3b..6ad9f4ac4 100644 --- a/test/integration/other/analytics-queries.js +++ b/test/integration/other/analytics-queries.js @@ -993,24 +993,20 @@ describe('analytics task queries', function () { datasets[0].num_entities_recent.should.be.equal(1); })); - it.skip('should calculate failed entities', testService(async (service, container) => { + it('should calculate failed entities', testService(async (service, container) => { const asAlice = await service.login('alice'); await createTestForm(service, container, testData.forms.simpleEntity, 1); - await approvalRequired(service, 1, 'people'); await submitToForm(service, 'alice', 1, 'simpleEntity', testData.instances.simpleEntity.one); - await asAlice.patch('/v1/projects/1/forms/simpleEntity/submissions/one').send({ reviewState: 'approved' }); // let's pass invalid UUID await submitToForm(service, 'alice', 1, 'simpleEntity', testData.instances.simpleEntity.two.replace(/aaa/, 'xxx')); - await asAlice.patch('/v1/projects/1/forms/simpleEntity/submissions/two').send({ reviewState: 'approved' }); await exhaust(container); // let's set date of entity errors to long time ago await container.run(sql`UPDATE audits SET "loggedAt" = '1999-1-1' WHERE action = 'entity.error'`); await submitToForm(service, 'alice', 1, 'simpleEntity', testData.instances.simpleEntity.three.replace(/bbb/, 'xxx')); - await asAlice.patch('/v1/projects/1/forms/simpleEntity/submissions/three').send({ reviewState: 'approved' }); await exhaust(container); const datasets = await container.Analytics.getDatasets(); @@ -1589,7 +1585,7 @@ describe('analytics task queries', function () { res.projects[1].submissions.num_submissions_approved.total.should.equal(0); })); - it.skip('should fill in all project.datasets queries', testService(async (service, container) => { + it('should fill in all project.datasets queries', testService(async (service, container) => { const { defaultMaxListeners } = require('events').EventEmitter; require('events').EventEmitter.defaultMaxListeners = 30; @@ -1597,15 +1593,12 @@ describe('analytics task queries', function () { // Create first Dataset await createTestForm(service, container, testData.forms.simpleEntity, 1); - await approvalRequired(service, 1, 'people'); // Make submission for the first Dataset await submitToForm(service, 'alice', 1, 'simpleEntity', testData.instances.simpleEntity.one); - await asAlice.patch('/v1/projects/1/forms/simpleEntity/submissions/one').send({ reviewState: 'approved' }); // Create second Dataset using two forms await createTestForm(service, container, testData.forms.simpleEntity.replace(/simpleEntity|people/g, 'employees'), 1); - await approvalRequired(service, 1, 'employees'); await createTestForm(service, container, testData.forms.simpleEntity .replace(/simpleEntity/, 'employees2') .replace(/people/, 'employees') @@ -1613,12 +1606,10 @@ describe('analytics task queries', function () { // Make submissions for the second Datasets await submitToForm(service, 'alice', 1, 'employees', testData.instances.simpleEntity.two.replace(/simpleEntity|people/g, 'employees')); - await asAlice.patch('/v1/projects/1/forms/employees/submissions/two').send({ reviewState: 'approved' }); await submitToForm(service, 'alice', 1, 'employees2', testData.instances.simpleEntity.three .replace(/simpleEntity/, 'employees2') .replace(/people/, 'employees') .replace(/age/g, 'gender')); - await asAlice.patch('/v1/projects/1/forms/employees2/submissions/three').send({ reviewState: 'approved' }); // Expecting all Submissions should generate Entities await exhaust(container); @@ -1629,11 +1620,9 @@ describe('analytics task queries', function () { // Make a recent Submissions for the first Dataset // aaa -> ccc creates unique UUID await submitToForm(service, 'alice', 1, 'simpleEntity', testData.instances.simpleEntity.two.replace('aaa', 'ccc')); - await asAlice.patch('/v1/projects/1/forms/simpleEntity/submissions/two').send({ reviewState: 'approved' }); // bbb -> xxx causes invalid UUID, hence this Submission should not generate Entity await submitToForm(service, 'alice', 1, 'simpleEntity', testData.instances.simpleEntity.three.replace('bbb', 'xxx')); - await asAlice.patch('/v1/projects/1/forms/simpleEntity/submissions/three').send({ reviewState: 'approved' }); // One Entity will be created and one error will be logged await exhaust(container); @@ -1643,7 +1632,6 @@ describe('analytics task queries', function () { // Create new Submission that will cause entity creation error await submitToForm(service, 'alice', 1, 'simpleEntity', testData.instances.simpleEntity.three.replace(/bbb|three/g, 'xxx')); - await asAlice.patch('/v1/projects/1/forms/simpleEntity/submissions/xxx').send({ reviewState: 'approved' }); // One error will be logged await exhaust(container); From d36f9d0a80a1bdd738b1abca9e8636757d18af85 Mon Sep 17 00:00:00 2001 From: Matthew White Date: Wed, 25 Sep 2024 16:51:12 -0400 Subject: [PATCH 2/2] Fix lint errors --- test/integration/other/analytics-queries.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/integration/other/analytics-queries.js b/test/integration/other/analytics-queries.js index 6ad9f4ac4..1288134e6 100644 --- a/test/integration/other/analytics-queries.js +++ b/test/integration/other/analytics-queries.js @@ -71,12 +71,6 @@ const createTestForm = (service, container, xml, projectId) => .send(xml) .then(({ body }) => body.xmlFormId)); -const approvalRequired = (service, projectId, datasetName) => - service.login('alice', (asAlice) => - asAlice.patch(`/v1/projects/${projectId}/datasets/${datasetName}`) - .send({ approvalRequired: true }) - .expect(200)); - const createPublicLink = (service, projectId, xmlFormId) => service.login('alice', (asAlice) => asAlice.post(`/v1/projects/${projectId}/forms/${xmlFormId}/public-links`) @@ -994,8 +988,6 @@ describe('analytics task queries', function () { })); it('should calculate failed entities', testService(async (service, container) => { - const asAlice = await service.login('alice'); - await createTestForm(service, container, testData.forms.simpleEntity, 1); await submitToForm(service, 'alice', 1, 'simpleEntity', testData.instances.simpleEntity.one);