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

Upgrade USWDS to 3.8.0 #10333

Open
TomElliottFlexion opened this issue Mar 28, 2024 · 5 comments
Open

Upgrade USWDS to 3.8.0 #10333

TomElliottFlexion opened this issue Mar 28, 2024 · 5 comments
Assignees
Labels
Blocked The issue is blocked Devex

Comments

@TomElliottFlexion
Copy link
Collaborator

TomElliottFlexion commented Mar 28, 2024

Acceptance Criteria

  • USWDS is updated to version 3.8.0
  • Icon spacing issues are resolved (PR here)
  • Cypress does not lose styling in snapshots

Pain Avoided/Frustration Saved

  • Maintains ability to use Cypress for visual testing

Breadth/Pervasiveness of Problem

  • Funky icons are present throughout the UI, all Cypress tests affected

Complexity of Problem (Low, Medium, High) and Why it's Complex

  • ???

Notes

@Mwindo Mwindo self-assigned this Aug 5, 2024
@Mwindo
Copy link
Collaborator

Mwindo commented Aug 5, 2024

Wow, this was bizarre. The issue has nothing to do with any of the things listed above.

After some trial and error, I discovered the root of the problem is that there are new SVG icons bundled with USWDS that are interfering with how Cypress injects styles into the DOM snapshots. Here is an example of such an SVG icon:

Screenshot 2024-08-05 at 6.04.08 PM.png

The <style></style> section in particular is causing problems for Cypress. Here is the garbled CSS that we get within Cypress snapshots due to this "bad" SVG:

Screenshot 2024-08-05 at 5.47.23 PM.png

When I clean these SVGs up using svgo, the Cypress snapshot issues are resolved.

One way to fix this issue, then, is to use svgo, which is already a dependency of uswds, and clean up the images upon npm i. I.e., put this in package.json:

"postinstall": "husky install && cd ./node_modules/@uswds/uswds/dist/img && npx svgo -r ."

where the && portion is new. I've verified this works locally. I am not yet sure this is the best solution.

@Mwindo
Copy link
Collaborator

Mwindo commented Aug 6, 2024

I opened an issue with USDWS ("Clean up your SVGs, please!") and will ask the team if they have a better solution than the one I posted above.

@Mwindo
Copy link
Collaborator

Mwindo commented Aug 8, 2024

A quick finding:

While everything I said above still holds, I have been investigating what is happening on our end (e.g., when we bundle) that might be contributing to the issue (i.e., trying to answer the question "why are there not more reports of this error from other teams?").

Somehow, it seems the issue with Cypress styles and these SVGs has to do with the fact that they are loaded inline via our esbuild:

    loader: {
      '.html': 'text',
      '.pdf': 'file',
      '.png': 'dataurl',
      '.svg': 'dataurl',
      '.ttf': 'file',
      '.woff': 'file',
      '.woff2': 'file',
    },

If I switch from '.svg': 'dataurl' to '.svg': 'file' (and also set publicPath: '/' because otherwise Cypress cannot locate the image in the DOM via the relative import), everything works.

@Mwindo Mwindo added the Blocked The issue is blocked label Aug 12, 2024
@TomElliottFlexion TomElliottFlexion added the migration do not use label Aug 26, 2024
@TomElliottFlexion TomElliottFlexion moved this from New Issues to Devex/Opex in US Tax Court Board Aug 26, 2024
@TomElliottFlexion TomElliottFlexion removed the migration do not use label Aug 26, 2024
@Mwindo
Copy link
Collaborator

Mwindo commented Sep 26, 2024

Still waiting on USWDS, but there has been an update.

@Mwindo
Copy link
Collaborator

Mwindo commented Nov 6, 2024

Finally, an update!: uswds/uswds#6011. Looks like we should be able to update when they next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked The issue is blocked Devex
Projects
Status: Devex/Opex
Development

No branches or pull requests

2 participants