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

Make test client's fileUploadMutation work for more input variable shapes #3188

Merged

Conversation

toBeOfUse
Copy link
Contributor

Description

In the testing package, Vendure provides a SimpleGraphQLClient that has a function called fileUploadMutation. This function works for the built-in GraphQL mutations that accept file uploads, but if you add a custom mutation that accepts file inputs, as the docs show you how to do, you will run into problems, since it assumes that it can find the Upload inputs in the GraphQL variables just by looking at the first property of each nested object. So, for example, the existing code that creates the FormData body for the upload will go into an infinite loop if there are any string fields before the Upload fields in your GraphQL mutation input. I detailed the problem that I ran into with this in #1671.

So, this PR makes the fileUploadMutation method work with mutation inputs with arbitrary shapes.

Also, the two tests for this functionality that exist seem to be written for Jest, and there is no test command inside the testing package.json to run them. I converted the test file to Vitest and added the test command so that they could be run.

Breaking changes

None: the fileUploadMutation should work the same as it always had for the mutations it previously worked with, as shown by the two existing tests passing.

Checklist

📌 Always:

  • I have set a clear title
  • My PR is small and contains a single feature
  • I have checked my own PR

👍 Most of the time:

  • I have added or updated test cases
  • I have updated the README if needed

Copy link

vercel bot commented Nov 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview Nov 6, 2024 3:12am

Copy link

sonarqubecloud bot commented Nov 6, 2024

@michaelbromley michaelbromley merged commit a8938f4 into vendure-ecommerce:master Nov 8, 2024
29 of 30 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 8, 2024
@michaelbromley
Copy link
Member

Wow, I think this is my favourite PR of the week. Tricky investigation, complex code to fix, and even getting previously-lost tests back up and running again! Bravo and thanks so much for your continued contributions 🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants