Skip to content

Commit

Permalink
Tests: Remove originalContent from fixtures (#38638)
Browse files Browse the repository at this point in the history
Previously we've been asserting in our full-content snapshot tests that
the `originalContent` property doesn't change, but it's faulty and going
away (see #38460).

By removing it from the test fixtures we can relax our constraint that
it exists and doesn't change, leaving future work easier to review and focus.

This is a generated property while loading the blocks and use of it leads
to content corruption and loss on certain invalid blocks and blocks with
inner blocks.

After this change we're still veryifying the full load and save flow
for the block implementations.
  • Loading branch information
dmsnell committed Feb 9, 2022
1 parent feda816 commit 5c5e292
Show file tree
Hide file tree
Showing 246 changed files with 346 additions and 681 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"attributes": {
"content": "<p><!-- wp:core/4-invalid /--></p>"
},
"innerBlocks": [],
"originalContent": "<p><!-- wp:core/4-invalid /--></p>"
"innerBlocks": []
}
]
3 changes: 1 addition & 2 deletions test/integration/fixtures/blocks/core__archives.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"displayAsDropdown": false,
"showPostCounts": false
},
"innerBlocks": [],
"originalContent": ""
"innerBlocks": []
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"displayAsDropdown": false,
"showPostCounts": true
},
"innerBlocks": [],
"originalContent": ""
"innerBlocks": []
}
]
3 changes: 1 addition & 2 deletions test/integration/fixtures/blocks/core__audio.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"loop": false,
"align": "right"
},
"innerBlocks": [],
"originalContent": "<figure class=\"wp-block-audio alignright\">\n <audio controls=\"\" src=\"data:audio/mpeg;base64,/+MYxAAAAANIAAAAAExBTUUzLjk4LjIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"></audio>\n</figure>"
"innerBlocks": []
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"autoplay": false,
"loop": false
},
"innerBlocks": [],
"originalContent": "<figure class=\"wp-block-audio\"><audio controls></audio></figure>"
"innerBlocks": []
}
]
3 changes: 1 addition & 2 deletions test/integration/fixtures/blocks/core__block.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"attributes": {
"ref": 123
},
"innerBlocks": [],
"originalContent": ""
"innerBlocks": []
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
}
}
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button is-style-outline\"><a class=\"wp-block-button__link has-text-color\" style=\"color:#1b9b6c;border-radius:10px;\">Where We Are</a></div>"
"innerBlocks": []
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
}
}
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\" style=\"border-radius:25px\">My button</a></div>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -21,7 +20,6 @@
"attributes": {
"content": ""
},
"innerBlocks": [],
"originalContent": "</div>"
"innerBlocks": []
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"text": "Help build Gutenberg",
"align": "center"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button aligncenter\"><a class=\"wp-block-button__link\" href=\"https://github.com/WordPress/gutenberg\">Help build Gutenberg</a></div>"
"innerBlocks": []
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"text": "My button",
"fontFamily": "cambria-georgia"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\" style=\"font-family:var(--wp--preset--font-family--cambria-georgia)\"><a class=\"wp-block-button__link\">My button</a></div>"
"innerBlocks": []
}
]
3 changes: 1 addition & 2 deletions test/integration/fixtures/blocks/core__button__squared.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
}
}
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link no-border-radius has-text-color has-background\" style=\"background-color:#aa5a20;color:#1b9b6c\">My button</a></div>"
"innerBlocks": []
}
]
9 changes: 3 additions & 6 deletions test/integration/fixtures/blocks/core__buttons.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"attributes": {
"text": "My button 1"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 1</a></div>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -28,10 +27,8 @@
"attributes": {
"text": "My button 2"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 2</a></div>"
"innerBlocks": []
}
],
"originalContent": "<div class=\"wp-block-buttons alignwide\">\n\t\n\n\t\n</div>"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"attributes": {
"text": "My button 1"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 1</a></div>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -27,10 +26,8 @@
"attributes": {
"text": "My button 2"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 2</a></div>"
"innerBlocks": []
}
],
"originalContent": "<div class=\"wp-block-buttons aligncenter\">\n\t\n\n\t\n</div>"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"attributes": {
"text": "My button 1"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 1</a></div>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -29,10 +28,8 @@
"attributes": {
"text": "My button 2"
},
"innerBlocks": [],
"originalContent": "<div class=\"wp-block-button\"><a class=\"wp-block-button__link\">My button 2</a></div>"
"innerBlocks": []
}
],
"originalContent": "<div class=\"wp-block-buttons alignwide is-content-justification-center\">\n\t\n\n\t\n</div>"
]
}
]
3 changes: 1 addition & 2 deletions test/integration/fixtures/blocks/core__calendar.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"name": "core/calendar",
"isValid": true,
"attributes": {},
"innerBlocks": [],
"originalContent": ""
"innerBlocks": []
}
]
3 changes: 1 addition & 2 deletions test/integration/fixtures/blocks/core__categories.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"showPostCounts": false,
"showOnlyTopLevel": false
},
"innerBlocks": [],
"originalContent": ""
"innerBlocks": []
}
]
3 changes: 1 addition & 2 deletions test/integration/fixtures/blocks/core__code.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"attributes": {
"content": "export default function MyButton() {\n\treturn &lt;Button&gt;Click Me!&lt;/Button&gt;;\n}"
},
"innerBlocks": [],
"originalContent": "<pre class=\"wp-block-code\"><code>export default function MyButton() {\n\treturn &lt;Button&gt;Click Me!&lt;/Button&gt;;\n}</code></pre>"
"innerBlocks": []
}
]
9 changes: 3 additions & 6 deletions test/integration/fixtures/blocks/core__column.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"content": "Column One, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph One</p>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -24,10 +23,8 @@
"content": "Column One, Paragraph Two",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph Two</p>"
"innerBlocks": []
}
],
"originalContent": "<div class=\"wp-block-column\">\n\t\n\t\n</div>"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"content": "Column One, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph One</p>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -26,10 +25,8 @@
"content": "Column One, Paragraph Two",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph Two</p>"
"innerBlocks": []
}
],
"originalContent": "<div class=\"wp-block-column\" style=\"flex-basis:33.33%\">\n\t\n\t\n</div>"
]
}
]
21 changes: 7 additions & 14 deletions test/integration/fixtures/blocks/core__columns.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"content": "Column One, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph One</p>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -33,11 +32,9 @@
"content": "Column One, Paragraph Two",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph Two</p>"
"innerBlocks": []
}
],
"originalContent": "<div class=\"wp-block-column\">\n\t\t\n\t\t\n\t</div>"
]
},
{
"clientId": "_clientId_1",
Expand All @@ -53,8 +50,7 @@
"content": "Column Two, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column Two, Paragraph One</p>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -64,13 +60,10 @@
"content": "Column Three, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column Three, Paragraph One</p>"
"innerBlocks": []
}
],
"originalContent": "<div class=\"wp-block-column\">\n\t\t\n\t\t\n\t</div>"
]
}
],
"originalContent": "<div class=\"wp-block-columns has-background has-secondary-background-color\">\n\t\n\t\n</div>"
]
}
]
15 changes: 5 additions & 10 deletions test/integration/fixtures/blocks/core__columns__deprecated.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"dropCap": false,
"className": "layout-column-1"
},
"innerBlocks": [],
"originalContent": "<p class=\"layout-column-1\">Column One, Paragraph One</p>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -34,8 +33,7 @@
"dropCap": false,
"className": "layout-column-1"
},
"innerBlocks": [],
"originalContent": "<p class=\"layout-column-1\">Column One, Paragraph Two</p>"
"innerBlocks": []
}
]
},
Expand All @@ -54,8 +52,7 @@
"dropCap": false,
"className": "layout-column-2"
},
"innerBlocks": [],
"originalContent": "<p class=\"layout-column-2\">Column Two, Paragraph One</p>"
"innerBlocks": []
}
]
},
Expand All @@ -74,12 +71,10 @@
"dropCap": false,
"className": "layout-column-3"
},
"innerBlocks": [],
"originalContent": "<p class=\"layout-column-3\">Column Three, Paragraph One</p>"
"innerBlocks": []
}
]
}
],
"originalContent": "<div class=\"wp-block-columns has-3-columns\">\n\t\n\t\n\t\n\t\n</div>"
]
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"content": "Column One, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph One</p>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -33,11 +32,9 @@
"content": "Column One, Paragraph Two",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column One, Paragraph Two</p>"
"innerBlocks": []
}
],
"originalContent": "<div class=\"wp-block-column\">\n\t\t\n\t\t\n\t</div>"
]
},
{
"clientId": "_clientId_1",
Expand All @@ -53,8 +50,7 @@
"content": "Column Two, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column Two, Paragraph One</p>"
"innerBlocks": []
},
{
"clientId": "_clientId_1",
Expand All @@ -64,13 +60,10 @@
"content": "Column Three, Paragraph One",
"dropCap": false
},
"innerBlocks": [],
"originalContent": "<p>Column Three, Paragraph One</p>"
"innerBlocks": []
}
],
"originalContent": "<div class=\"wp-block-column\">\n\t\t\n\t\t\n\t</div>"
]
}
],
"originalContent": "<div class=\"wp-block-columns is-not-stacked-on-mobile has-secondary-background-color has-background\">\n\t\n\t\n</div>"
]
}
]
Loading

0 comments on commit 5c5e292

Please sign in to comment.