Skip to content

Try to handle browser JSON responses more robustly #3305

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

myabc
Copy link
Contributor

@myabc myabc commented Feb 2, 2025

What are you trying to accomplish?

Sticking to Capybara's API for getting document text should (in theory) make this less likely to break in the event of a browser changing how it renders plain text/JSON responses.

Arguably, it also reads slightly better.

Screenshots

There should be no visual changes.

Integration

List the issues that this change affects.

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

Anything you want to highlight for special attention from reviewers?

Accessibility

  • Fixes axe scan violation - This change fixes an existing axe scan violation.
  • No new axe scan violation - This change does not introduce any new axe scan violations.
  • New axe violation - This change introduces a new axe scan violation. Please describe why the violation cannot be resolved below.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@myabc myabc requested a review from a team as a code owner February 2, 2025 03:28
@myabc myabc requested a review from TylerJDev February 2, 2025 03:28
Copy link

changeset-bot bot commented Feb 2, 2025

⚠️ No Changeset found

Latest commit: e27d310

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@myabc myabc force-pushed the feature/test-json-response-improvements branch from a3fc4ce to e37f0bc Compare February 2, 2025 03:34
@myabc
Copy link
Contributor Author

myabc commented Feb 4, 2025

This PR only touches test code so I'm not sure if we need a changeset?

@camertron
Copy link
Contributor

Hey @myabc, thanks for working on this, and apologies I missed it! It looks like system tests are failing in Firefox for some reason, would you be able to look into that? No need to add a changeset 😄

@camertron camertron added the skip changeset Pull requests that don't change the library output label Feb 12, 2025
Copy link
Member

@TylerJDev TylerJDev left a comment

Choose a reason for hiding this comment

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

Hey @myabc, thanks for the contribution!

I just wanted to follow up, as I see there's a failing test. I think that might be the last thing required here 😄

@myabc myabc force-pushed the feature/test-json-response-improvements branch from e37f0bc to a8771e9 Compare March 21, 2025 15:25
@myabc
Copy link
Contributor Author

myabc commented Mar 21, 2025

@TylerJDev Sorry for the delay in following up. I finally got a chance to look at the failing test. The issue was with waiting: while calling find("pre") waits, calling page.document.text does not. This was resolved in a driver-agnostic way by calling assert_current_path before asserting JSON values.

@myabc myabc requested a review from TylerJDev March 21, 2025 17:05
Adds `assert_json_response` and `json_response` helper method.

Sticking to Capybara's API for getting document text should (in theory)
make this less likely to break in the event of a browser changing how it
renders plain text/JSON responses.
@myabc myabc force-pushed the feature/test-json-response-improvements branch from a8771e9 to e27d310 Compare March 21, 2025 17:05
Copy link
Contributor

Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days.

@github-actions github-actions bot added the Stale Automatically marked as stale. label May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changeset Pull requests that don't change the library output Stale Automatically marked as stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants