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

Fix incorrect paths type on ConstraintFailure #275

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

ecooper
Copy link
Contributor

@ecooper ecooper commented Jul 17, 2024

Ticket(s): FE-5552

Problem

The type ConstraintFailure["paths"] was set to be Array<number | string>. However, the wire response for paths is actually an array of arrays. Anyone trying to interact with paths using the declared types would have a runtime error. The existing integration tests only check paths is defined.

Solution

Fix the the types to match the current response, and update the integration tests to actually test the array of array data structure. The expect statements were updated to use more "complex" matchers to reduce the number of assertions while visually documenting the data structures.

Result

The types now match the expected wire result and the integration tests validate that structure more concretely.

Out of scope

N/A.

Testing

Updated the existing constraint failure query tests.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@ptpaterson ptpaterson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

expect(e.constraint_failures).toEqual([
{
message: expect.any(String),
paths: expect.arrayContaining([expect.any(Array)]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out a simple way to assert the array contains String | Number. I guess we could extend expect but doesn't seem worth it. This is much improved already.

@ecooper ecooper merged commit 25bc766 into main Jul 17, 2024
5 checks passed
@ecooper ecooper deleted the incorrect-constraint-failure-types branch July 17, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants