-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(graphiql): Prettify also formats query variables #991
Conversation
Codecov Report
@@ Coverage Diff @@
## master #991 +/- ##
==========================================
- Coverage 43.14% 43.08% -0.07%
==========================================
Files 64 64
Lines 2934 2943 +9
Branches 635 637 +2
==========================================
+ Hits 1266 1268 +2
- Misses 1400 1406 +6
- Partials 268 269 +1
Continue to review full report at Codecov.
|
@benjie should I add some tests to increase coverage?) or I could just remove the code part which rid of unnecessary editors updates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @zouxuoz! Adding tests would be preferably; we have the beginnings of Cypress tests but I'm not sure if they're hooked up to code coverage or not (@acao?). Adding a test like those here: https://github.com/graphql/graphiql/blob/master/packages/graphiql/cypress/integration/init.spec.js would be great, testing the following circumstances:
- Regular prettification: enter ugly query and variables, click button, and check they are prettier
- Noop prettification: enter prettified query and variables, click button, and check that everything's unchanged (and no errors)
- No crash on bad query: enter broken query and ugly variables, click button, query should remain unchanged but variables should be prettier
- No crash on bad variables: enter ugly query and broken variables, click button, query should prettify but variables should remain unchanged.
Thanks so much 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems CI failed due to non-determinism in our existing tests - not your fault. This code looks great, simple, clean, does the job and well tested 👍
Please fix the query strings and then it's good to merge 👍
|
||
describe('GraphiQL Prettify', function() { | ||
it('Regular prettification', function() { | ||
cy.visit(`/?query=${uglyQuery}&variables=${uglyVaribles}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please escape the URLs; it doesn't seem to matter for these tests but it'll help future tests get it right 👍
cy.visit(`/?query=${uglyQuery}&variables=${uglyVaribles}`); | |
cy.visit(`/?query=${encodeURIComponent(uglyQuery)}&variables=${encodeURIComponent(uglyVaribles)}`); |
cy.expect(w.g.getVariableEditor().getValue()).to.equal(brokenVaribles); | ||
}) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent job of translating my list into tests! 🙌
@benjie Updated 🥳 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works beautifully. I'm going to ignore the codecov issues because I think we haven't got around to having Cypress contribute to that yet, and I'm satisfied the tests are fine.
Merged! Thanks 🎉 |
Closes #990
and rid of unnecessary editors updates when content not changed during prettification