-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix character newlines in pre (#13799)
* Fix character newlines in pre * Add e2e test
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/e2e-tests/specs/blocks/__snapshots__/preformatted.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Preformatted should preserve character newlines 1`] = ` | ||
"<!-- wp:html --> | ||
<pre>1 | ||
2</pre> | ||
<!-- /wp:html -->" | ||
`; | ||
|
||
exports[`Preformatted should preserve character newlines 2`] = ` | ||
"<!-- wp:preformatted --> | ||
<pre class=\\"wp-block-preformatted\\">0<br>1<br>2</pre> | ||
<!-- /wp:preformatted -->" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { | ||
getEditedPostContent, | ||
createNewPost, | ||
insertBlock, | ||
clickButton, | ||
} from '@wordpress/e2e-test-utils'; | ||
|
||
describe( 'Preformatted', () => { | ||
beforeEach( async () => { | ||
await createNewPost(); | ||
} ); | ||
|
||
it( 'should preserve character newlines', async () => { | ||
await insertBlock( 'Custom HTML' ); | ||
await page.keyboard.type( '<pre>1' ); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.keyboard.type( '2</pre>' ); | ||
|
||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
|
||
await page.keyboard.press( 'Escape' ); | ||
await page.click( 'button[aria-label="More options"]' ); | ||
await clickButton( 'Convert to Blocks' ); | ||
// Once it's edited, it should be saved as BR tags. | ||
await page.keyboard.type( '0' ); | ||
await page.keyboard.press( 'Enter' ); | ||
await page.click( 'button[aria-label="More options"]' ); | ||
await clickButton( 'Edit as HTML' ); | ||
|
||
expect( await getEditedPostContent() ).toMatchSnapshot(); | ||
} ); | ||
} ); |