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

Testing: Trim block fixture HTML when generating other test fixture files #30981

Merged

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Apr 20, 2021

Description

Over in #30951 (comment) we noticed that when a new line exists at the end of an html fixture file, the parser interprets this as an empty block. 😱

The result is an empty block object in the parsed JSON (*.parsed.json files).

   {
        "blockName": null,
        "attrs": {},
        "innerBlocks": [],
        "innerHTML": "\n",
        "innerContent": [
            "\n"
        ]
    }

Trimming the output string of the HTML prevents this from occurring.

This PR trims the fixture HTML and regenerates our suite of fixtures to removing the hanging, empty blocks. 👍

How has this been tested?

By running the fixtures tests again:

npm run fixtures:regenerate test/integration/full-content/full-content.test.js

And making sure the fixtures are still valid.

And the unit tests just in case:

npm run test-unit

Types of changes

Non-breaking changes to fixture generation.

…interprets this as an empty block. The result is an empty block object in the resulting parsed JSON.

Trimming the output string of the HTML prevents this from occurring.
We're also re-generating the fixtures to remove the empty blocks.
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Interesting one, thank you for the fix 👍🏻

@gziolo gziolo added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Code Quality Issues or PRs that relate to code quality labels Apr 20, 2021
@gziolo gziolo changed the title Block fixtures: trim block fixture HTML when generating fixtures Testing: Trim block fixture HTML when generating other test fixture files Apr 20, 2021
@gziolo gziolo merged commit b3fe0be into WordPress:trunk Apr 20, 2021
@github-actions github-actions bot added this to the Gutenberg 10.5 milestone Apr 20, 2021
ramonjd added a commit to ramonjd/gutenberg that referenced this pull request Jul 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants