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

Cover integratin between search, table and root page #3

Closed
michal-murawski-90poe opened this issue Jan 24, 2023 · 5 comments
Closed

Comments

@michal-murawski-90poe
Copy link

We have some unit tests to cover the basic functionality of the view components. Now, we would like to test them all together.

Could you add an integration test (the best approach would be with @ testing-library/react), where we mock the apollo response for a specific query and assert the full async flow of a request? Again, we want to be sure that the expected user interaction works.

@louisotto
Copy link
Owner

Hi Michal,

This should be addressed in commit 1c354d0

Please run npm install before running the project to install the new dependencies.

I've run into a bug that really frustrated me, I hope you could help me understand what I've done wrong! I get the below error when running rpm run test

Expected variables: {"search":"react language:javascript stars:>10000 sort:stars"}

Failed to match 1 mock for this query. The mocked response had the following variables:
  {"search":"react language:javascript stars:>10000 sort:stars"}

Unless I'm mistaken, I'm submitting exactly what should be expected. I've gone through docs and helpful threads like this one: apollographql/react-apollo#617 but I can't find a solution.

Sorry to submit a failing piece of code but I'm really hoping you understand my confusion!

@michal-murawski-90poe
Copy link
Author

Hi Louis! Thanks for the message; I will look into it today, as yesterday I had a day off.

@michal-murawski-90poe
Copy link
Author

michal-murawski-90poe commented Feb 2, 2023

I had a moment to look into it. The solution to avoid this problem is to use the backslash escape character. The backslash \ escape character turns special characters into string characters.

mocks:

variables: {
        search: "react language:javascript stars\:\>10000 sort:stars",
      },

search

    variables: {
      search: `${search} language:javascript stars\:\>10000 sort:stars`,
    },

filter

          refetch({
            search: `${e.target.value} language:javascript stars\:\>10000 sort:stars`,
          });

@louisotto
Copy link
Owner

Hi Michal,

Apologies for the delay, I had some time off too :)

That's amazing, great catch. I didn't even consider looking at escaping because the terminal output matched, but this is something I'll remember in case it ever comes up again!

@louisotto
Copy link
Owner

Those should be fixed in 8acb04d along with a tidy up.

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

No branches or pull requests

2 participants