Skip to content

Commit

Permalink
add test for concurrent tag updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hotzevzl committed Nov 15, 2023
1 parent 058e391 commit 7f271af
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions api/apps/api/test/geo-features/geo-feature-tags.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,49 @@ describe('GeoFeatureTag PATCH (e2e)', () => {
expect(response.status).toBe(HttpStatus.OK);
await fixtures.ThenFeatureHasTag(projectId, featureId, equivalentTag);
});

/**
* @see MRXN23-316
*/
test('updating feature tags in a large batch of concurrent-ish operations should complete without errors', async () => {
// ARRANGE
const projectId = await fixtures.GivenProject('someProject');
// create an array of 100 features
const features = await Promise.all(
Array.from({ length: 100 }).map((featureId) =>
fixtures.GivenFeatureOnProject(projectId, `feature${featureId}`),
),
);
await Promise.all(
features.map((feature) =>
fixtures.GivenTagOnFeature(projectId, feature, 'oldTag'),
),
);
const newTag = 'newTag';

// ACT
const responses = await Promise.all(
features.map((feature) =>
fixtures.WhenPatchingAGeoFeatureTag(projectId, feature, newTag),
),
);

// ASSERT
responses.forEach((response) =>
expect(response.status).toBe(HttpStatus.OK),
);
responses.forEach((response) =>
expect(response.body.data.type).toBe('geo_features'),
);
responses.forEach((response) =>
expect(response.body.data.attributes.featureClassName).toBe(
'someFeature',
),
);
await Promise.all(
features.map((feature) =>
fixtures.ThenFeatureHasTag(projectId, feature, newTag),
),
);
});
});

0 comments on commit 7f271af

Please sign in to comment.