-
Notifications
You must be signed in to change notification settings - Fork 53
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
Gql mock server #1071
Gql mock server #1071
Conversation
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.
Looks like good stuff! There are typos here and there, but no major complaints. It would be really nice to print out somewhere the number of calls to of each graphql mock for tracking redundant calls.
package.json
Outdated
@@ -18,7 +18,8 @@ | |||
"semantic-release": "semantic-release", | |||
"start": "craco start", | |||
"percy-serve": "serve", | |||
"percy-har-express": "har-express" | |||
"percy-har-express": "har-express", | |||
"percy-mock-server": "node ./percy/mock-server.js" |
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.
Maybe rename so we know which one is graphql?
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.
I can add combined to it, but this script runs the express server that hosts GraphQL and REST endpoints.
|
||
## Running and debugging the Percy tests | ||
You can run the Percy tests locally with this command: | ||
```OTP_RR_UI_MODE=normal npx percy exec -- npx jest percy/percy.test.js``` |
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.
Is env
needed before the env variables?
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.
This works for me. I think because this is a Bash command, it's okay. I am not sure about Windows.
percy/README.md
Outdated
|
||
You can disable headless mode by setting `headless: false` in the Puppeteer launch settings in `percy.test.js`. We left a line commented out which you can uncomment to achieve this. | ||
|
||
You can also debug the tests by creating a JavaScript Debug Terminal in the VSCode run pane, then running the above commands with breakpoints set in the editor. |
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.
Instead of "in the VSCode...", say "in IDEs that have that functionality"
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.
Might just remove the mention of IDEs entirely. There are probably multiple ways of doing this.
percy/graphql-mocks.js
Outdated
} | ||
} | ||
|
||
const mocks = { |
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.
Nice-to-have: Is that possible to output somewhere how many times each mock was used? Having previously all the responses in order helped highlight unnecessarily repeated web requests.
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.
I could write something to do that, it isn't a bad idea. I could put some assertions in the code for the number of times we expect each resolver to be called.
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.
Actually I can't do this very easily, the assertions won't work in the mocking server since it's run as a subprocess under the Percy tests. For some reason importing the server and running it directly in the Percy test doesn't work very well, it fails part way through.
I tried adding some code that logs the calls to each resolver at the end, but the function doesn't seem to be called.
Open to ideas here.
@daniel-heppner-ibigroup Also can you address the translation checks, please? |
I'd like to address the translation problems with Nearby View in the parent PR after this is merged into it. This is just to get the Percy Tests all working. Open to ideas on how to log or document the GraphQL requests made. |
Checkout screenshot 11/12! Something funky is going on there, not sure if it's related to these changes. Overall the result looks quite promising well done. I'm not fussed with graphql logging for now, I think we can deal with it later. Happy to approve this once we confirm what's going on with that itinerary body screenshot |
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.
Tiny bit of code cleanup too
After looking into it, I think the missing headsigns in the screenshot is actually correct, as we don't request it in the GraphQL query. The old HAR server would return the same response no matter what the GraphQL query was. At some point I guess we stopped requesting the trip.tripHeadsign in the plan query, but the HAR server kept returning it since we didn't update the response data. The new GraphQL server is smart, so it doesn't return it, which made the test look broken even though it's now actually more correct: we caught a bug! |
Good finding! |
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.
One last config cleanup and then I think we are ready to go! Thanks so much for all your work on this it looks great
percy/har-mock-config.yml
Outdated
reportIssue: | ||
mailto: [email protected] |
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.
This should go
Description:
Adds a GraphQL Mock server to the Percy tests.
PR Checklist:
| Before | After |
|--------|-------|
|
|
|