Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unskip tests by preventing additional entity.error #1196

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/integration/api/datasets.js
matthew-white marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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('<entities:label>Alice (88)</entities:label>', ''))
.set('Content-Type', 'application/xml')
.expect(200);

Expand Down Expand Up @@ -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
Expand All @@ -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('<entities:label>Alice (88)</entities:label>', ''))
.set('Content-Type', 'application/xml')
.expect(200);

Expand Down
24 changes: 2 additions & 22 deletions test/integration/other/analytics-queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down Expand Up @@ -993,24 +987,18 @@ describe('analytics task queries', function () {
datasets[0].num_entities_recent.should.be.equal(1);
}));

it.skip('should calculate failed entities', testService(async (service, container) => {
const asAlice = await service.login('alice');

it('should calculate failed entities', testService(async (service, container) => {
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();
Expand Down Expand Up @@ -1589,36 +1577,31 @@ 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;

const asAlice = await service.login('alice');

// 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')
.replace(/age/g, 'gender'), 1);

// 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);
Expand All @@ -1629,11 +1612,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);
Expand All @@ -1643,7 +1624,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);
Expand Down